[R] density plots using density.lf, data.frame and sort.int errors
R. Michael Weylandt
michael.weylandt at gmail.com
Thu May 31 20:25:15 CEST 2012
My guess (unconfirmed) is that read.table() gives you a data frame but
density.lf expects an atomic (= not a list = not a data frame) vector.
Perhaps try density.lf(x[,1]) to just send the column -- the "drop"
behavior should make sure this is an atomic vector.
If that doesn't help, please do provide us with the output of
dput(head(x, 30))
and the package from which the density.lf function comes from.
Best,
Michael
On Thu, May 31, 2012 at 11:35 AM, Andrea S Sequeira
<asequeir at wellesley.edu> wrote:
> Dear R help group: I am attempting to produce a density plot from a list of
> 20000 values using the density.lf function and would appreciate any help, I
> hope I have done my homework reading the documentation but I still seem to
> be missing something basic.
>
> I have read the data as a table using read.table, with header=TRUE (I
> excluded 2000 values), when calling the objects it appears to be there and
> I can see the values
>
> this is what I get when doing
>
> density.lf (x=logN0, n=50, window="gaussian")
>
> Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing =
> decreasing)) :
>
> undefined columns selected
>
> then assigned a column name (using colname so it is called first), then
> assigned it as a vector using
>
> assign ("x", c (logN0))
>
>
> the error I get is
>
>
> density.lf (x, n=50, window="gaussian")
>
> Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
>
> 'x' must be atomic
>
>
> the traceback produces:
>
>> traceback ()
>
> 5: stop("'x' must be atomic")
>
> 4: sort.int(x, na.last = na.last, decreasing = decreasing, ...)
>
> 3: sort.default(x)
>
> 2: sort(x)
>
> 1: density.lf(x, n = 50, window = "gaussian")
>
>
> Thanks in advance, Andrea
>
> --
> Andrea Sequeira
> Associate Professor
> Department of Biological Sciences
> Wellesley College, Wellesley MA 02481
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list