I am trying to produce multiple violin plots by 3 categorical variables, each violin representing 1 year worth of data. The variables are: Watershed (7 levels: county canals) Geography (5 levels: west; central; east; mouth; bay) Parameter (8 levels: water quality chemical parameters) Year (25 levels: 1992-2017) I want to produce 1 plot for each Parameter-Watershed subdivided into Geography with a violin for each year. I used facets with the following code (not by year): ggplot () + facet_grid (PARAMETER ~Wshed, scales="free_y") + geom_violin (data=merged, aes(x=Geo, y=RESULT)) I do not want facets, they crowd the information so it is unreadable. I just started with R this week and have not been able to figure out the foreach protocol, or any other loop protocol. I tried to subset the data to do it iteratively with the following code: subdf<-subset (merged, Wshed = "AC") but got an error: Error: unexpected input in "subdf=subset (merged, Wshed == "" Any help would be greatly appreciated. Thanks, Omar Abdelrahman, Biologist II Miami-Dade County, Department of Regulatory and Economic Resources Division of Environmental Resources Management (DERM) Overtown Transit Village 701 NW 1st Court, 5th Floor Miami, FL 33136-3912 (305) 372-6872 abdelo at miamidade.gov<mailto:abdelo at miamidade.gov> www.miamidade.gov/environment<http://www.miamidade.gov/environment/> [[alternative HTML version deleted]]
Read A) the Posting Guide (re plain text only... your emails may be damaged by the mailing list if you send html-formatted email... only you can solve this by figuring out how to use your email software) B) Help on assignment (?`=`) C) Help on logical tests (?`==`) -- Sent from my phone. Please excuse my brevity. On May 16, 2017 7:06:40 AM PDT, "Abdelrahman, Omar (RER)" <Omar.Abdelrahman at miamidade.gov> wrote:>I am trying to produce multiple violin plots by 3 categorical >variables, each violin representing 1 year worth of data. The variables >are: > >Watershed (7 levels: county canals) > >Geography (5 levels: west; central; east; mouth; bay) > >Parameter (8 levels: water quality chemical parameters) > >Year (25 levels: 1992-2017) > >I want to produce 1 plot for each Parameter-Watershed subdivided into >Geography with a violin for each year. I used facets with the following >code (not by year): > >ggplot () + > >facet_grid (PARAMETER ~Wshed, scales="free_y") + > >geom_violin (data=merged, aes(x=Geo, y=RESULT)) > > > >I do not want facets, they crowd the information so it is unreadable. I >just started with R this week and have not been able to figure out the >foreach protocol, or any other loop protocol. I tried to subset the >data to do it iteratively with the following code: > > > >subdf<-subset (merged, Wshed = "AC") > > > >but got an error: Error: unexpected input in "subdf=subset (merged, >Wshed == "" > >Any help would be greatly appreciated. > >Thanks, > >Omar Abdelrahman, Biologist II >Miami-Dade County, Department of Regulatory and Economic Resources >Division of Environmental Resources Management (DERM) >Overtown Transit Village >701 NW 1st Court, 5th Floor >Miami, FL 33136-3912 >(305) 372-6872 >abdelo at miamidade.gov<mailto:abdelo at miamidade.gov> >www.miamidade.gov/environment<http://www.miamidade.gov/environment/> > > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org 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.
Please use reply-all or equivalent to keep the list in the conversation. I don't do private online consultation. Your example suggested you did not know the difference, but your error suggests a completely different expression triggered the error, so all the more reason to give us an example that we can run to trigger the same error. Items B and C are recommendations to read the help pages for those syntax elements. You should already have read enough of an introduction to R to have encountered the use of the question mark to bring up the help pages. If not, please do. -- Sent from my phone. Please excuse my brevity. On May 16, 2017 9:00:09 AM PDT, "Abdelrahman, Omar (RER)" <Omar.Abdelrahman at miamidade.gov> wrote:>Thanks Jeff. I will send plain text from now on. I am not sure what B >or C mean; is there a guide that I can reference? I know the difference >between "=" and "==" , they work the same in Stata and SAS. > >Omar >-----Original Message----- >From: Jeff Newmiller [mailto:jdnewmil at dcn.davis.ca.us] >Sent: Tuesday, May 16, 2017 11:43 AM >To: r-help at r-project.org; Abdelrahman, Omar (RER) ><Omar.Abdelrahman at miamidade.gov>; 'r-help at r-project.org' ><r-help at r-project.org> >Subject: Re: [R] violin plot help > >Read >A) the Posting Guide (re plain text only... your emails may be damaged >by the mailing list if you send html-formatted email... only you can >solve this by figuring out how to use your email software) >B) Help on assignment (?`=`) >C) Help on logical tests (?`==`) >-- >Sent from my phone. Please excuse my brevity. > >On May 16, 2017 7:06:40 AM PDT, "Abdelrahman, Omar (RER)" ><Omar.Abdelrahman at miamidade.gov> wrote: >>I am trying to produce multiple violin plots by 3 categorical >>variables, each violin representing 1 year worth of data. The >variables >>are: >> >>Watershed (7 levels: county canals) >> >>Geography (5 levels: west; central; east; mouth; bay) >> >>Parameter (8 levels: water quality chemical parameters) >> >>Year (25 levels: 1992-2017) >> >>I want to produce 1 plot for each Parameter-Watershed subdivided into >>Geography with a violin for each year. I used facets with the >following >>code (not by year): >> >>ggplot () + >> >>facet_grid (PARAMETER ~Wshed, scales="free_y") + >> >>geom_violin (data=merged, aes(x=Geo, y=RESULT)) >> >> >> >>I do not want facets, they crowd the information so it is unreadable. >I >>just started with R this week and have not been able to figure out the > >>foreach protocol, or any other loop protocol. I tried to subset the >>data to do it iteratively with the following code: >> >> >> >>subdf<-subset (merged, Wshed = "AC") >> >> >> >>but got an error: Error: unexpected input in "subdf=subset (merged, >>Wshed == "" >> >>Any help would be greatly appreciated. >> >>Thanks, >> >>Omar Abdelrahman, Biologist II >>Miami-Dade County, Department of Regulatory and Economic Resources >>Division of Environmental Resources Management (DERM) Overtown Transit > >>Village >>701 NW 1st Court, 5th Floor >>Miami, FL 33136-3912 >>(305) 372-6872 >>abdelo at miamidade.gov<mailto:abdelo at miamidade.gov> >>www.miamidade.gov/environment<http://www.miamidade.gov/environment/> >> >> >> [[alternative HTML version deleted]] >> >>______________________________________________ >>R-help at r-project.org 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.
Thanks again RE: "so all the more reason to give us an example that we can run to trigger the same error." Are you asking for an example of the data? Below is a "small" example, but with so many levels of the different variables I am not sure it can be useful. STATION Geo Wshed DATE PARAMETER RESULT BB36 Bay C-100 1/10/2013 Phosphorus, Total (TP) 0.004 BB36 Bay C-100 1/10/2013 Chlorophyll-A 0.2 BB52 Bay C-100 1/10/2013 Phosphorus, Total (TP) 0.003 BB52 Bay C-100 1/10/2013 Chlorophyll-A 0.39 CD01A Mouth C-100 1/10/2013 Phosphorus, Total (TP) 0.017 CD01A Mouth C-100 1/10/2013 Chlorophyll-A 0.64 CD02 East C-100 1/10/2013 Phosphorus, Total (TP) 0.01 CD05 Central C-100 1/10/2013 Phosphorus, Total (TP) 0.005 CD06 Central C-100 1/10/2013 Phosphorus, Total (TP) 0.01 CD09 Central C-100 1/10/2013 Phosphorus, Total (TP) 0.007 BB36 Bay C-100 2/7/2013 Chlorophyll-A 0.18 BB36 Bay C-100 2/7/2013 Phosphorus, Total (TP) 0.002 BB52 Bay C-100 2/7/2013 Phosphorus, Total (TP) 0.002 BB52 Bay C-100 2/7/2013 Chlorophyll-A 0.31 CD01A Mouth C-100 2/7/2013 Phosphorus, Total (TP) 0.004 CD01A Mouth C-100 2/7/2013 Chlorophyll-A 0.4 CD02 East C-100 2/7/2013 Phosphorus, Total (TP) 0.011 CD05 Central C-100 2/7/2013 Phosphorus, Total (TP) 0.007 CD06 Central C-100 2/7/2013 Phosphorus, Total (TP) 0.015 CD09 Central C-100 2/7/2013 Phosphorus, Total (TP) 0.008 CD01A Mouth C-100 3/7/2013 Phosphorus, Total (TP) 0.007 Hope this is not too much -----Original Message----- From: Jeff Newmiller [mailto:jdnewmil at dcn.davis.ca.us] Sent: Tuesday, May 16, 2017 12:30 PM To: Abdelrahman, Omar (RER) <Omar.Abdelrahman at miamidade.gov>; R-help <r-help at r-project.org> Subject: RE: [R] violin plot help Please use reply-all or equivalent to keep the list in the conversation. I don't do private online consultation. Your example suggested you did not know the difference, but your error suggests a completely different expression triggered the error, so all the more reason to give us an example that we can run to trigger the same error. Items B and C are recommendations to read the help pages for those syntax elements. You should already have read enough of an introduction to R to have encountered the use of the question mark to bring up the help pages. If not, please do. -- Sent from my phone. Please excuse my brevity. On May 16, 2017 9:00:09 AM PDT, "Abdelrahman, Omar (RER)" <Omar.Abdelrahman at miamidade.gov> wrote:>Thanks Jeff. I will send plain text from now on. I am not sure what B >or C mean; is there a guide that I can reference? I know the difference >between "=" and "==" , they work the same in Stata and SAS. > >Omar >-----Original Message----- >From: Jeff Newmiller [mailto:jdnewmil at dcn.davis.ca.us] >Sent: Tuesday, May 16, 2017 11:43 AM >To: r-help at r-project.org; Abdelrahman, Omar (RER) ><Omar.Abdelrahman at miamidade.gov>; 'r-help at r-project.org' ><r-help at r-project.org> >Subject: Re: [R] violin plot help > >Read >A) the Posting Guide (re plain text only... your emails may be damaged >by the mailing list if you send html-formatted email... only you can >solve this by figuring out how to use your email software) >B) Help on assignment (?`=`) >C) Help on logical tests (?`==`) >-- >Sent from my phone. Please excuse my brevity. > >On May 16, 2017 7:06:40 AM PDT, "Abdelrahman, Omar (RER)" ><Omar.Abdelrahman at miamidade.gov> wrote: >>I am trying to produce multiple violin plots by 3 categorical >>variables, each violin representing 1 year worth of data. The >variables >>are: >> >>Watershed (7 levels: county canals) >> >>Geography (5 levels: west; central; east; mouth; bay) >> >>Parameter (8 levels: water quality chemical parameters) >> >>Year (25 levels: 1992-2017) >> >>I want to produce 1 plot for each Parameter-Watershed subdivided into >>Geography with a violin for each year. I used facets with the >following >>code (not by year): >> >>ggplot () + >> >>facet_grid (PARAMETER ~Wshed, scales="free_y") + >> >>geom_violin (data=merged, aes(x=Geo, y=RESULT)) >> >> >> >>I do not want facets, they crowd the information so it is unreadable. >I >>just started with R this week and have not been able to figure out the > >>foreach protocol, or any other loop protocol. I tried to subset the >>data to do it iteratively with the following code: >> >> >> >>subdf<-subset (merged, Wshed = "AC") >> >> >> >>but got an error: Error: unexpected input in "subdf=subset (merged, >>Wshed == "" >> >>Any help would be greatly appreciated. >> >>Thanks, >> >>Omar Abdelrahman, Biologist II >>Miami-Dade County, Department of Regulatory and Economic Resources >>Division of Environmental Resources Management (DERM) Overtown Transit > >>Village >>701 NW 1st Court, 5th Floor >>Miami, FL 33136-3912 >>(305) 372-6872 >>abdelo at miamidade.gov<mailto:abdelo at miamidade.gov> >>www.miamidade.gov/environment<http://www.miamidade.gov/environment/> >> >> >> [[alternative HTML version deleted]] >> >>______________________________________________ >>R-help at r-project.org 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.
> On 16 May 2017, at 17:06, Abdelrahman, Omar (RER) <Omar.Abdelrahman at miamidade.gov> wrote: > > I am trying to produce multiple violin plots by 3 categorical variables, each violin representing 1 year worth of data. The variables are: > > Watershed (7 levels: county canals) > > Geography (5 levels: west; central; east; mouth; bay) > > Parameter (8 levels: water quality chemical parameters) > > Year (25 levels: 1992-2017) > > I want to produce 1 plot for each Parameter-Watershed subdivided into Geography with a violin for each year. I used facets with the following code (not by year):Hello Omer, If you want violin plots for different categories, I would suggest lattice solution. For start; https://www.r-bloggers.com/violin-and-boxplots-with-lattice-and-r/ Search terms: lattice, bwplot, panel.violin will help you find more examples.> > ggplot () + > > facet_grid (PARAMETER ~Wshed, scales="free_y") + > > geom_violin (data=merged, aes(x=Geo, y=RESULT)) > > > > I do not want facets, they crowd the information so it is unreadable. I just started with R this week and have not been able to figure out the foreach protocol, or any other loop protocol. I tried to subset the data to do it iteratively with the following code: > > > > subdf<-subset (merged, Wshed = "AC") > > > > but got an error: Error: unexpected input in "subdf=subset (merged, Wshed == "" > > Any help would be greatly appreciated. > > Thanks, > > Omar Abdelrahman, Biologist II > Miami-Dade County, Department of Regulatory and Economic Resources > Division of Environmental Resources Management (DERM) > Overtown Transit Village > 701 NW 1st Court, 5th Floor > Miami, FL 33136-3912 > (305) 372-6872 > abdelo at miamidade.gov<mailto:abdelo at miamidade.gov> > www.miamidade.gov/environment<http://www.miamidade.gov/environment/> >