Quantcast

Data scaled by lattice::stripplot

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Data scaled by lattice::stripplot

meonline
For the following example,

> library(lattice)
> df<-data.frame(i=1:100,p=runif(100),id=rep(c('a','b'),100))
> summary(df[,'p'])
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
0.01165 0.33580 0.57520 0.53290 0.74540 0.98610
> stripplot(p~i|id,df)

The plot that is output is as expected with the exception that the values are scaled by a factor of 100 in the plot (and the yaxis has too many labels) -- see attached screenshot.

I'm running R.2.10 under Ubuntu 10.04.

Why does this happen and how do I get the stripplot to plot the values as they are in the data (from 0 to 1)?



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Data scaled by lattice::stripplot

meonline
Forgot the attachment :-(Screenshot-1.png
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Data scaled by lattice::stripplot

Pascal Oettli-2
In reply to this post by meonline
Hello,

It works with lattice::xyplot.

Best Regards


Le 29/06/2012 13:06, meonline a écrit :

> For the following example,
>
>> library(lattice)
>> df<-data.frame(i=1:100,p=runif(100),id=rep(c('a','b'),100))
>> summary(df[,'p'])
>     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
> 0.01165 0.33580 0.57520 0.53290 0.74540 0.98610
>> stripplot(p~i|id,df)
>
> The plot that is output is as expected with the exception that the values
> are scaled by a factor of 100 in the plot (and the yaxis has too many
> labels) -- see attached screenshot.
>
> I'm running R.2.10 under Ubuntu 10.04.
>
> Why does this happen and how do I get the stripplot to plot the values as
> they are in the data (from 0 to 1)?
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Data-scaled-by-lattice-stripplot-tp4634809.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Data scaled by lattice::stripplot

Peter Ehlers
In reply to this post by meonline
On 2012-06-28 21:06, meonline wrote:

> For the following example,
>
>> library(lattice)
>> df<-data.frame(i=1:100,p=runif(100),id=rep(c('a','b'),100))
>> summary(df[,'p'])
>     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
> 0.01165 0.33580 0.57520 0.53290 0.74540 0.98610
>> stripplot(p~i|id,df)
>
> The plot that is output is as expected with the exception that the values
> are scaled by a factor of 100 in the plot (and the yaxis has too many
> labels) -- see attached screenshot.
>
> I'm running R.2.10 under Ubuntu 10.04.
>
> Why does this happen and how do I get the stripplot to plot the values as
> they are in the data (from 0 to 1)?

You need to understand what a stripplot is for; as the
help page says: "stripplot produces one-dimensional
scatterplots".

It's usually used to compare several such one-dim plots
for different levels of a factor variable; see the
example on the help page or the examples on the help
page for stripchart which does the same thing using
traditional graphics. Using your data, try:

  stripplot(p ~ id, data = df)

With stripplot(p ~ i | id, df), lattice coerces 'p' to
a factor, assigning levels '1', '2', ..., '100' since
you have 100 different values. It then plots 100
strips _horizontally_ (you can't tell since each
plot has only a single value). You get 100 labels on
the y-axis. No scaling has taken place.

The measured variable is taken to be 'i'. Its values
are also 1-100 and that's what you see on the x-axis.

Try adding 'horizontal = FALSE' to the command:

   stripplot(p ~ i | id, data = df, horizontal = FALSE)

This will give you 100 _vertical_ strips, using 'i' as
the factor variable. The measured variable is then 'p'
and you'll see the values you were expecting.

But I suspect that you never wanted a stripplot at all.

Peter Ehlers

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Data scaled by lattice::stripplot

meonline
Thanks, Peter.  You are correct in that I was incorrectly interpreting
the purpose of stripplot and as a result, my expectations were
invalid.  Thanks for getting me back on track and your promptness in
responding.

@Pascal Thanks for the feedback.  However, FTR, specifying the package
by using lattice::stripplot produced the same result.  This is not
surprising given Peter's response.

Finally, and also  FTR, I have upgraded my R installation to 2.15.1
and lattice package to 0.18-3 with the same results. Again, not
surprising given that I was misinterpreting what to expect.  Bottom
line is that in all cases, R 2.10.1, specifying the package, and R
2.15.1 the function is and was performing as it should have been.
Operator error.

Best,
[hidden email]


On Fri, Jun 29, 2012 at 7:47 AM, Peter Ehlers [via R]
<[hidden email]> wrote:

> On 2012-06-28 21:06, meonline wrote:
>
>> For the following example,
>>
>>> library(lattice)
>>> df<-data.frame(i=1:100,p=runif(100),id=rep(c('a','b'),100))
>>> summary(df[,'p'])
>>     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
>> 0.01165 0.33580 0.57520 0.53290 0.74540 0.98610
>>> stripplot(p~i|id,df)
>>
>> The plot that is output is as expected with the exception that the values
>> are scaled by a factor of 100 in the plot (and the yaxis has too many
>> labels) -- see attached screenshot.
>>
>> I'm running R.2.10 under Ubuntu 10.04.
>>
>> Why does this happen and how do I get the stripplot to plot the values as
>> they are in the data (from 0 to 1)?
>
> You need to understand what a stripplot is for; as the
> help page says: "stripplot produces one-dimensional
> scatterplots".
>
> It's usually used to compare several such one-dim plots
> for different levels of a factor variable; see the
> example on the help page or the examples on the help
> page for stripchart which does the same thing using
> traditional graphics. Using your data, try:
>
>   stripplot(p ~ id, data = df)
>
> With stripplot(p ~ i | id, df), lattice coerces 'p' to
> a factor, assigning levels '1', '2', ..., '100' since
> you have 100 different values. It then plots 100
> strips _horizontally_ (you can't tell since each
> plot has only a single value). You get 100 labels on
> the y-axis. No scaling has taken place.
>
> The measured variable is taken to be 'i'. Its values
> are also 1-100 and that's what you see on the x-axis.
>
> Try adding 'horizontal = FALSE' to the command:
>
>    stripplot(p ~ i | id, data = df, horizontal = FALSE)
>
> This will give you 100 _vertical_ strips, using 'i' as
> the factor variable. The measured variable is then 'p'
> and you'll see the values you were expecting.
>
> But I suspect that you never wanted a stripplot at all.
>
> Peter Ehlers
>
> ______________________________________________
> [hidden email] 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.
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/Data-scaled-by-lattice-stripplot-tp4634809p4634869.html
> To unsubscribe from Data scaled by lattice::stripplot, click here.
> NAML
Loading...