Marvin Kiene
2019-Jul-01 09:41 UTC
[R] sd in aggregate and help.search/?? seem not to work as usual in latest version
Hello dear helpers, I am currently running a small R-crash course for beginners at my university, since I believe that there a far too few lectures about how to use R. Thereby, I showed the '??' or 'help.search()' function to the students as well as the 'aggregate()' function with 'FUN=sd'. The code worked fine for me - as usual (in version 3.5.1) - but not for the students. Doing some research got me to the point, that in the current version (3.6.0), 'aggregate' cannot use 'sd' for data.frames with mixed columns of factors and numeric columns and throws an error (which is somewhat ok, since 'var()' is not applicable for factors, of course) instead of putting 'NA's into the respective columns like it does with 'FUN=mean' and like it does in the former version(s). Is this a bug or a feature? It would be nice to work with it, the way I am used to. Of course it is not difficult to work around this problem, but it is somewhat strange, why it was changed that way (if this was intended). Additionally, the 'help.search()' always just gives the result: "No results found", for all of my students. I didn't find any post about that issues so far, so I am not sure whether this are known issues (but all of my 10 students had this problem). If this were intended changes, I would be interested, what the reason is and whether there are direct workarounds (e.g. instead of using only numeric columns), for those issues. Otherwise I am looking forward to a fixed version. Thanks in advance for your help! Kind regards, Marvin Kiene Doctoral Student Department of Animal Ecology I, AG Prof. Laforsch University of Bayreuth 95440 Bayreuth Germany [[alternative HTML version deleted]]
Jim Lemon
2019-Jul-01 21:59 UTC
[R] sd in aggregate and help.search/?? seem not to work as usual in latest version
Hi Marvin, One way to get around the problem with "sd" is to only process those columns of a data frame for which the variance is defined. It is an opportunity to show students how to write wrapper functions as well: sd_num<-function(x) return(ifelse(is.numeric(x),sd(x),NA)) df<-data.frame(group=rep(0:1,each=5),value=1:10,name=LETTERS[1:10]) aggregate(df[,2:3],by=df[1],FUN="sd_num") Jim On Tue, Jul 2, 2019 at 3:47 AM Marvin Kiene <maki at maki-science.org> wrote:> > Hello dear helpers, > > I am currently running a small R-crash course for beginners at my > university, since I believe that there a far too few lectures about how to > use R. > > Thereby, I showed the '??' or 'help.search()' function to the students as > well as the 'aggregate()' function with 'FUN=sd'. > > > > The code worked fine for me - as usual (in version 3.5.1) - but not for the > students. Doing some research got me to the point, that in the current > version (3.6.0), > > 'aggregate' cannot use 'sd' for data.frames with mixed columns of factors > and numeric columns and throws an error (which is somewhat ok, since 'var()' > is not applicable for factors, of course) instead of putting 'NA's into the > respective columns like it does with 'FUN=mean' and like it does in the > former version(s). > > Is this a bug or a feature? It would be nice to work with it, the way I am > used to. Of course it is not difficult to work around this problem, but it > is somewhat strange, why it was changed that way (if this was intended). > > > > Additionally, the 'help.search()' always just gives the result: "No results > found", for all of my students. > > > > I didn't find any post about that issues so far, so I am not sure whether > this are known issues (but all of my 10 students had this problem). > > > > If this were intended changes, I would be interested, what the reason is and > whether there are direct workarounds (e.g. instead of using only numeric > columns), for those issues. > > Otherwise I am looking forward to a fixed version. > > > > Thanks in advance for your help! > > > > Kind regards, > > Marvin Kiene > > > > Doctoral Student > > Department of Animal Ecology I, AG Prof. Laforsch > > University of Bayreuth > > 95440 Bayreuth > > Germany > > > > > [[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.
Rolf Turner
2019-Jul-01 22:00 UTC
[R] [FORGED] sd in aggregate and help.search/?? seem not to work as usual in latest version
On 1/07/19 9:41 PM, Marvin Kiene wrote:> Hello dear helpers, > > I am currently running a small R-crash course for beginners at my > university, since I believe that there a far too few lectures about how to > use R. > > Thereby, I showed the '??' or 'help.search()' function to the students as > well as the 'aggregate()' function with 'FUN=sd'. > > > > The code worked fine for me - as usual (in version 3.5.1) - but not for the > students. Doing some research got me to the point, that in the current > version (3.6.0), > > 'aggregate' cannot use 'sd' for data.frames with mixed columns of factors > and numeric columns and throws an error (which is somewhat ok, since 'var()' > is not applicable for factors, of course) instead of putting 'NA's into the > respective columns like it does with 'FUN=mean' and like it does in the > former version(s). > > Is this a bug or a feature? It would be nice to work with it, the way I am > used to. Of course it is not difficult to work around this problem, but it > is somewhat strange, why it was changed that way (if this was intended). > > > > Additionally, the 'help.search()' always just gives the result: "No results > found", for all of my students. > > > > I didn't find any post about that issues so far, so I am not sure whether > this are known issues (but all of my 10 students had this problem). > > > > If this were intended changes, I would be interested, what the reason is and > whether there are direct workarounds (e.g. instead of using only numeric > columns), for those issues. > > Otherwise I am looking forward to a fixed version. > > > > Thanks in advance for your help!Can't offer much help, especially in respect of the first issue involving aggregate(). (But it sounds to me more like a bug than a feature.) I would just like to point out that when I do help.search() (with no argument) I get:> Error in help.search() : do not know what to searchThis seems reasonable, apart from being ungrammatical. If I do, e.g., help.search("ellipse") I get a brazillion results. This is with version 3.6.0. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276
Duncan Murdoch
2019-Jul-02 00:28 UTC
[R] sd in aggregate and help.search/?? seem not to work as usual in latest version
On 01/07/2019 5:41 a.m., Marvin Kiene wrote:> Additionally, the 'help.search()' always just gives the result: "No results > found", for all of my students.Those students are probably using RStudio. This appears to be an incompatibility in the RStudio browser to a nearly unannounced (as far as I can see) change in the help system. You can read about the change in the comments around line 700 of https://svn.r-project.org/R/trunk/src/library/utils/R/help.search.R Perhaps if anyone from RStudio is reading this, they can read those comments and fix things in their front end. To work around it, students can set options(browser="/path/to/their/browser") where that path will depend on what system they're using. On MacOS, options(browser="/usr/bin/open") works. On Windows, options(browser=NULL) works. I don't know the R default on Linux. This will cause lots of things to appear in an external browser instead of in the RStudio display, so it's not the nicest workaround, but at least it's fairly easy. Duncan Murdoch
Duncan Murdoch
2019-Jul-02 00:38 UTC
[R] sd in aggregate and help.search/?? seem not to work as usual in latest version
On 01/07/2019 8:28 p.m., Duncan Murdoch wrote:> On 01/07/2019 5:41 a.m., Marvin Kiene wrote: > >> Additionally, the 'help.search()' always just gives the result: "No results >> found", for all of my students. > > Those students are probably using RStudio. This appears to be an > incompatibility in the RStudio browser to a nearly unannounced (as far > as I can see) change in the help system. You can read about the change > in the comments around line 700 of > > https://svn.r-project.org/R/trunk/src/library/utils/R/help.search.R > > Perhaps if anyone from RStudio is reading this, they can read those > comments and fix things in their front end. > > To work around it, students can set > > options(browser="/path/to/their/browser") > > where that path will depend on what system they're using. On MacOS, > options(browser="/usr/bin/open") works. On Windows, > options(browser=NULL) works. I don't know the R default on Linux. > > This will cause lots of things to appear in an external browser instead > of in the RStudio display, so it's not the nicest workaround, but at > least it's fairly easy.I just saw here: https://github.com/rstudio/rstudio/issues/4819 that the issue is known and fixed in RStudio, but still only in a preview release available here: https://www.rstudio.com/products/rstudio/download/preview/ Duncan Murdoch