[R] density() function: differences with S-PLUS

Joshua Wiley jwiley.psych at gmail.com
Tue Nov 2 17:56:51 CET 2010


Dear Nicola,

There are undoubtedly people here who are familiar with both S+ and R,
but they may not always be around or get to every question.  In that
case there are (at least) two good options for you:

1) Say what you want mathematically (something of a universal
language) or statistically

2) Rather than just give us S+ code, show sample data (e.g., 1:1000),
and the values you would like obtained (in this case whatever the
output from S+ was).  This would let us *try* to figure out what
happened and duplicate it in R.

>From the arcane step of reading R's documentation for density (?density):

width: this exists for compatibility with S; if given, and ‘bw’ is
          not, will set ‘bw’ to ‘width’ if this is a character string,
          or to a kernel-dependent multiple of ‘width’ if this is
          numeric.

Which makes me wonder if this works for you (in R)?

density(1:1000, width = 4)


Cheers,

Josh


On Tue, Nov 2, 2010 at 3:04 AM, Nicola Sturaro Sommacal (Quantide srl)
<mailinglist at sturaro.net> wrote:
> Hello!
>
> Someone know what are the difference between R and S-PLUS in the density()
> function?
>
> For example, I would like to reply this simple S-PLUS code in R, but I don't
> understand which parameter I should modify to get the same results.
>
> S-PLUS CODE:
> density(1:1000, width = 4)
>
> R-CODE:
> density(1:1000, bw = 4, window = "g",  n = 50, cut = 0.75)
>
> I obtain the same x values, but different y values. I try also different
> examples, with different parameter.
>
> Can you help me?
>
> Thank you in advance.
>
> Nicola Sturaro
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list