Re: [R] density(x)

From: Marc Schwartz <MSchwartz_at_medanalytics.com>
Date: Mon 05 Jul 2004 - 23:57:34 EST

On Mon, 2004-07-05 at 08:34, Christoph Hanck wrote:
> Dear experts,
>
> when trying to estimate an kernel density function with density(x) I get the following
> error message with imported data from either EXCEL or text files:
>
> Error in density(spr) : argument must be numeric.
>
> Other procedues such as truehist work. If I generate data within R density works fine.
> Does anybody have an idea?

More than likely, your vector 'spr' was imported as a factor. This would possibly suggest that at least one value in 'spr' is not numeric. If the entire vector was numeric, this would not be a problem.

It is also possible that you may have not specified the proper delimiting character during the import, which would compromise the parsed structure of the incoming data.

Use:

str(spr)

and you will probably get

Factor ...

First, check to be sure that you have used the proper delimiting character during your import. See ?read.table for the family of related functions and the default argument values for 'sep', which is the delimiting character.

You should also check your source data file, since it may be problematic.

HTH, Marc Schwartz



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:01:30 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:41 EST