Friday, 15 May 2015

r - Using read.table to read a CSV file gives a table with quotes -



r - Using read.table to read a CSV file gives a table with quotes -

i trying read csv file in r using read.table command , table in r has double quotes around every entry. problem cannot utilize these entries quotes mathematical operations.

here read command:

exprs_data <- as.matrix(read.table("test1.csv", sep= ",",header=true,row.names=1,as.is=true))##

here imported table in r:

abc def xyz m0122 " 854" "1487" "1855" m0152 " 97" " 159" " 468" m0257 " 157" " 733" " 6"

why there quotes around numbers?? never experienced problem in r before. can help me importing csv file in r?

the quotes indicate values in matrix strings rather numbers. without knowing csv file looks like, suspect value in file not valid number, , conversion matrix (your as.matrix) statement, converted strings comply required construction of matrix (needs same info type). i'm not exclusively sure why doing matrix conversion can explicitly specify in read.table type info using colclasses parameter. seek (assuming columns treated numbers, otherwise utilize vector of different values each column in colclasses):

exprs_data <- read.table("test1.csv", sep= ",", header=true, row.names=1, colclasses = "numeric")

you can convert matrix if want work straight info frame read.table returns. mentioned in comment, can details on construction (including column info types) of variable running str(exprs_data).

r csv read.table

No comments:

Post a Comment