[R] Teach me how to transpose in R

Marcio Resende mresendeufv at yahoo.com.br
Sun Sep 27 06:57:41 CEST 2009


Hi Hyo,
I am kinda of new in R but I think if you use
x <- as.matrix(data2) #with the numer of collumns you wish
y <- t(x)

it should work

Hope I´ve helped

Márcio



Hyo Lee wrote:
> 
> Hi guys,
> I need your help!!
> 
> My goal is to make a csv file from ncdf file.
> This is the code i've used :
> 
>> hyo=open.ncdf("C:/CRUTEM3.nc")
>> hyo
> [1] "file C:/CRUTEM3.nc has 4 dimensions:"
> [1] "longitude   Size: 72"
> [1] "latitude   Size: 36"
> [1] "unspecified   Size: 1"
> [1] "t   Size: 1916"
> [1] "------------------------"
> [1] "file C:/CRUTEM3.nc has 1 variables:"
> [1] "float temp[longitude,latitude,unspecified,t]  Longname:Temperature T
> Missval:2.00000004008175e+20"
>> data2=get.var.ncdf(hyo)
>> write.csv(data2,file="C:/ple.csv")
> 
> 
> But the problem is, I expected this data would be 17000 * 72  (row* col) ;
> but, it is the other way around. 72*17000
> Because the maximum col number in excel is 16383, this cvs file doesn't
> show
> all data. Obviously, I need to transpose the matrix..
> I tried to use transpose function but failed.
> 
>> bbb=t(data2)
> Error in t.default(data2) : argument is not a matrix
>> ccc=t(hyo)
>> ccc
> [1] "file  has  dimensions:"
> Error in if (nc$ndims > 0) for (i in 1:nc$ndims) { :
>   argument is of length zero
> 
> Teach me how to deal with this problem.
> Thank you very much.
> 
> -Hyo
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Teach-me-how-to-transpose-in-R-tp25630869p25630947.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list