I'd like to read a file which contain 2 columns.
2 00001
9 00001
3 00001
12 00001
115 00001
11 00001
12 00001
38 00001
if I use the standard read.table
, I end up with something like that :
V1 V2
1 2 1
2 9 1
3 3 1
4 12 1
5 115 1
6 11 1
Do you have any idea on how I could read this file, and keep the 2nd column as it is? Thanks
Read the documentation for read.table()
and learn about how select column types. You want the second column as character.
Looks like you can pass an argument as.is
to change whether read.table attempts to parse strings into values, or keep them as raw strings.
as.is the default behavior of read.table is to convert character variables (which are not converted to logical, numeric or complex) to factors. The variable as.is controls this conversion. Its value is either a vector of logicals (values are recycled if necessary), or a vector of numeric or character indices which specify which columns should not be converted to factors.
Note: to suppress all conversions including those of numeric columns, set colClasses = "character".
http://stuff.mit.edu/afs/sipb/project/r-project/arch/i386_rhel3/lib/R/library/base/html/read.table.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With