[R] how to get vector of data from line ?

Greg Snow Greg.Snow at imail.org
Tue Dec 7 19:46:33 CET 2010


There are a few different options depending on what you are trying to do.

If you just need some data pairs (for plotting for example), then the return from density has a vector of x's and a vector of y's, just use those.

If you have specific x values that you need the height at and they follow a regular pattern, then you can modify the from, to, and n parameters to generate your x values, then they are in the return value.

You can approximate the values by passing the x and y from the return of density to the functions approx or approxfun.

You can estimate the density in a different way using the logspline package, it provides functions to give you the height of the curve at specified values.

You can just add the kernels together at your specified x values instead of using density (search the archives, I think Prof. Ripley recently posted a function to do this or similar).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of madr
> Sent: Tuesday, December 07, 2010 11:28 AM
> To: r-help at r-project.org
> Subject: [R] how to get vector of data from line ?
> 
> 
> I have created a density line
> d<- density(X)
> now I need to read values from that line
> 
> for example what is the value of this line at x = 1, 2, 3 etc...
> --
> View this message in context: http://r.789695.n4.nabble.com/how-to-get-
> vector-of-data-from-line-tp3076943p3076943.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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