Re: [R] Auto Data in the ISLR Package
I did not care to load the packages -- small reproducible examples are preferable, as the posting guide suggests. But, if I have understood correctly: See, e.g. ?subset Alternatively, you can read up on indexing data frames in any good basic R tutorial. Cheers, Bert 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 Sat, Dec 16, 2017 at 11:44 AM, AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: > Dear All: > > I would like to create a subset data set *with only* all Ford and all > Toyota cars from the Auto data set in ISLR R Package. Thank you very much > in advance. > > Please use the following code to see how is the data look like. > > > install.packages("ISLR") > library(ISLR) > data(Auto) > head(Auto) > > > with many thanks > abou > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor of Statistics* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > [[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] Auto Data in the ISLR Package
Dear All: I would like to create a subset data set *with only* all Ford and all Toyota cars from the Auto data set in ISLR R Package. Thank you very much in advance. Please use the following code to see how is the data look like. install.packages("ISLR") library(ISLR) data(Auto) head(Auto) with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[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: [ESS] Problems with lintr in Emacs
Hi Renger: Check the value of inferior-R-program-name to see if your setting is actually happening. Rodney -Original Message- From: Renger van NieuwkoopDate: Saturday, December 16, 2017 at 11:36 AM To: Rodney Sparapani Subject: Re: [ESS] Problems with lintr in Emacs Hi Rodney That is the funny thing: I have this exact line in my .emacs. Renger __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [R] Generating help files for a function
On Sat, 16 Dec 2017, Erin Hodgess writes: > Hello everyone! > > I'm in the process of writing a package, and I'm using the lovely "R > Package" book as a guideline. > > However, in the midst of my work, I discovered that I had omitted a > function and am now putting in it the package. Not a problem. But the > problem is the help file. What is the best way to generate a help file > "after the fact" like that, please? > > Thank you in advance. Hope everyone is enjoying various holidays. > > Sincerely, > Erin see ?prompt -- Enrico Schumann Lucerne, Switzerland http://enricoschumann.net __ 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] Generating help files for a function
On 16/12/2017 10:15 AM, Berwin A Turlach wrote: G'day Erin, On Sat, 16 Dec 2017 08:00:38 -0600 Erin Hodgesswrote: I'm in the process of writing a package, and I'm using the lovely "R Package" book as a guideline. However, in the midst of my work, I discovered that I had omitted a function and am now putting in it the package. Not a problem. But the problem is the help file. What is the best way to generate a help file "after the fact" like that, please? It depends on how you decided to write the documentation. If you follow the "R Package" guidelines and use roxygen2, just add the comments for the documentation at the beginning of the file and follow the procedure outline in "R Packages" book. If you are writing the documentation separate, more like the "Writing R Extensions" manual, then (1) start R, (2) source the file in which the function is so that is is in your workspace, (3) say "prompt(foo)" if the function's name is foo and (4) copy the resulting foo.Rd into the /man directory of your package. I'm in the latter camp, but my workflow is slightly different from Berwin's: After writing a new function and putting it into the package: 1. install the package, and attach it (using library() or require()). 2. use setwd() to change to the man directory. 3. use prompt() to create the skeleton help page. After that, you edit that new .Rd file, and build the package again. The first two steps are particularly easy in RStudio: for 1, just click "Install and restart" in the build pane, and for 2, navigate in the file pane to the man directory, and choose "Set as working directory" from the "More" tab. Duncan Murdoch __ 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] Generating help files for a function
G'day Erin, On Sat, 16 Dec 2017 08:00:38 -0600 Erin Hodgesswrote: > I'm in the process of writing a package, and I'm using the lovely "R > Package" book as a guideline. > > However, in the midst of my work, I discovered that I had omitted a > function and am now putting in it the package. Not a problem. But > the problem is the help file. What is the best way to generate a > help file "after the fact" like that, please? It depends on how you decided to write the documentation. If you follow the "R Package" guidelines and use roxygen2, just add the comments for the documentation at the beginning of the file and follow the procedure outline in "R Packages" book. If you are writing the documentation separate, more like the "Writing R Extensions" manual, then (1) start R, (2) source the file in which the function is so that is is in your workspace, (3) say "prompt(foo)" if the function's name is foo and (4) copy the resulting foo.Rd into the /man directory of your package. Cheers, Berwin __ 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] Finding center of mass in a hydrologic time series
Slightly faster: sum(cumsum(hyd) <= .5 * sum(hyd)) Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkel...@inbo.be Kliniekstraat 25, B-1070 Brussel www.inbo.be /// To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey /// Van 14 tot en met 19 december 2017 verhuizen we uit onze vestiging in Brussel naar het Herman Teirlinckgebouw op de site Thurn & Taxis. Vanaf dan ben je welkom op het nieuwe adres: Havenlaan 88 bus 73, 1000 Brussel. /// 2017-12-16 14:32 GMT+01:00 Eric Berger: > Hi Eric, > How about > > match( TRUE, cumsum(hyd/sum(hyd)) > .5 ) - 1 > > HTH, > Eric > > > On Sat, Dec 16, 2017 at 3:18 PM, Morway, Eric wrote: > >> The small bit of script below is an example of what I'm attempting to do - >> find the day on which the 'center of mass' occurs. In case that is the >> wrong term, I'd like to know the day that essentially cuts the area under >> the curve in to two equal parts: >> >> set.seed(4004) >> Date <- seq(as.Date('2000-09-01'), as.Date('2000-09-30'), by='day') >> hyd <- ((100*(sin(seq(0.5,4.5,length.out=30))+10) + >> seq(45,1,length.out=30)) + rnorm(30)*8) - 800 >> >> # View the example curve >> plot(Date, hyd, las=1) >> >> # By trial-and-error, the day on which the center of mass occurs is the >> 11th day: >> # Add up the area under the curve for the first 11 days and compare >> # with the last 19 days: >> >> sum(hyd[1:11]) >> # 3546.364 >> sum(hyd[12:30]) >> # 3947.553 >> >> # Add up the area under the curve for the first 12 days and compare >> # with the last 18 days: >> >> sum(hyd[1:12]) >> # 3875.753 >> sum(hyd[13:30]) >> # 3618.164 >> >> By day 12, the halfway point has already been passed, so the answer that >> would be returned would be: >> >> Date[11] >> # "2000-09-11" >> >> For the larger problem, it'd be handy if the proposed function could >> process a multi-year time series (a runoff hydrograph) and return the day >> of the center of mass for each year in the time series. >> >> I appreciate any pointers...Eric >> >> [[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-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-es] Estimada comunidad, queria pedirles ayuda porque realmente llevo muchas horas tratando de hacer algo que debe ser simple, y por eso mismo ya me esta frustrando ...
Hola. Lo que tienes que hacer es calcular el numero total de muertes por año primero y luego este resultado adjuntarlo a tu data.table de causas de muerte. NO te salen los resultados porque al momento que haces todo en solo grupo de operaciones y aplicas un FILTRO esto afecta en los totales. dt <- data.table(readxl::read_xlsx("d:/cdm.xlsx","dat")) dt año cdm muertes 1: 2015 A 4 2: 2015 B 3 3: 2015 D 1 4: 2015 F 8 5: 2016 A 9 6: 2016 B 5 7: 2016 C 3 8: 2017 C 4 9: 2017 B 1 10: 2017 G 2 11: 2017 A 7 dt[,.(total=sum(muertes)),by=año][dt[,.(muertes_s=sum(muertes)),by=.(año,cdm)],on=.(año)][,.(año,cdm,pct=muertes_s/total)] saludos [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[ESS] Problems with lintr in Emacs
Hi Renger: Not sure what would cause that. But, you should be able to fix this by placing the following in ~/.emacs (setq-default inferior-R-program-name "C:/Program Files/R/R-3.4.3/bin/x64/Rterm.exe”) Happy Holidays! Rodney and the ESS elves __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [R] Generating help files for a function
... and please note for the future and in case Ben's reply does not suffice that such queries should generally go to the r-package-devel mailing list. Cheers, Bert 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 Sat, Dec 16, 2017 at 6:36 AM, Ben Tupperwrote: > Hi, > > If you are using roxygen-style function documentation then why not use > devtools::document()? > > Ben > > > > > On Dec 16, 2017, at 9:00 AM, Erin Hodgess > wrote: > > > > Hello everyone! > > > > I'm in the process of writing a package, and I'm using the lovely "R > > Package" book as a guideline. > > > > However, in the midst of my work, I discovered that I had omitted a > > function and am now putting in it the package. Not a problem. But the > > problem is the help file. What is the best way to generate a help file > > "after the fact" like that, please? > > > > Thank you in advance. Hope everyone is enjoying various holidays. > > > > Sincerely, > > Erin > > > > > > -- > > Erin Hodgess > > Associate Professor > > Department of Mathematical and Statistics > > University of Houston - Downtown > > mailto: erinm.hodg...@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. > > Ben Tupper > Bigelow Laboratory for Ocean Sciences > 60 Bigelow Drive, P.O. Box 380 > East Boothbay, Maine 04544 > http://www.bigelow.org > > Ecocast Reports: http://seascapemodeling.org/ecocast.html > Tick Reports: https://report.bigelow.org/tick/ > Jellyfish Reports: https://jellyfish.bigelow.org/jellyfish/ > > > > > [[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] Generating help files for a function
Hi, If you are using roxygen-style function documentation then why not use devtools::document()? Ben > On Dec 16, 2017, at 9:00 AM, Erin Hodgesswrote: > > Hello everyone! > > I'm in the process of writing a package, and I'm using the lovely "R > Package" book as a guideline. > > However, in the midst of my work, I discovered that I had omitted a > function and am now putting in it the package. Not a problem. But the > problem is the help file. What is the best way to generate a help file > "after the fact" like that, please? > > Thank you in advance. Hope everyone is enjoying various holidays. > > Sincerely, > Erin > > > -- > Erin Hodgess > Associate Professor > Department of Mathematical and Statistics > University of Houston - Downtown > mailto: erinm.hodg...@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. Ben Tupper Bigelow Laboratory for Ocean Sciences 60 Bigelow Drive, P.O. Box 380 East Boothbay, Maine 04544 http://www.bigelow.org Ecocast Reports: http://seascapemodeling.org/ecocast.html Tick Reports: https://report.bigelow.org/tick/ Jellyfish Reports: https://jellyfish.bigelow.org/jellyfish/ [[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] Generating help files for a function
Hello everyone! I'm in the process of writing a package, and I'm using the lovely "R Package" book as a guideline. However, in the midst of my work, I discovered that I had omitted a function and am now putting in it the package. Not a problem. But the problem is the help file. What is the best way to generate a help file "after the fact" like that, please? Thank you in advance. Hope everyone is enjoying various holidays. Sincerely, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@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.
Re: [R] Finding center of mass in a hydrologic time series
Hi Eric, How about match( TRUE, cumsum(hyd/sum(hyd)) > .5 ) - 1 HTH, Eric On Sat, Dec 16, 2017 at 3:18 PM, Morway, Ericwrote: > The small bit of script below is an example of what I'm attempting to do - > find the day on which the 'center of mass' occurs. In case that is the > wrong term, I'd like to know the day that essentially cuts the area under > the curve in to two equal parts: > > set.seed(4004) > Date <- seq(as.Date('2000-09-01'), as.Date('2000-09-30'), by='day') > hyd <- ((100*(sin(seq(0.5,4.5,length.out=30))+10) + > seq(45,1,length.out=30)) + rnorm(30)*8) - 800 > > # View the example curve > plot(Date, hyd, las=1) > > # By trial-and-error, the day on which the center of mass occurs is the > 11th day: > # Add up the area under the curve for the first 11 days and compare > # with the last 19 days: > > sum(hyd[1:11]) > # 3546.364 > sum(hyd[12:30]) > # 3947.553 > > # Add up the area under the curve for the first 12 days and compare > # with the last 18 days: > > sum(hyd[1:12]) > # 3875.753 > sum(hyd[13:30]) > # 3618.164 > > By day 12, the halfway point has already been passed, so the answer that > would be returned would be: > > Date[11] > # "2000-09-11" > > For the larger problem, it'd be handy if the proposed function could > process a multi-year time series (a runoff hydrograph) and return the day > of the center of mass for each year in the time series. > > I appreciate any pointers...Eric > > [[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] Finding center of mass in a hydrologic time series
The small bit of script below is an example of what I'm attempting to do - find the day on which the 'center of mass' occurs. In case that is the wrong term, I'd like to know the day that essentially cuts the area under the curve in to two equal parts: set.seed(4004) Date <- seq(as.Date('2000-09-01'), as.Date('2000-09-30'), by='day') hyd <- ((100*(sin(seq(0.5,4.5,length.out=30))+10) + seq(45,1,length.out=30)) + rnorm(30)*8) - 800 # View the example curve plot(Date, hyd, las=1) # By trial-and-error, the day on which the center of mass occurs is the 11th day: # Add up the area under the curve for the first 11 days and compare # with the last 19 days: sum(hyd[1:11]) # 3546.364 sum(hyd[12:30]) # 3947.553 # Add up the area under the curve for the first 12 days and compare # with the last 18 days: sum(hyd[1:12]) # 3875.753 sum(hyd[13:30]) # 3618.164 By day 12, the halfway point has already been passed, so the answer that would be returned would be: Date[11] # "2000-09-11" For the larger problem, it'd be handy if the proposed function could process a multi-year time series (a runoff hydrograph) and return the day of the center of mass for each year in the time series. I appreciate any pointers...Eric [[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.