Re: [R] density(x)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 06 Jul 2004 - 00:49:16 EST


OK, so sp is a data frame. Probably you want density(sp$sp) there since the single column is already numeric.

It just so happens that truehist does an implicit drop() on a 1-column data frame.

On Mon, 5 Jul 2004, Christoph Hanck wrote:

> Hello and thanks for your reply
>
> Hopefully, my answer arrives at the correct place like that (if not, I am sorry for bothering you, but please let me know...)
>
> To sum up my procedure (sp is exactly the same thing as spr, I had just tinkered with
> the names while trying sth. to solve this problem)
>
> > sp<-read.table("c:/ratsdata/sp3.txt", col.names="sp")
> > xd<-density(sp)
> Error in density(sp) : argument must be numeric
>
> The suggested remedies yield the following
> > str(sp)
> `data.frame': 195 obs. of 1 variable:
> $ sp: int 11 10 10 12 25 22 12 23 13 15 ...
> > xd<-density(as.numeric(sp))
> Error in as.double.default(sp) : (list) object cannot be coerced to double
>
> Hence, it does not seem to be a factor. Declaring it as numeric gives another error
> message, on which I haven't yet found any help in Google/the archive.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jul 06 00:53:26 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:34:02 EST