How to avoid: read.table truncates numeric values beginning with 0

前端 未结 3 1228
走了就别回头了
走了就别回头了 2020-11-28 13:03

I want to import a table (.txt file) in R with read.table(). One column in my table is an ID with nine numerals - some ids begin with a 0, other wi

3条回答
  •  渐次进展
    2020-11-28 13:21

    A reproducible example would be nice, but: use the colClasses argument to read.table() to specify that you want this column to be read as a character variable, not numeric. Or make them back into character variables after reading them in, using sprintf to pad the numbers with leading zeros. (The former is probably easier.)

提交回复
热议问题