Need help using lattice

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help using lattice

Gerrit Draisma-2
David,
Is this what you are looking for?
library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
                  month=1:12)
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH Gerrit

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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
|

Re: Need help using lattice

Gerrit Draisma-2
Ha David,
Thanks for your reply.
For your last question, you have to change month into an ordered factor
variable:

library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
                  month=factor(3:12,levels=1:12,
                               labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH, Gerrit



Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:

> That worked nicely;  thanks again.  Here’s what I used for our data:
>
> library(lattice)
>
> df <-
> expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)
>
> dotplot(months~conc | site, data=df)
>
> The result is attached.  Is there a way to replace the month numbers on
> the y axes with the names Apr-Dec?
>
> David
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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
|

Re: Need help using lattice

David Parkhurst
Thank you.

From: Gerrit Draisma <[hidden email]>
Date: Tuesday, February 9, 2021 at 6:14 AM
To: Parkhurst, David F. <[hidden email]>
Cc: [hidden email] <[hidden email]>
Subject: Re: [R] Need help using lattice
Ha David,
Thanks for your reply.
For your last question, you have to change month into an ordered factor
variable:

library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
                  month=factor(3:12,levels=1:12,
                               labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH, Gerrit



Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:

> That worked nicely;  thanks again.  Here�s what I used for our data:
>
> library(lattice)
>
> df <-
> expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)
>
> dotplot(months~conc | site, data=df)
>
> The result is attached.  Is there a way to replace the month numbers on
> the y axes with the names Apr-Dec?
>
> David
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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
|

Re: Need help using lattice

David Parkhurst
In reply to this post by Gerrit Draisma-2
When I enter your line:
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
                  month=factor(3:12,levels=1:12,
                               labels=month.abb, ordered=TRUE))
I get + signs in front of month and label, as expected, and it follows with <

When I convert that to use my own variable names to this:
df <- expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE"),
    monames=factor(3:12, levels=1:12,
       labels=AprToDec, ordered=TRUE))
 I get + signs in front of monames and labels, again as expected, but then it gives me another + sign.  And if I try to add another ), it keeps giving me + signs.  What is happening here?

From: Gerrit Draisma <[hidden email]>
Date: Tuesday, February 9, 2021 at 6:14 AM
To: Parkhurst, David F. <[hidden email]>
Cc: [hidden email] <[hidden email]>
Subject: Re: [R] Need help using lattice
Ha David,
Thanks for your reply.
For your last question, you have to change month into an ordered factor
variable:

library(lattice)
df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
                  month=factor(3:12,levels=1:12,
                               labels=month.abb, ordered=TRUE))
df$conc <- rnorm(dim(df)[1])
dotplot(month~conc|site,data=df)

HTH, Gerrit



Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:

> That worked nicely;  thanks again.  Here’s what I used for our data:
>
> library(lattice)
>
> df <-
> expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)
>
> dotplot(months~conc | site, data=df)
>
> The result is attached.  Is there a way to replace the month numbers on
> the y axes with the names Apr-Dec?
>
> David
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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
|

Re: Need help using lattice

Gerrit Draisma-2
Ha David,
I do not know.
It must be that your AprtoDec object  is different from month.abb.
Anyhow it should contain the labels for all twelve months!
If I copy your command in an interactive session I just get the message
that AprtoDec is not defined.

I understand that you type the commands interactively in an R session?
I usually prefer using an editor to write the program, and execute with a
 > source("dotplot.R",echo=TRUE)
command.
I like an editor with syntax highlighting and shows matching brackets.

I have attached my dotplot.R to this mail.

Gerrit

Op 09-02-2021 om 21:14 schreef Parkhurst, David F.:

> When I enter your line:
> df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
>                    month=factor(3:12,levels=1:12,
>                                 labels=month.abb, ordered=TRUE))
> I get + signs in front of month and label, as expected, and it follows with <
>
> When I convert that to use my own variable names to this:
> df <- expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE"),
>      monames=factor(3:12, levels=1:12,
>         labels=AprToDec, ordered=TRUE))
>   I get + signs in front of monames and labels, again as expected, but then it gives me another + sign.  And if I try to add another ), it keeps giving me + signs.  What is happening here?
>
> From: Gerrit Draisma <[hidden email]>
> Date: Tuesday, February 9, 2021 at 6:14 AM
> To: Parkhurst, David F. <[hidden email]>
> Cc: [hidden email] <[hidden email]>
> Subject: Re: [R] Need help using lattice
> Ha David,
> Thanks for your reply.
> For your last question, you have to change month into an ordered factor
> variable:
>
> library(lattice)
> df <- expand.grid(site=c("een","twee","drie","vier","vijf"),
>                    month=factor(3:12,levels=1:12,
>                                 labels=month.abb, ordered=TRUE))
> df$conc <- rnorm(dim(df)[1])
> dotplot(month~conc|site,data=df)
>
> HTH, Gerrit
>
>
>
> Op 08-02-2021 om 21:04 schreef Parkhurst, David F.:
>> That worked nicely;  thanks again.  Here’s what I used for our data:
>>
>> library(lattice)
>>
>> df <-
>> expand.grid(site=c("CrCr","NFSC","MFSC","SFSC","LMO","MCE","MUE","MLE","MoCe"),months=1:9)
>>
>> dotplot(months~conc | site, data=df)
>>
>> The result is attached.  Is there a way to replace the month numbers on
>> the y axes with the names Apr-Dec?
>>
>> David
>>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.

dotplot.R (616 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need help using lattice

David Parkhurst
Thanks.  What editor do you use?  I'm working in a Mac, if that makes a difference.

From: Gerrit Draisma <[hidden email]>
Date: Tuesday, February 9, 2021 at 5:10 PM
To: Parkhurst, David F. <[hidden email]>
Cc: [hidden email] <[hidden email]>
Subject: Re: [R] Need help using lattice
Ha David,
I do not know.
It must be that your AprtoDec object  is different from month.abb.
Anyhow it should contain the labels for all twelve months!
If I copy your command in an interactive session I just get the message
that AprtoDec is not defined.

I understand that you type the commands interactively in an R session?
I usually prefer using an editor to write the program, and execute with a
 > source("dotplot.R",echo=TRUE)
command.
I like an editor with syntax highlighting and shows matching brackets.

I have attached my dotplot.R to this mail.

Gerrit

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.