[R] Problems reshaping data with cast()

From: Neil Shephard <nshephard_at_gmail.com>
Date: Thu, 7 Feb 2008 13:11:10 +0000


I'm trying to cast() some data, but keep on getting the following error...

> norm.all.melted.height <- transform(all.melted.height,

+                                     norm.height = value / ave(value,
SNP, Pool, FUN = max)
+                                     )

Warning messages:
1: In FUN(X[[147L]], ...) :
  no non-missing arguments to max; returning -Inf 2: In FUN(X[[147L]], ...) :
  no non-missing arguments to max; returning -Inf 3: In FUN(X[[147L]], ...) :
  no non-missing arguments to max; returning -Inf
> norm.all.melted.height <- subset(norm.all.melted.height, select=c("Sample.Name", "SNP", "Pool", "variable", "norm.height"))
> names(norm.all.melted.height) <- c("Sample.Name", "SNP", "Pool", "variable", "value")
> ## Now reshape the data

> normalised <- cast(norm.all.melted.height, Sample.Name + SNP + Pool ~ value, sum)

Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :   negative length vectors are not allowed

Is the error thats occuring with cast() likely to be caused by the previous warnings?

As far as I can work out rep.int() is called to expand the data based on the grouping specified (in this case the left hand portion of the cast formula, i.e. Sample.Name + SNP + Pool), but how would there be a negative index in this data? I had previously melted the data into this format.

Apologies for not providing a reproducible example, I suspect the problem lies within the data structure I'm using.

Thanks for reading this question,


Email - nshephard_at_gmail.com / n.shephard_at_sheffield.ac.uk
Photos - http://www.flickr.com/photos/slackline/

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 07 Feb 2008 - 13:12:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 07 Feb 2008 - 15:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive