Hi, all, I've been converting code from S-Plus ("S" for short) to R for a few weeks. Here are some differences I've found, aside from the big well-known ones (scoping, models, data storage) and the contents of Kurt Hornik's FAQ section 3.3.3. Let me start with the ones that seem like serious bugs or deficiencies: 1) LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B"). This is TERRIBLE! I have a ton of S-Plus code that looks like: y$ticker <- z$ticker[match(y$cusip, z$cusip)] and I count on a ticker of "" to indicate failed lookups. Not only will I need to change all that code, but I'll never be able to trade Nabisco (ticker NA) again. PLEASE re-consider this choice, or at least make it an option: option(na.char=""). 2) system() has no "input" argument in R. Here's a (Unix) example: S> system("cd mydir; latex myfile", input="x") which goes to the directory where myfile lives and LaTeX's it, passing an "x" through STDIN in case LaTeX encounters an error. My R fix is: R> system("cd mydir; echo x | latex myfile") Note that it's not as simple as cmd <- paste("echo",input,"|",cmd). 3) R> myfun <- function(x, ...) {x[...] <- 0; x} R> myfun(3) Error in myfun(3) : SubAssignArgs: invalid number of arguments It failed because no ... was given. Fortunately, this is easily patched: R> myfun <- function(x, ...) {if (missing(...)) x[]<-0 else x[...]<-0; x} 4) Missing functions: a) identical() [scheduled for 1.4.0] b) slice.index() c) rowSums(), colSums(), colVars(), etc. d) unpaste() - R has strsplit, whose result is like the transpose of unpaste 5) rowsum() gives character dimnames in S, factor numbers in R. I've reported this early, and Brian D. Ripley promised a fix in 1.4.0. OK, the rest are just differences, not complaints. In fact, sometimes they are very good differences. 1) Same argument given twice produces an error in R; S takes the last one. S> mean(x=4, x=5) # Returns 5 R> mean(x=4, x=5) # Error 2) row.names(y) <- LETTERS[1:3] coerces list to dataframe in S, is error in R. 3) Default "what" for scan in S is "", in R is double(0). 4) Default "quote" for scan is "'\"" in R, causes different behavior than S. 5) which(<numeric>) converts to logical in S, is an error in R. 6) The NULL returned by if(F){...} is invisible in R, visible in S. 7) The NULL returned by return() is visible in R, invisible in S. 8) Args to "var" differ, and R has "cov". S na.method="a" is like R use="p". 9) var (or cov) drops dimensions in S, not R. 10) cut allows labels=F in R, not in S (also left.include=T becomes right=F). 11) substring(s,"x") <- "X" only works in S, but R has s <- gsub("x","X",s). 12) S function casefold() replaced in R by toupper() or tolower(). 13) Functions missing from S: sub(), gsub(), chartr(), toupper(), tolower() 14) Log scale indicated in S with par(xaxt)=="l", in R with par("xlog")==T. -- David Brahm (a215020 at agate.fmr.com) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
David Brahm <a215020 at agate.fmr.com> writes:> Hi, all, > > I've been converting code from S-Plus ("S" for short) to R for a few weeks. > Here are some differences I've found, aside from the big well-known ones > (scoping, models, data storage) and the contents of Kurt Hornik's FAQ section > 3.3.3. Let me start with the ones that seem like serious bugs or deficiencies: > > 1) LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B")....> 14) Log scale indicated in S with par(xaxt)=="l", in R with par("xlog")==T.*Sigh* PLEASE do not post several bugs in one report (hint: look at the filing system on bugs.r-project.org) PLEASE discern between actual bugs and points for discussion and design issues PLEASE do not mail to multiple addresses. All bug reports are echoed to the r-devel list and should be discussed there. This will ensure that the discussion, including possible patches and workarounds are filed in the bug repository. Worse, careless followups to posts on r-devel or r-help with a Cc: field including "r-bugs" will cause the creation of *new* bug reports since they lack the crucial (PR#nnnn) part. Sorry if I sound annoyed, but I am.... -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote:> Sorry if I sound annoyed, but I am....Grossly unfair, Peter! And since you chose to vent your annoyance publicly, I am responding publicly. I spent several hours trying to build a coherent, single-page summary of my observations over several weeks, and my reward is a scolding for sending my email to the address given in the FAQ??? Jeez! Just delete it if it offends so much!> PLEASE do not post several bugs in one report ... > PLEASE discern between actual bugs and points for discussion...Not mentioned in the FAQ (section 9.2), nor anywhere else on CRAN that I can find. It sounds like r-bugs is some kind of automated system that cannot handle non-standard formatting, is that it? I assumed it was just read by a human (the "bugs guy"), parsed, and handed out appropriately, sorry.> PLEASE do not mail to multiple addresses. All bug reports are echoed > to the r-devel list and should be discussed there.Then I don't understand how to communicate with the "development team", besides just posting to the general discussion list. Is every posting there really read and handled by the right people? I guess I fundamentally don't understand your communication model, e.g. how my comment about subsetting (which isn't strictly a "bug") gets to the guy who actually writes "[".> Sorry if I sound annoyed, but I am....Likewise. R-help sure is filled with a lot of negativity. -- David Brahm (a215020 at agate.fmr.com) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Also in assign() there some arguments lacking in R such as 'frame' and 'where', though I guess that 'frame' in S may be similar to 'pos' in R. Harvey -----Original Message----- From: David Brahm [SMTP:a215020 at agate.fmr.com] Sent: Wednesday, October 03, 2001 11:36 AM To: r-help at stat.math.ethz.ch Cc: Kurt.Hornik at ci.tuwien.ac.at; r-bugs at r-project.org Subject: [R] Several R vs S-Plus issues Hi, all, I've been converting code from S-Plus ("S" for short) to R for a few weeks. Here are some differences I've found, aside from the big well-known ones (scoping, models, data storage) and the contents of Kurt Hornik's FAQ section 3.3.3. Let me start with the ones that seem like serious bugs or deficiencies: 1) LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B"). This is TERRIBLE! I have a ton of S-Plus code that looks like: y$ticker <- z$ticker[match(y$cusip, z$cusip)] and I count on a ticker of "" to indicate failed lookups. Not only will I need to change all that code, but I'll never be able to trade Nabisco (ticker NA) again. PLEASE re-consider this choice, or at least make it an option: option(na.char=""). 2) system() has no "input" argument in R. Here's a (Unix) example: S> system("cd mydir; latex myfile", input="x") which goes to the directory where myfile lives and LaTeX's it, passing an "x" through STDIN in case LaTeX encounters an error. My R fix is: R> system("cd mydir; echo x | latex myfile") Note that it's not as simple as cmd <- paste("echo",input,"|",cmd). 3) R> myfun <- function(x, ...) {x[...] <- 0; x} R> myfun(3) Error in myfun(3) : SubAssignArgs: invalid number of arguments It failed because no ... was given. Fortunately, this is easily patched: R> myfun <- function(x, ...) {if (missing(...)) x[]<-0 else x[...]<-0; x} 4) Missing functions: a) identical() [scheduled for 1.4.0] b) slice.index() c) rowSums(), colSums(), colVars(), etc. d) unpaste() - R has strsplit, whose result is like the transpose of unpaste 5) rowsum() gives character dimnames in S, factor numbers in R. I've reported this early, and Brian D. Ripley promised a fix in 1.4.0. OK, the rest are just differences, not complaints. In fact, sometimes they are very good differences. 1) Same argument given twice produces an error in R; S takes the last one. S> mean(x=4, x=5) # Returns 5 R> mean(x=4, x=5) # Error 2) row.names(y) <- LETTERS[1:3] coerces list to dataframe in S, is error in R. 3) Default "what" for scan in S is "", in R is double(0). 4) Default "quote" for scan is "'\"" in R, causes different behavior than S. 5) which(<numeric>) converts to logical in S, is an error in R. 6) The NULL returned by if(F){...} is invisible in R, visible in S. 7) The NULL returned by return() is visible in R, invisible in S. 8) Args to "var" differ, and R has "cov". S na.method="a" is like R use="p". 9) var (or cov) drops dimensions in S, not R. 10) cut allows labels=F in R, not in S (also left.include=T becomes right=F). 11) substring(s,"x") <- "X" only works in S, but R has s <- gsub("x","X",s). 12) S function casefold() replaced in R by toupper() or tolower(). 13) Functions missing from S: sub(), gsub(), chartr(), toupper(), tolower() 14) Log scale indicated in S with par(xaxt)=="l", in R with par("xlog")==T. -- David Brahm (a215020 at agate.fmr.com) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Marc Feldesman (feldesmanm at pdx.edu) wrote:> David, if S-Plus works for you, why are you bothering to convert all your > code to R?Group decision. I have the most old S code of the group, so I have the most issues with incompatibility. If I can't get it to work, we either revert to S-Plus, or bifurcate into the "S people" and the "R people".> R is open source. If you want to change something, you are free to change > it and you are free to contribute your changes to the community.Really? You think nobody in the community would complain if I went in and changed the behavior of "[" for character vectors? I don't really understand the OSS model, but I doubt that. I think I am a "user", not a "developer". Thomas Lumley (tlumley at u.washington.edu) wrote:> deep breaths and count to 10...OK, so here's what I think I've learned. Feedback please if I've still got it wrong. 1) Do not Cc: to r-bugs!!! 2) Bugs go individually to r-bugs. Here is the only one I think qualifies: - myfun <- function(x, ...) {x[...] <- 0; x} fails if no ... given 3) Feature and compatibility requests go to r-devel, to which I am just now subscribed. Separate messages, I suppose. These would be: - LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B") - system() has no "input" argument in R - No slice.index() - No rowSums(), colSums(), colVars(), etc. - No unpaste() 4) Issues already addressed (rowsum, identical) don't need to go anywhere. 5) Other differences are just FYI, and don't need to go anywhere. Philippe Grosjean (phgrosje at ulb.ac.be) suggested I make a project of collecting all such differences, but frankly that's too big a job for me. I am, after all, supposed to be working! I have the greatest respect for Peter and all the others who work so hard at this project. I'm obviously having some trouble understanding the communication model, but I'll get it eventually. Peace. -- David Brahm (a215020 at agate.fmr.com) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I wrote:> R-help sure is filled with a lot of negativity.Well, I went to document this, and found I was confusing r-help in my mind with some other mailing lists, including s-news. I take it back. -- David Brahm (a215020 at agate.fmr.com) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> David Brahm writes:> ...> OK, so here's what I think I've learned. Feedback please if I've > still got it wrong.> 1) Do not Cc: to r-bugs!!!> 2) Bugs go individually to r-bugs. Here is the only one I think qualifies: > - myfun <- function(x, ...) {x[...] <- 0; x} fails if no ... given> 3) Feature and compatibility requests go to r-devel, to which I am just now > subscribed. Separate messages, I suppose. These would be: > - LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B")I think we do not want to change this. Splus has> (1:2)[c(NA,2)][1] NA 2> is.na((1:2)[c(NA,2)])[1] T F> is.na(c(TRUE, FALSE)[c(NA,2)])[1] T F etc, so I think the logic would be that we get NA whenever we subscript by NA. The current Splus behavior for character vectors is different, and I do not see why it should. Note that in R, R> is.na(LETTERS[c(NA,2)]) [1] TRUE FALSE so we really have NA but it is printed as "NA" (and this might be another case where <NA> would be better).> - system() has no "input" argument in R > - No slice.index() > - No rowSums(), colSums(), colVars(), etc.Doug Bates had raised this issue some time ago. In the interest of keeping the S language core as small as possible, I'd rather recommend against adding these. We can basically do that same using apply(), and if the point is to have fast C code I think we should rather special-case apply accordingly.> - No unpaste()This is a function from the chron package, and it is also available in the R version of chron. Again, I am not sure whether this should be in the S language core: we have strsplit. -k -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> > R is open source. If you want to change something, you are > free to change > > it and you are free to contribute your changes to the community. > > Really? You think nobody in the community would complain if > I went in and > changed the behavior of "[" for character vectors? I don't > really understand > the OSS model, but I doubt that. I think I am a "user", not > a "developer".IMHO, for an OSS project, the line between "user" and "developer" tend to be very fuzzy. Many contributions to the code came from people who *are* users. They added features or fixed bugs because they want/need to for themselves, and feel it might be useful for others. No one can/will stop you from modifying the behavior of "[" for character vectors in R for your own use. Whether your modification will be accepted by the R community at large is an entirely different matter.> 3) Feature and compatibility requests go to r-devel, to which > I am just now > subscribed. Separate messages, I suppose. These would be: > - LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B")My vote is for this to be called a bug. The S behavior is consistent. R isn't.> Philippe Grosjean (phgrosje at ulb.ac.be) suggested I make a > project of > collecting all such differences, but frankly that's too > big a job for me. > I am, after all, supposed to be working!And what do you think all those who put their time and effort into writing/fixing/maintaining R are doing? AFAIK not a single one of them gets a penny for the work they put into R.> I have the greatest respect for Peter and all the others who > work so hard at > this project. I'm obviously having some trouble understanding the > communication model, but I'll get it eventually. Peace. > > -- David Brahm (a215020 at agate.fmr.com)Just my $0.02... Andy Andy I. Liaw, PhD Biometrics Research Phone: (732) 594-0820 Merck & Co., Inc. Fax: (732) 594-1565 P.O. Box 2000, RY70-38 Rahway, NJ 07065 mailto:andy_liaw at merck.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I wrote, re: collecting R/S differences,> frankly that's too big a job for me. I am, after all, supposed to be working!Andy I. Liaw <andy_liaw at merck.com> wrote:> And what do you think all those who put their time and effort into > writing/fixing/maintaining R are doing?They are better people than me, I admit it! I just don't want to promise something I can't deliver. Me> LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B") Andy> My vote is for this to be called a bug. I have moved my further comments on this to R-devel. -- David Brahm (brahm at alum.mit.edu) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._