sandsky wrote:
> 
> I have a data set (csv); e.g.,
> 
> ID  samp1  samp2 samp3 samp4
> G1       23        32      12      87
> G2       85        45      49      76
> G3       12        46      39      28
> G4       73        26      18      13
> 
> and read it:
> 
> data1<-(read.csv("Datafolder/rawdata.csv",header=T))
> 
> It is fine with reading as above, but, if it is read as transposed values
> like:
> 
> data1<-t(read.csv("Datafolder/rawdata.csv",header=T))
> 
> ID         "G1"   "G2"   "G3"   "G4"
> samp1   "23"    "85"    "12"   "73"
> ...
> 
> all values are shown in "   ".
> 
> How to get this transposed data as numerical values?
> 
> 

Because ID is not numeric, and in a data frame each column must have the
same data type. The least common denominator is "character".

Written explicitly, you have to transpose the numeric part, and paste in the
names later. This could be shortened, but the example below gives the idea.

Dieter

d = data.frame(ID=c("G1","G2"), samp1=1:2,samp2=5:6)
d
t(d)
dt = as.data.frame(t(d[-1]))
names(dt)= d[,1]



-- 
View this message in context: 
http://www.nabble.com/reading-transposed-data-in-read.csv-tp24979445p24982142.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to