Peter Dalgaard BSA writes:
Li Dongfeng <mavip5@inet.polyu.edu.hk> writes:
Suppose we have a data file containing:
"Smith, John", 120, 90
"Thomson, Peter", 110, 85
there are 3 variables in it. If we use
x <- read.table("tmp.txt", sep=",")
to read the data to a data.frame,
the result will be 4 columns.
Splus 4.0 have no problem with this kind
of data.
read.table("data", sep=",")
V2 V3 V4
"Smith John\" 120 90
"Thomson Peter\" 110 85
i.e. 3 variables but with row.names '"Smith' and '"Thomson'
Or, closer to what R does:
read.table("data", sep=",",row.names=NULL)
V1 V2 V3 V4
1 \"Smith John\" 120 90
2 \"Thomson Peter\" 110 85
By its definition, this is what sep=',' must do, but it obviously will
not handle all CSV files properly. Anyone want to write a read.csv()
function or something of the sorts? It would be very useful.