[R] density(x)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Jul 5 16:49:16 CEST 2004
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 at 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
More information about the R-help
mailing list