如何避免R自动将字符串转换为数字?

时间:2018-01-14 02:40:12

标签: r import-from-csv

当我从access或excel中读取数据时,R会转换" string"中的变量格式。到" int"。

这是一个小样本:

NumberFit   stringFit   LetterFit
0           000000000      0
1           000000001      U
2           000000010      L
3           000000011      LU

将数据导入R后,我有:

<-States
    NumberFit stringFit LetterFit
          0         0         0
          1         1         U
          2        10         L
          3        11        LU

> str(States)
'data.frame':   514 obs. of  3 variables:
 $ NumberFit: int  0 1 2 3 4 5 6 7 8 9 ...
 $ stringFit: int  0 1 10 11 100 101 110 111 1000 1001 ...
 $ LetterFit: Factor w/ 514 levels "0","B","BD","BDL"

但是,我需要数据的字符串格式。有人能帮助我吗?

0 个答案:

没有答案