[R] Odp: Creation of a new data frame

Petr PIKAL petr.pikal at precheza.cz
Thu Mar 25 15:39:05 CET 2010


r-help-bounces at r-project.org napsal dne 25.03.2010 14:32:46:

> Dear all,
> I have a data frame of 18556 rows and 19 columns and wish to create a 
new grid
> from these data of dimensions 360 rows and 720 columns.
> The existing data frame is set up so that every 38 rows makes up one row 

What is make up. I know women use it but I am not sure how you would like 
to use it on your PC. R has not yet developed an interface for makeups.

> the new data frame, with 2 NA values at the end of each 'block' that 
should be
> removed before being inserted into the new grid.
> So to be clear, row 1 of the new data frame consists of rows 1:38 of the 

this is 38 values

> existing data frame, with the 2 NA values on the end removed. Row 2 is 
39:77 and so on.
and this is 39 values. OK lets assume that it is a misprint.

Besides you can not exactly split your data frame to portions by 38 
> 18556/38
[1] 488.3158

fac<-rep(1:489, each=38)
[1] 18582
[1] 18556
other.data <- aggregate(some.data, list(fac), mean, na.rm=T)

shall result in data frame other.data in which in all rows is mean of 38 
rows of some.data data frame.

> How do I go about creating this new 360 x 720 grid from existing data?

I have no idea. You have 352546 values and you want 259200 values. How do 
you want to do it is mystery for me.


> Many thanks,
> Steve
> _________________________________________________________________
> We want to hear all your funny, exciting and crazy Hotmail stories. Tell 
us now
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list