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.
Forgot the attachment :-( http://r.789695.n4.nabble.com/file/n4634810/Screenshot-1.png Screenshot-1.png -- View this message in context: http://r.789695.n4.nabble.com/Data-scaled-by-lattice-stripplot-tp4634809p4634810.html Sent from the R help mailing list archive at Nabble.com.
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. > > ______________________________________________ > 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. >
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