Re: [R] Ggplot2 Line Problem
Hello, Sorry, I forgot you also want the line type changed. Remove color and linetype from the initial call to ggplot and include aes(color = cases, linetype = cases) in geom_line. Then add a layer scale_linetype_manual with the same name and labels to merge it with the color legend. dfO %>% pivot_longer( cols = -date, names_to = "cases", values_to = "count" ) %>% mutate(cases = factor(cases, levels = c("positive", "negative", "total"))) %>% ggplot(aes(date, count)) + #geom_point() + geom_line(aes(color = cases, linetype = cases)) + scale_color_manual(name = "Test", labels = c("Positive", "Negative", "Total"), values = c("red", "blue", "green")) + scale_linetype_manual(name = "Test", labels = c("Positive", "Negative", "Total"), values = c("solid", "dotdash", "twodash")) + ylim(0, 175) + labs(x = "Date", y = "Number of Tests")+ ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+ theme_bw() + theme(axis.text.x = element_text(angle = 30, hjust = 1), plot.title = element_text(hjust = 0.5)) Hope this helps, Rui Barradas Às 06:49 de 17/08/20, Rui Barradas escreveu: Hello, This type of problem is almost always a data reshaping problem. ggplot graphics work better if the data is in the long format and you have 3 columns for counts, one column for each category. If you reformat from the current wide format to the long format you will have a date vector, a categorical variable and a counts variable. In the code below just change geom_point to geom_line and the problem is solved. library(tidyverse) library(lubridate) datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;) datO[ ,1] <- ymd(datO[ ,1]) dfO <- tibble::as_tibble(data.frame(date = datO[ ,"date"], positive = datO[ ,"positive"], negative = datO[ ,"negative"], total = datO[ ,"total"])) dfO %>% pivot_longer( cols = -date, names_to = "cases", values_to = "count" ) %>% mutate(cases = factor(cases, levels = c("positive", "negative", "total"))) %>% ggplot(aes(date, count, color = cases)) + geom_point() + scale_color_manual(name = "Test", labels = c("Positive", "Negative", "Total"), values = c("red", "blue", "green")) + ylim(0, 175) + labs(x = "Date", y = "Number of Tests")+ ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+ theme_bw() + theme(axis.text.x = element_text(angle = 30, hjust = 1), plot.title = element_text(hjust = 0.5)) Hope this helps, Rui Barradas Às 02:00 de 17/08/20, Stephen P. Molnar escreveu: I have cobbled together a short script to plot Covid-19 data. setwd("~/Apps/Models/1-CoronaVirus") library(tidyverse) library(lubridate) datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;) datO[ ,1] <- ymd(datO[ ,1]) dfO <- tibble::as_tibble(data.frame(datO[ ,"date"],datO[ ,"positive"],datO[ ,"negative"],datO[ ,"total"])) dfO %>% ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+ geom_point(color = 'red', size = 0.025)+ geom_point(y = datO[ ,"negative"], color = 'blue', size = 0.025)+ geom_point(y = datO[ ,"total"], color = "green", size = 0.025)+ theme(axis.text.x = element_text(angle=30, hjust=1))+ theme_bw()+ scale_y_continuous(limits = c(0,175))+ labs(x = "Date", y = "Number of Tests")+ ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+ theme(plot.title = element_text(hjust = 0.5))+ scale_fill_discrete(name = "Test", labels = c("Positive", "Negative", "Total")) Here is the plot: but, if I want lines rather that the code (the aspplicable plines) uis: ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+ geom_line(linetype = "solid",color = 'red')+ geom_line(linetype = "dotdash",y = datO[ ,"negative"], color = 'blue')+ geom_line(linetype = "twodash",y = datO[ ,"total"], color = "green")+ Now two of the plots are reversed. Google has not been a friend in finding a solution. Help will be much appreciated. Thanks in advance __ R-help@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. __ R-help@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.
Re: [R] Ggplot2 Line Problem
Hello, This type of problem is almost always a data reshaping problem. ggplot graphics work better if the data is in the long format and you have 3 columns for counts, one column for each category. If you reformat from the current wide format to the long format you will have a date vector, a categorical variable and a counts variable. In the code below just change geom_point to geom_line and the problem is solved. library(tidyverse) library(lubridate) datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;) datO[ ,1] <- ymd(datO[ ,1]) dfO <- tibble::as_tibble(data.frame(date = datO[ ,"date"], positive = datO[ ,"positive"], negative = datO[ ,"negative"], total = datO[ ,"total"])) dfO %>% pivot_longer( cols = -date, names_to = "cases", values_to = "count" ) %>% mutate(cases = factor(cases, levels = c("positive", "negative", "total"))) %>% ggplot(aes(date, count, color = cases)) + geom_point() + scale_color_manual(name = "Test", labels = c("Positive", "Negative", "Total"), values = c("red", "blue", "green")) + ylim(0, 175) + labs(x = "Date", y = "Number of Tests")+ ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+ theme_bw() + theme(axis.text.x = element_text(angle = 30, hjust = 1), plot.title = element_text(hjust = 0.5)) Hope this helps, Rui Barradas Às 02:00 de 17/08/20, Stephen P. Molnar escreveu: I have cobbled together a short script to plot Covid-19 data. setwd("~/Apps/Models/1-CoronaVirus") library(tidyverse) library(lubridate) datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;) datO[ ,1] <- ymd(datO[ ,1]) dfO <- tibble::as_tibble(data.frame(datO[ ,"date"],datO[ ,"positive"],datO[ ,"negative"],datO[ ,"total"])) dfO %>% ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+ geom_point(color = 'red', size = 0.025)+ geom_point(y = datO[ ,"negative"], color = 'blue', size = 0.025)+ geom_point(y = datO[ ,"total"], color = "green", size = 0.025)+ theme(axis.text.x = element_text(angle=30, hjust=1))+ theme_bw()+ scale_y_continuous(limits = c(0,175))+ labs(x = "Date", y = "Number of Tests")+ ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+ theme(plot.title = element_text(hjust = 0.5))+ scale_fill_discrete(name = "Test", labels = c("Positive", "Negative", "Total")) Here is the plot: but, if I want lines rather that the code (the aspplicable plines) uis: ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+ geom_line(linetype = "solid",color = 'red')+ geom_line(linetype = "dotdash",y = datO[ ,"negative"], color = 'blue')+ geom_line(linetype = "twodash",y = datO[ ,"total"], color = "green")+ Now two of the plots are reversed. Google has not been a friend in finding a solution. Help will be much appreciated. Thanks in advance __ R-help@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.
Re: [R] Best settings for RStudio video recording?
In my experience pixel count is only indirectly related to legibility on a small screen, since they may have very high pixel count yet still be poorly readable with "normal" programming font sizes. If you really want to support that then increase font size. Slide presentations have similar design principles. If you really want the multi-pane experience then I would advocate for not assuming the phones will be usable, but you can try the medium font everywhere approach and hope for the best. On August 16, 2020 5:02:03 PM PDT, Boris Steipe wrote: >I totally agree with Roy, thank you. > >I hope that we can get the discussion back on OP's question (which is >timely and very important, and actually not specific to the IDE). > >The problem is that our possibilities to test user experience are >usually limited. AFAIK students could be participating via their mobile >phone... I want to be able to type code, have them read along, open >help-pages, discuss the help pages, and plot things. > >Zoom appears to send out 720p video. That is 1280 x 720 px. If I set my >monitor from which I screen-share my R session to 1280px wide, does >this mean I will be doing the best I can to reduce anti-aliasing >artefacts and improve legibility? Or does it even matter? > > >Cheers, >Boris > > > > > >> On 2020-08-17, at 09:47, Roy Mendelssohn - NOAA Federal via R-help > wrote: >> >> May I suggest that this discussion is best left for another time and >place. Some people have very strong opinions about RStudio vis a vis >R, it has been discussed here before, shedding mostly heat and not a >lot of light (nor do I think anyone had their mind changed), and >worse the discussions have tended to move over to twitter, where >twitter mobs have gone after people whose views on this subject didn't >agree with theirs, to the extent of digging up any transgression that >person ever committed and claiming that discredited anything they said >about R and RStudio, rather than dealing with points made.I have >seen people who I have reason to believe are well-meaning, decent >people trying to improve R, be tarred and feathered on this subject >(and this is on both sides of the discussion), I can't believe that >this helps improve R, nor does it help anyone use R, which is the >main point of this mail-list. >> >> Thanks, >> >> -Roy >> >> PS - Or we can start a discussion on the best editor to use - that >should be good for a few flames! :-) >> >>> On Aug 16, 2020, at 3:39 PM, Abby Spurdle >wrote: >>> a) Read about it yourself. It is a legal definition. >>> >>> Not quite. >>> Your statement implies some sort of universalism, which is >unrealistic. >>> Legal definitions vary from one legal system to the next. >>> >>> I'm not an expert in US company/corporate law. >>> But as I understand it, the applicable laws vary from state to >state. >>> >>> It's unlikely that you or most readers will interpret the original >>> statement in a strict legal sense. >>> But rather, the term is used to imply something. >>> >>> If the criteria is: >>> Sacrificing prophets (not just theirs, but their *holding/sibling >>> companies too*), for some public benefit(s)... >>> >>> ...then I would like to see evidence of this. >>> b) Don't "correct" me with misinformation you are clearly >inventing. RStudio the software does not "introduce people to a >modified version of R." >>> >>> Read this post: >>> https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html >>> >>> My information is accurate, and RStudio does modify R, unless of >>> course something has changed... >>> >>> __ >>> R-help@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. >> >> ** >> "The contents of this message do not reflect any position of the U.S. >Government or NOAA." >> ** >> Roy Mendelssohn >> Supervisory Operations Research Analyst >> NOAA/NMFS >> Environmental Research Division >> Southwest Fisheries Science Center >> ***Note new street address*** >> 110 McAllister Way >> Santa Cruz, CA 95060 >> Phone: (831)-420-3666 >> Fax: (831) 420-3980 >> e-mail: roy.mendelss...@noaa.gov www: https://www.pfeg.noaa.gov/ >> >> "Old age and treachery will overcome youth and skill." >> "From those who have been given much, much will be expected" >> "the arc of the moral universe is long, but it bends toward justice" >-MLK Jr. >> >> __ >> R-help@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. >
[R] Ggplot2 Line Problem
I have cobbled together a short script to plot Covid-19 data. setwd("~/Apps/Models/1-CoronaVirus") library(tidyverse) library(lubridate) datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;) datO[ ,1] <- ymd(datO[ ,1]) dfO <- tibble::as_tibble(data.frame(datO[ ,"date"],datO[ ,"positive"],datO[ ,"negative"],datO[ ,"total"])) dfO %>% ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+ geom_point(color = 'red', size = 0.025)+ geom_point(y = datO[ ,"negative"], color = 'blue', size = 0.025)+ geom_point(y = datO[ ,"total"], color = "green", size = 0.025)+ theme(axis.text.x = element_text(angle=30, hjust=1))+ theme_bw()+ scale_y_continuous(limits = c(0,175))+ labs(x = "Date", y = "Number of Tests")+ ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+ theme(plot.title = element_text(hjust = 0.5))+ scale_fill_discrete(name = "Test", labels = c("Positive", "Negative", "Total")) Here is the plot: but, if I want lines rather that the code (the aspplicable plines) uis: ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+ geom_line(linetype = "solid",color = 'red')+ geom_line(linetype = "dotdash",y = datO[ ,"negative"], color = 'blue')+ geom_line(linetype = "twodash",y = datO[ ,"total"], color = "green")+ Now two of the plots are reversed. Google has not been a friend in finding a solution. Help will be much appreciated. Thanks in advance -- Stephen P. Molnar, Ph.D. www.molecular-modeling.net 614.312.7528 (c) Skype: smolnar1 __ R-help@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.
Re: [R] Plot math symbol with string and number
On Sun, Aug 16, 2020 at 3:18 PM Bert wrote: | On Sun, Aug 16, 2020, 14:53 John wrote: | | | | I would like to make plots with | | titles for different data sets and | | different parameters. The first | | title doesn't show sigma as a math | | symbol, while the second one | | doesn't contain the s value as a | | numeric value | | | | s <- 1 | | y <- rnorm(100) | | plot(y, main=paste("data", "sigma=", s)) | | plot(y, main=expression(paste("data", sigma,"=", s))) | | ?plotmath Dear John, read ?plotmath, it is good, I was not aware of its existence; then backquote s like so: plot(y, main=bquote(paste( "data" ~~ widehat(aleph) %notin% .(s)^.(s V r __ R-help@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.
Re: [R] Plot math symbol with string and number
Specifically, see the "how to combine "math" and numeric variables" in the Examples therein. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sun, Aug 16, 2020 at 3:18 PM Bert Gunter wrote: > ?plotmath > > On Sun, Aug 16, 2020, 14:53 John Smith wrote: > >> Dear Helpers, >> >> I would like to make plots with titles for different data sets and >> different parameters. So a useful title should combine data name >> and parameter for clarity. The following is a simplified code example with >> two plots. The first title doesn't show sigma as a math symbol, while the >> second one doesn't contain the s value as a numeric value - I could >> manually change the s value, but when there are many different s values, >> this is not a good solution. Thanks! >> >> s <- 1 >> y <- rnorm(100) >> plot(y, main=paste("data", "sigma=", s)) >> plot(y, main=expression(paste("data", sigma,"=", s))) >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@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. >> > [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Best settings for RStudio video recording?
Completely agree with Roy M. and do not wish to express any opinion, but this typo was too precious to ignore: "If the criteria is: Sacrificing prophets (not just theirs, but their *holding/sibling companies too*), for some public benefit(s)..." Oh gosh, I hope no prophets are sacrificed ... though I can think of some financial and political pundits who may deserve that fate Still, let's keep it to chickens or the occasional goat... (with apologies to any vegans out there).** Bert Gunter ** and yes feel free to beat me up for this! ** On Sun, Aug 16, 2020 at 3:40 PM Abby Spurdle wrote: > > a) Read about it yourself. It is a legal definition. > > Not quite. > Your statement implies some sort of universalism, which is unrealistic. > Legal definitions vary from one legal system to the next. > > I'm not an expert in US company/corporate law. > But as I understand it, the applicable laws vary from state to state. > > It's unlikely that you or most readers will interpret the original > statement in a strict legal sense. > But rather, the term is used to imply something. > > If the criteria is: > Sacrificing prophets (not just theirs, but their *holding/sibling > companies too*), for some public benefit(s)... > > ...then I would like to see evidence of this. > > > b) Don't "correct" me with misinformation you are clearly inventing. > RStudio the software does not "introduce people to a modified version of R." > > Read this post: > https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html > > My information is accurate, and RStudio does modify R, unless of > course something has changed... > > __ > R-help@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. > [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Best settings for RStudio video recording?
I totally agree with Roy, thank you. I hope that we can get the discussion back on OP's question (which is timely and very important, and actually not specific to the IDE). The problem is that our possibilities to test user experience are usually limited. AFAIK students could be participating via their mobile phone... I want to be able to type code, have them read along, open help-pages, discuss the help pages, and plot things. Zoom appears to send out 720p video. That is 1280 x 720 px. If I set my monitor from which I screen-share my R session to 1280px wide, does this mean I will be doing the best I can to reduce anti-aliasing artefacts and improve legibility? Or does it even matter? Cheers, Boris > On 2020-08-17, at 09:47, Roy Mendelssohn - NOAA Federal via R-help > wrote: > > May I suggest that this discussion is best left for another time and place. > Some people have very strong opinions about RStudio vis a vis R, it has been > discussed here before, shedding mostly heat and not a lot of light (nor do I > think anyone had their mind changed), and worse the discussions have tended > to move over to twitter, where twitter mobs have gone after people whose > views on this subject didn't agree with theirs, to the extent of digging up > any transgression that person ever committed and claiming that discredited > anything they said about R and RStudio, rather than dealing with points made. >I have seen people who I have reason to believe are well-meaning, decent > people trying to improve R, be tarred and feathered on this subject (and > this is on both sides of the discussion), I can't believe that this helps > improve R, nor does it help anyone use R, which is the main point of this > mail-list. > > Thanks, > > -Roy > > PS - Or we can start a discussion on the best editor to use - that should be > good for a few flames! :-) > >> On Aug 16, 2020, at 3:39 PM, Abby Spurdle wrote: >> >>> a) Read about it yourself. It is a legal definition. >> >> Not quite. >> Your statement implies some sort of universalism, which is unrealistic. >> Legal definitions vary from one legal system to the next. >> >> I'm not an expert in US company/corporate law. >> But as I understand it, the applicable laws vary from state to state. >> >> It's unlikely that you or most readers will interpret the original >> statement in a strict legal sense. >> But rather, the term is used to imply something. >> >> If the criteria is: >> Sacrificing prophets (not just theirs, but their *holding/sibling >> companies too*), for some public benefit(s)... >> >> ...then I would like to see evidence of this. >> >>> b) Don't "correct" me with misinformation you are clearly inventing. >>> RStudio the software does not "introduce people to a modified version of R." >> >> Read this post: >> https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html >> >> My information is accurate, and RStudio does modify R, unless of >> course something has changed... >> >> __ >> R-help@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. > > ** > "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > ** > Roy Mendelssohn > Supervisory Operations Research Analyst > NOAA/NMFS > Environmental Research Division > Southwest Fisheries Science Center > ***Note new street address*** > 110 McAllister Way > Santa Cruz, CA 95060 > Phone: (831)-420-3666 > Fax: (831) 420-3980 > e-mail: roy.mendelss...@noaa.gov www: https://www.pfeg.noaa.gov/ > > "Old age and treachery will overcome youth and skill." > "From those who have been given much, much will be expected" > "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. > > __ > R-help@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. __ R-help@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.
Re: [R] Best settings for RStudio video recording?
May I suggest that this discussion is best left for another time and place. Some people have very strong opinions about RStudio vis a vis R, it has been discussed here before, shedding mostly heat and not a lot of light (nor do I think anyone had their mind changed), and worse the discussions have tended to move over to twitter, where twitter mobs have gone after people whose views on this subject didn't agree with theirs, to the extent of digging up any transgression that person ever committed and claiming that discredited anything they said about R and RStudio, rather than dealing with points made. I have seen people who I have reason to believe are well-meaning, decent people trying to improve R, be tarred and feathered on this subject (and this is on both sides of the discussion), I can't believe that this helps improve R, nor does it help anyone use R, which is the main point of this mail-list. Thanks, -Roy PS - Or we can start a discussion on the best editor to use - that should be good for a few flames! :-) > On Aug 16, 2020, at 3:39 PM, Abby Spurdle wrote: > >> a) Read about it yourself. It is a legal definition. > > Not quite. > Your statement implies some sort of universalism, which is unrealistic. > Legal definitions vary from one legal system to the next. > > I'm not an expert in US company/corporate law. > But as I understand it, the applicable laws vary from state to state. > > It's unlikely that you or most readers will interpret the original > statement in a strict legal sense. > But rather, the term is used to imply something. > > If the criteria is: > Sacrificing prophets (not just theirs, but their *holding/sibling > companies too*), for some public benefit(s)... > > ...then I would like to see evidence of this. > >> b) Don't "correct" me with misinformation you are clearly inventing. RStudio >> the software does not "introduce people to a modified version of R." > > Read this post: > https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html > > My information is accurate, and RStudio does modify R, unless of > course something has changed... > > __ > R-help@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. ** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: https://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. __ R-help@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.
Re: [R] Hot Air Balloon Weather Briefings
Hi Philip, My fault for assuming that what worked for the sample data would work for the entire data set. If you run the following code: # read the file into a data frame phdf<-read.csv("phdf.csv",stringsAsFactors=FALSE) print(dim(phdf)) # create a logical variable for the subsetting step keep<-rep(TRUE,length(phdf$Speed)) # this follows the conventional for(i in ...) syntax # mini (minute index) is the name of the variable # that is assigned the successive values of the # unique values in the Minute column of phdf # here I was lazy and only dealt with the sample data # what I should have done was to create a column # with minute values that don't repeat phdf$hourmin<-phdf$Hour.Z * 60 + phdf$Minute for(mini in unique(phdf$hourmin)) { # mark all minutes that are all zeros for deletion if(all(phdf$Speed[phdf$hourmin == mini] == 0)) keep[phdf$hourmin == mini]<-FALSE # but now there is another condition # that I didn't notice (more laziness) # drop minutes containing ten consecutive zeros # I'll use a cheap trick for this # if the length of the run length encoding (rle) # of the Speed == 0 condition is less than three, # then there can't be a broken run of zeros if(length(rle(phdf$Speed[phdf$hourmin == mini])$length)<3) keep[phdf$hourmin == mini]<-FALSE } # now drop any rows for which has marked FALSE (note all caps!) phdf<-phdf[keep,] print(dim(phdf)) You will see that it has removed 67 rows. This is the same as if I had only applied the first "all zeros" condition, for there were no unique minutes with 11 observations that contained a single non-zero speed value. I can see that you are getting short runs of zero speeds near the end. I assume that this is due to the balloon slowly bumping along the ground. Often just looking at the data can suggest solutions to problems like this. Coincidentally I am about to email an old friend of mine whose sons have dabbled in sending balloons high into the air and I will let them know that they are not alone in performing this unusual practice. If I haven't answered all your questions, feel free to let me know. Jim On Sun, Aug 16, 2020 at 4:39 AM Philip wrote: > > Thanks for getting back to me so quickly. > > I can get your code to run without errors but I'm not sure what it > accomplishes since I still get 813 rows of data and 11 variables. The > entire file for a January flight is attached. Also attached is a .jpg of a > flight from a couple of years ago where my wife putzed back and forth across > a road for over an hour by going up or down to catch different winds. Stuff > like this is one of the charms of the sport for those of us who are easily > amused. > > keep <- rep(TRUE,length(phdf$Speed)) #813 repetitions of TRUE > for(mini in unique(phdf$Minute)) > if(all(phdf$Speed[phdf$Minute==mini]==0)) > keep[phdf$Minute==mini]<-False #813 repetitions of > TRUE in the keep data file. > > #Don't understand the assignment (<-) to FALSE > phdf <- phdf[keep,] #Still have 813 rows of data. > > As you may know, we lay out the balloon and then blow cold air into the > envelope with a gas powered fan. When it is packed we "go hot". Just > before we turn on the pilot light and hit the burner we will turn on the > tracking software which results in several minutes of no movement at the > beginning of the flight. This is what is happening between rows 2 and 70 of > the attached spreadsheet. You will also notice that the balloon slowly > accelerates between rows 71 and 79 p to about 3.4 MPH just after liftoff. > The no movement is what I want to eliminate. > > Can you let me know what I am missing. > > Two more thing. I really not sure about the: > > for(mini in unique(phdf$Minute)) > > .line of code. I understand the unique function but not the "mini > in..." part. Is mini a function or just a label? I understand stuff like: > > for(i in 1:5) print(1:i) > > .from the R base documentation but not real sure how it fits in here. > > And finally, I'm retired, So I have plenty of time and determined to learn > R. But I keep running into things like the "mini in unique" command. I > have read four or five books and watched or read dozens of tutorials but > there always seems to be another layer that alludes me. Any suggestions? > > Philip __ R-help@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.
Re: [R] Best settings for RStudio video recording?
> a) Read about it yourself. It is a legal definition. Not quite. Your statement implies some sort of universalism, which is unrealistic. Legal definitions vary from one legal system to the next. I'm not an expert in US company/corporate law. But as I understand it, the applicable laws vary from state to state. It's unlikely that you or most readers will interpret the original statement in a strict legal sense. But rather, the term is used to imply something. If the criteria is: Sacrificing prophets (not just theirs, but their *holding/sibling companies too*), for some public benefit(s)... ...then I would like to see evidence of this. > b) Don't "correct" me with misinformation you are clearly inventing. RStudio > the software does not "introduce people to a modified version of R." Read this post: https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html My information is accurate, and RStudio does modify R, unless of course something has changed... __ R-help@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.
Re: [R] Plot math symbol with string and number
?plotmath On Sun, Aug 16, 2020, 14:53 John Smith wrote: > Dear Helpers, > > I would like to make plots with titles for different data sets and > different parameters. So a useful title should combine data name > and parameter for clarity. The following is a simplified code example with > two plots. The first title doesn't show sigma as a math symbol, while the > second one doesn't contain the s value as a numeric value - I could > manually change the s value, but when there are many different s values, > this is not a good solution. Thanks! > > s <- 1 > y <- rnorm(100) > plot(y, main=paste("data", "sigma=", s)) > plot(y, main=expression(paste("data", sigma,"=", s))) > > [[alternative HTML version deleted]] > > __ > R-help@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. > [[alternative HTML version deleted]] __ R-help@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.
[R] Plot math symbol with string and number
Dear Helpers, I would like to make plots with titles for different data sets and different parameters. So a useful title should combine data name and parameter for clarity. The following is a simplified code example with two plots. The first title doesn't show sigma as a math symbol, while the second one doesn't contain the s value as a numeric value - I could manually change the s value, but when there are many different s values, this is not a good solution. Thanks! s <- 1 y <- rnorm(100) plot(y, main=paste("data", "sigma=", s)) plot(y, main=expression(paste("data", sigma,"=", s))) [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Best settings for RStudio video recording?
On Sun 16 Aug 2020 at 06:32, Jeff Newmiller wrote: > a) Read about it yourself. It is a legal definition. > > b) Don't "correct" me with misinformation you are clearly inventing. > RStudio the software does not "introduce people to a modified version of > R." Each user has to opt in to that "modified" experience by explicitly > installing each of the the many CRAN packages that various employees of > RStudio have created and all of which can (to my knowledge) be used without > installing the RStudio IDE at all. Yes, a bunch of them can be grabbed at > once by installing the tidyverse package, but that is also a choice made by > users and by instructors struggling to deal with students who have a hard > time with Excel much less functional programming. But RStudio is an R IDE. > > There are a lot of packages sponsored by RStudio that I find redundant and > slow, but portraying the RStudio company or the IDE as inherently "not R" > just because newbies like the IDE and the packages they sponsor, and who > end up confusing R with RStudio even though they have to install both, is > small-minded and biased To clarify: If you use RStudio and do not install any of the RStudio packages, R in RStudio is the same R as if you were running it from the command line. I would think that many users find command completion, access to help files, project management Etc. useful. Nobody is asking anyone to install the RStudio packages. I do sometimes but not always and have found them useful. Jeff is 100% correct. > On August 15, 2020 9:10:34 PM PDT, Abby Spurdle > wrote: > >On Fri, Aug 14, 2020 at 12:11 PM Jeff Newmiller > > wrote: > >> It is a public benefit corporation > > > >Seriously? > > > >On Fri, Aug 14, 2020 at 12:11 PM Jeff Newmiller > > wrote: > >> used to introduce people to R > > > >Correction, it introduces people to a modified version of R. > > -- > Sent from my phone. Please excuse my brevity. > > __ > R-help@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. > -- John C Frain 3 Aranleigh Park Rathfarnham Dublin 14 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:fra...@tcd.ie mailto:fra...@gmail.com [[alternative HTML version deleted]] __ R-help@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.