Hi,
I'd like to change the default orientation of bwplot() and stripplot()
so the plots are displayed vertically. Passing horizontal=FALSE into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x <- rnorm(100);
y <- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df <- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
Many thanks for any suggestions!
Cheers,
Dave
Vertical bwplot and stripplot
8 messages · David Winsemius, David Neu, Peter Ehlers
On Apr 23, 2011, at 9:26 AM, David Neu wrote:
Hi,
I'd like to change the default orientation of bwplot() and stripplot()
so the plots are displayed vertically. Passing horizontal=FALSE into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x <- rnorm(100);
y <- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df <- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
A) hor is not defined B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`. Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE); (I didn't recognize the as.table argument, but experimentation seems to produce a top-down order to the plots.)
David Winsemius, MD West Hartford, CT
On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius <dwinsemius at comcast.net> wrote:
On Apr 23, 2011, at 9:26 AM, David Neu wrote:
Hi,
I'd like to change the default orientation of bwplot() and stripplot()
so the plots are displayed vertically. ?Passing horizontal=FALSE into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x <- rnorm(100);
y <- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df <- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
A) hor is not defined B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`. Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE); (I didn't recognize the as.table argument, but experimentation seems to produce a top-down order to the plots.) -- David Winsemius, MD West Hartford, CT
Many thanks for your reply!
A) hor is not defined
Ugggh, cut and paste mistake.
B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`.
I have data from related experiments in that involves two variables conditioned on a third. This data is displayed in an xyplot. The reason I'm trying to get the vertical orientation in the stripplot is that in some experiments the variable plotted on the horizontal axis is invariant and in these cases for consistency I'd like the variable that is plotted on the vertical axis to continue to appear vertically. For example in non-lattice graphics the following works: stripchart(rnorm(100), vert=TRUE).
Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE);
Yes, that's moving closer, but the strips containing the conditioning info are missing.
On Apr 23, 2011, at 10:13 AM, David Neu wrote:
On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius <dwinsemius at comcast.net
wrote: On Apr 23, 2011, at 9:26 AM, David Neu wrote:
Hi,
I'd like to change the default orientation of bwplot() and
stripplot()
so the plots are displayed vertically. Passing horizontal=FALSE
into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x <- rnorm(100);
y <- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df <- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
A) hor is not defined B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`. Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE); (I didn't recognize the as.table argument, but experimentation seems to produce a top-down order to the plots.) -- David Winsemius, MD West Hartford, CT
Many thanks for your reply!
A) hor is not defined
Ugggh, cut and paste mistake.
B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`.
I have data from related experiments in that involves two variables conditioned on a third. This data is displayed in an xyplot. The reason I'm trying to get the vertical orientation in the stripplot is that in some experiments the variable plotted on the horizontal axis is invariant and in these cases for consistency I'd like the variable that is plotted on the vertical axis to continue to appear vertically. For example in non-lattice graphics the following works: stripchart(rnorm(100), vert=TRUE).
Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE);
Yes, that's moving closer, but the strips containing the conditioning info are missing.
You only offered two variables, so It's unclear what sort of "conditioning info" you imagine. Your stripchart() example that you say "works" told me nothing. Unless perhaps you are trying for: stripplot( x~1 | y , data=my.df, layout=c(1,3), horizontal=FALSE)
David Winsemius, MD West Hartford, CT
On Sat, Apr 23, 2011 at 10:23 AM, David Winsemius
<dwinsemius at comcast.net> wrote:
On Apr 23, 2011, at 10:13 AM, David Neu wrote:
On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius <dwinsemius at comcast.net> wrote:
On Apr 23, 2011, at 9:26 AM, David Neu wrote:
Hi,
I'd like to change the default orientation of bwplot() and stripplot()
so the plots are displayed vertically. ?Passing horizontal=FALSE into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x <- rnorm(100);
y <- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df <- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
A) hor is not defined B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`. Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE); (I didn't recognize the as.table argument, but experimentation seems to produce a top-down order to the plots.) -- David Winsemius, MD West Hartford, CT
Many thanks for your reply!
A) hor is not defined
Ugggh, cut and paste mistake.
B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`.
I have data from related experiments in that involves two variables conditioned on a third. ?This data is displayed in an xyplot. ?The reason I'm trying to get the vertical orientation in the stripplot is that in some experiments the variable plotted on the horizontal axis is invariant and in these cases for consistency I'd like the variable that is plotted on the vertical axis to continue to appear vertically. For example in non-lattice graphics the following works: stripchart(rnorm(100), vert=TRUE).
Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE);
Yes, that's moving closer, but the strips containing the conditioning info are missing.
You only offered two variables, so It's unclear what sort of "conditioning info" you imagine. Your stripchart() ?example that you say "works" told me nothing. Unless perhaps you are trying for: stripplot( x~1 | y , data=my.df, ?layout=c(1,3), horizontal=FALSE) -- David Winsemius, MD West Hartford, CT
You only offered two variables, so It's unclear what sort of "conditioning info" you imagine.
Yes, the original message I sent showed two variables, x being continuous, y being a factor and x being conditioned on y.
Your stripchart() example that you say "works" told me nothing.
It was just meant to show what I'd like an single panel to look like.
Unless perhaps you are trying for: stripplot( x~1 | y , data=my.df, layout=c(1,3), horizontal=FALSE)
Yes, that will work just fine. Many, many thanks for your help!!! Have a good weekend. Cheers, Dave
On 2011-04-23 07:13, David Neu wrote:
On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius<dwinsemius at comcast.net> wrote:
On Apr 23, 2011, at 9:26 AM, David Neu wrote:
Hi,
I'd like to change the default orientation of bwplot() and stripplot()
so the plots are displayed vertically. Passing horizontal=FALSE into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x<- rnorm(100);
y<- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df<- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
A) hor is not defined B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`. Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE); (I didn't recognize the as.table argument, but experimentation seems to produce a top-down order to the plots.) -- David Winsemius, MD West Hartford, CT
Many thanks for your reply!
A) hor is not defined
Ugggh, cut and paste mistake.
B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`.
I have data from related experiments in that involves two variables conditioned on a third. This data is displayed in an xyplot. The reason I'm trying to get the vertical orientation in the stripplot is that in some experiments the variable plotted on the horizontal axis is invariant and in these cases for consistency I'd like the variable that is plotted on the vertical axis to continue to appear vertically. For example in non-lattice graphics the following works: stripchart(rnorm(100), vert=TRUE).
Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE);
Yes, that's moving closer, but the strips containing the conditioning info are missing.
You can define a 'phantom' single-level factor
my.df$fac <- rep("", 100)
stripplot(x ~ fac | y, data = my.df, layout = c(1, 3))
and I'd consider 'jitter'.
BTW, your method of generating 'y' seems overly complicated:
y <- sample(c("A","B","C"), 100,
replace=TRUE,
prob=c(1/2, 1/3, 1/6))
Peter Ehlers
On Sat, Apr 23, 2011 at 10:37 AM, Peter Ehlers <ehlers at ucalgary.ca> wrote:
On 2011-04-23 07:13, David Neu wrote:
On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius<dwinsemius at comcast.net> ?wrote:
On Apr 23, 2011, at 9:26 AM, David Neu wrote:
Hi,
I'd like to change the default orientation of bwplot() and stripplot()
so the plots are displayed vertically. ?Passing horizontal=FALSE into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x<- rnorm(100);
y<- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df<- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
A) hor is not defined B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`. Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE); (I didn't recognize the as.table argument, but experimentation seems to produce a top-down order to the plots.) -- David Winsemius, MD West Hartford, CT
Many thanks for your reply!
A) hor is not defined
Ugggh, cut and paste mistake.
B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`.
I have data from related experiments in that involves two variables conditioned on a third. ?This data is displayed in an xyplot. ?The reason I'm trying to get the vertical orientation in the stripplot is that in some experiments the variable plotted on the horizontal axis is invariant and in these cases for consistency I'd like the variable that is plotted on the vertical axis to continue to appear vertically. For example in non-lattice graphics the following works: stripchart(rnorm(100), vert=TRUE).
Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE);
Yes, that's moving closer, but the strips containing the conditioning info are missing.
You can define a 'phantom' single-level factor
?my.df$fac <- rep("", 100)
?stripplot(x ~ fac | y, data = my.df, layout = c(1, 3))
and I'd consider 'jitter'.
BTW, your method of generating 'y' seems overly complicated:
?y <- sample(c("A","B","C"), 100,
? ? ? ? ? ? ?replace=TRUE,
? ? ? ? ? ? ?prob=c(1/2, 1/3, 1/6))
Peter Ehlers
Ahh, that's nice. BTW, for my understanding, could you please explain why you suggested the use of 'jitter'? I'm thinking it's to aid in the visualization. Many thanks for your help!
On 2011-04-23 08:03, David Neu wrote:
On Sat, Apr 23, 2011 at 10:37 AM, Peter Ehlers<ehlers at ucalgary.ca> wrote:
On 2011-04-23 07:13, David Neu wrote:
On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius<dwinsemius at comcast.net> wrote:
On Apr 23, 2011, at 9:26 AM, David Neu wrote:
Hi,
I'd like to change the default orientation of bwplot() and stripplot()
so the plots are displayed vertically. Passing horizontal=FALSE into
stripplot in the simple code below doesn't seem to be the answer.
library(lattice);
x<- rnorm(100);
y<- as.factor(sapply(1:100, function(k) sample(c("A","B","C"), 1,
prob=c(1/2, 1/3, 1/6))));
my.df<- data.frame(x=x, y=y);
stripplot(~x | y, data=my.df, as.table=TRUE, layout=c(1,3), hor);
A) hor is not defined B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`. Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE); (I didn't recognize the as.table argument, but experimentation seems to produce a top-down order to the plots.) -- David Winsemius, MD West Hartford, CT
Many thanks for your reply!
A) hor is not defined
Ugggh, cut and paste mistake.
B) it doesn't make sense to me to have the continuous variable as the independent variable here, despite if being named `x`.
I have data from related experiments in that involves two variables conditioned on a third. This data is displayed in an xyplot. The reason I'm trying to get the vertical orientation in the stripplot is that in some experiments the variable plotted on the horizontal axis is invariant and in these cases for consistency I'd like the variable that is plotted on the vertical axis to continue to appear vertically. For example in non-lattice graphics the following works: stripchart(rnorm(100), vert=TRUE).
Try: stripplot(x~y , data=my.df, as.table=TRUE, layout=c(1,3), horizontal=FALSE);
Yes, that's moving closer, but the strips containing the conditioning info are missing.
You can define a 'phantom' single-level factor
my.df$fac<- rep("", 100)
stripplot(x ~ fac | y, data = my.df, layout = c(1, 3))
and I'd consider 'jitter'.
BTW, your method of generating 'y' seems overly complicated:
y<- sample(c("A","B","C"), 100,
replace=TRUE,
prob=c(1/2, 1/3, 1/6))
Peter Ehlers
Ahh, that's nice. BTW, for my understanding, could you please explain why you suggested the use of 'jitter'? I'm thinking it's to aid in the visualization.
Just try it:
stripplot(x ~ fac | y, data = my.df, layout = c(1, 3),
jitter.data = TRUE, factor = 0.8)
Play with different values of 'factor'; factor = 0 is
equivalent to leaving the jitter.data argument at the
default value of FALSE.
See the example in ?xyplot and see ?panel.stripplot.
Peter Ehlers