Re: [R] Problems reshaping data with cast()

2008-02-07 Thread Neil Shephard
On Feb 7, 2008 2:21 PM, hadley wickham <[EMAIL PROTECTED]> wrote:
> Hi Neil,
>
> I think your cast statement is wrong.  You have
>
> cast(norm.all.melted.height, Sample.Name + SNP + Pool ~ value, sum)
>
> but I think you want
>
> cast(norm.all.melted.height, Sample.Name + SNP + Pool ~ ., sum)
>
> i.e. value never appears in the cast formula.

Hi Hadley,

Your right, my formula was wrong. I should have had 'variable' in
place of 'value'.

> cast(norm.all.melted.height, Sample.Name + SNP + Pool ~ variable, sum)

Thanks for the help, and apologies for the dumb mistake (I even have
your paper from Journal of Statistical Software sat on my desk and
still managed to miss the glaringly obvious).

"Everyone is entitled to be stupid, but some abuse the privilege."  - Unknown

I guess I've been abusing my privilege a bit today.

Neil
-- 

Email - [EMAIL PROTECTED] / [EMAIL PROTECTED]
Photos - http://www.flickr.com/photos/slackline/

__
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.


Re: [R] Problems reshaping data with cast()

2008-02-07 Thread hadley wickham
Hi Neil,

I think your cast statement is wrong.  You have

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

but I think you want

cast(norm.all.melted.height, Sample.Name + SNP + Pool ~ ., sum)

i.e. value never appears in the cast formula.

Hadley

On Feb 7, 2008 7:11 AM, Neil Shephard <[EMAIL PROTECTED]> wrote:
> 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 - [EMAIL PROTECTED] / [EMAIL PROTECTED]
> Photos - http://www.flickr.com/photos/slackline/
>
> __
> 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.
>



-- 
http://had.co.nz/

__
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.


[R] Problems reshaping data with cast()

2008-02-07 Thread Neil Shephard
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 - [EMAIL PROTECTED] / [EMAIL PROTECTED]
Photos - http://www.flickr.com/photos/slackline/

__
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.