[R] Problems reshaping data with cast()
Neil Shephard
nshephard at gmail.com
Thu Feb 7 14:11:10 CET 2008
Hi,
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,
Neil
--
Email - nshephard at gmail.com / n.shephard at sheffield.ac.uk
Photos - http://www.flickr.com/photos/slackline/
More information about the R-help
mailing list