Hi!
I'm trying to read data from csv file, but instead of e.g. 001000 I get 1000 in my data.
I've tried to set as.is=!stringsAsFactors, but got error: object stringsAsFactors not found.
Anybody can help?
views:
150answers:
1
+1
A:
I've found workaround: add colClasses description
data_raw<-read.table("data",colClasses=c("character","character","character"),sep="\t",quote="\"")
How to convert character to vector:
It's easier to use separators in data, because finally you'll get character and to convert it to e.g. vector you should do smth like:
m<-as.integer(unlist(strsplit("0,1,1,1,0",split=",")))
m
[1] 0 1 1 1 0
or
m<-as.integer(scan(textConnection("0,1,1,1,0"),sep=","))
Ivri
2010-02-20 03:25:09