Re: [Rd] Typo in NEWS: -as-cran should be --as-cran
On Feb 29, 2012, at 03:13 , Henrik Bengtsson wrote: > Under 'CHANGES IN R VERSION 2.14.2' in NEWS, there is: > > "R CMD check has a new option -as-cran to turn on most of the > customizations that CRAN uses for its incoming checks." > > "-as-cran" should be "--as-cran". Where do you see that? The sources have \item \command{R CMD check} has a new option \option{--as-cran} to turn on most of the customizations that CRAN uses for its incoming checks. but there has been issues with LaTeX converting "--" to en-dash. (We saw it with the style files used for The R Journal, but that is hardly the case this time.) > > /Henrik > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] missing value break my if clause and crash my program
I have a program which is designed to read through a dbf file and carry out certain amount of further calculation if one condition obtained from the newly read line. The condition to determine if the calculation can be done is a if-clasue (i.e. if(m>0). Unfortunately, when m is missing, the program crashed. Just wonder who can help me out. Thanks [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Typo in NEWS: -as-cran should be --as-cran
On Wed, Feb 29, 2012 at 2:21 AM, peter dalgaard wrote: > > On Feb 29, 2012, at 03:13 , Henrik Bengtsson wrote: > >> Under 'CHANGES IN R VERSION 2.14.2' in NEWS, there is: >> >> "R CMD check has a new option -as-cran to turn on most of the >> customizations that CRAN uses for its incoming checks." >> >> "-as-cran" should be "--as-cran". > > Where do you see that? http://cran.r-project.org/bin/windows/base/NEWS.R-2.14.2rc.html http://cran.r-project.org/bin/windows/base/NEWS.R-devel.html and with R version 2.14.2 RC (2012-02-26 r58511): > tail(head(news(), n=7), n=1) Changes in version 2.14.2: UTILITIES o R CMD check has a new option -as-cran to turn on most of the customizations that CRAN uses for its incoming checks. BTW, with R Under development (unstable) (2012-02-29 r58531) [on Win7] news() gives: > news() Error: invalid version specification 'CHANGES IN R-devel' /Henrik PS. Thxs you all for the new release. > > The sources have > > \item \command{R CMD check} has a new option \option{--as-cran} to > turn on most of the customizations that CRAN uses for its incoming > checks. > > but there has been issues with LaTeX converting "--" to en-dash. (We saw it > with the style files used for The R Journal, but that is hardly the case this > time.) > >> >> /Henrik >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > -- > Peter Dalgaard, Professor > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Email: pd@cbs.dk Priv: pda...@gmail.com > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Replace back slashes with forward slashes?
Hello, All: What can people tell me about converting back slashes to forward slashes in character strings? Several years ago, Prof. Ripley provided a solution, which I lost and have not been able to find. Below please find a function to do this. I do not find this very satisfactory, however, because it uses "scan" and therefore operates on an input not a character string. Unless someone suggests something better, I plan to add this to the "sos" package and issue a new release very soon. (The new release is needed, because the RSiteSearch capability has been modified in a way that breaks the current "findFn" core of "sos".) Thanks, Spencer back2forwardslash <- function (nmax = 1, pattern = "\\", replacement = "/") { x <- scan(what = character(), quote = pattern, nmax = nmax) x. <- gsub(pattern, replacement, x, fixed = TRUE) paste(x., collapse = " ") } (x <- back2forwardslash()) c:\Users\ # nmax must be one more than the number of embedded blanks (x3 <- back2forwardslash(3)) c:\u\a b\c d -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Replace back slashes with forward slashes?
On Feb 29, 2012, at 12:37 PM, Spencer Graves wrote: > Hello, All: > > > What can people tell me about converting back slashes to forward slashes > in character strings? > > That's it's trivially done with gsub("\\", "/", x, fixed=TRUE) Where x is the character string (and I suppose you are aware of it since you are using it below). The rest of this e-mail makes absolutely no sense to me -- what exactly are you taking about? What else do you want to achieve? Cheers, Simon > Several years ago, Prof. Ripley provided a solution, which I lost and > have not been able to find. > > > Below please find a function to do this. I do not find this very > satisfactory, however, because it uses "scan" and therefore operates on an > input not a character string. Unless someone suggests something better, I > plan to add this to the "sos" package and issue a new release very soon. > (The new release is needed, because the RSiteSearch capability has been > modified in a way that breaks the current "findFn" core of "sos".) > > > Thanks, > Spencer > > back2forwardslash <- function (nmax = 1, pattern = "\\", replacement = "/") { >x <- scan(what = character(), quote = pattern, nmax = nmax) >x. <- gsub(pattern, replacement, x, fixed = TRUE) >paste(x., collapse = " ") > } > > (x <- back2forwardslash()) > c:\Users\ > > # nmax must be one more than the number of embedded blanks > (x3 <- back2forwardslash(3)) > c:\u\a b\c d > > > -- > Spencer Graves, PE, PhD > President and Chief Technology Officer > Structure Inspection and Monitoring, Inc. > 751 Emerson Ct. > San José, CA 95126 > ph: 408-655-4567 > web: www.structuremonitoring.com > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Replace back slashes with forward slashes?
Hi, Simon: On 2/29/2012 10:04 AM, Simon Urbanek wrote: On Feb 29, 2012, at 12:37 PM, Spencer Graves wrote: Hello, All: What can people tell me about converting back slashes to forward slashes in character strings? That's it's trivially done with gsub("\\", "/", x, fixed=TRUE) Where x is the character string (and I suppose you are aware of it since you are using it below). It does not work for me. Consider the following: > x <- 'c:\Users\' Error: '\U' used without hex digits in character string starting "c:\U" This is one reason I needed to use "scan". Even if I could get past this, consider the following: > x <- '\t' > gsub('\\', '/', x, fixed=TRUE) [1] "\t" It seems far from trivial, which is why I wrote this function and am looking for a better one. Thanks for the reply. Spencer The rest of this e-mail makes absolutely no sense to me -- what exactly are you taking about? What else do you want to achieve? Cheers, Simon Several years ago, Prof. Ripley provided a solution, which I lost and have not been able to find. Below please find a function to do this. I do not find this very satisfactory, however, because it uses "scan" and therefore operates on an input not a character string. Unless someone suggests something better, I plan to add this to the "sos" package and issue a new release very soon. (The new release is needed, because the RSiteSearch capability has been modified in a way that breaks the current "findFn" core of "sos".) Thanks, Spencer back2forwardslash<- function (nmax = 1, pattern = "\\", replacement = "/") { x<- scan(what = character(), quote = pattern, nmax = nmax) x.<- gsub(pattern, replacement, x, fixed = TRUE) paste(x., collapse = " ") } (x<- back2forwardslash()) c:\Users\ # nmax must be one more than the number of embedded blanks (x3<- back2forwardslash(3)) c:\u\a b\c d -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Replace back slashes with forward slashes?
On 29.02.2012 19:19, Spencer Graves wrote: Hi, Simon: On 2/29/2012 10:04 AM, Simon Urbanek wrote: On Feb 29, 2012, at 12:37 PM, Spencer Graves wrote: Hello, All: What can people tell me about converting back slashes to forward slashes in character strings? That's it's trivially done with gsub("\\", "/", x, fixed=TRUE) Where x is the character string (and I suppose you are aware of it since you are using it below). It does not work for me. Consider the following: > x <- 'c:\Users\' Error: '\U' used without hex digits in character string starting "c:\U" This is something your editor could do much better than R. Uwe This is one reason I needed to use "scan". Even if I could get past this, consider the following: > x <- '\t' > gsub('\\', '/', x, fixed=TRUE) [1] "\t" It seems far from trivial, which is why I wrote this function and am looking for a better one. Thanks for the reply. Spencer The rest of this e-mail makes absolutely no sense to me -- what exactly are you taking about? What else do you want to achieve? Cheers, Simon Several years ago, Prof. Ripley provided a solution, which I lost and have not been able to find. Below please find a function to do this. I do not find this very satisfactory, however, because it uses "scan" and therefore operates on an input not a character string. Unless someone suggests something better, I plan to add this to the "sos" package and issue a new release very soon. (The new release is needed, because the RSiteSearch capability has been modified in a way that breaks the current "findFn" core of "sos".) Thanks, Spencer back2forwardslash<- function (nmax = 1, pattern = "\\", replacement = "/") { x<- scan(what = character(), quote = pattern, nmax = nmax) x.<- gsub(pattern, replacement, x, fixed = TRUE) paste(x., collapse = " ") } (x<- back2forwardslash()) c:\Users\ # nmax must be one more than the number of embedded blanks (x3<- back2forwardslash(3)) c:\u\a b\c d -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Replace back slashes with forward slashes?
On Feb 29, 2012, at 1:19 PM, Spencer Graves wrote: > Hi, Simon: > > On 2/29/2012 10:04 AM, Simon Urbanek wrote: >> On Feb 29, 2012, at 12:37 PM, Spencer Graves wrote: >> >>> Hello, All: >>> >>> >>> What can people tell me about converting back slashes to forward >>> slashes in character strings? >>> >>> >> That's it's trivially done with >> >> gsub("\\", "/", x, fixed=TRUE) >> >> Where x is the character string (and I suppose you are aware of it since you >> are using it below). > > It does not work for me. Consider the following: > > > > x <- 'c:\Users\' > Error: '\U' used without hex digits in character string starting "c:\U" > But that has nothing to do with strings - it is an user error since you are not creating a valid string in R (not that backslash needs to be escaped in R -- just like in C and many other languages). You probably meant to write > x <- "c:\\users\\" > cat(x,"\n") c:\users\ > gsub("\\","/",x,fixed=TRUE) [1] "c:/users/" Cheers, Simon > > This is one reason I needed to use "scan". Even if I could get past > this, consider the following: > > > > x <- '\t' > > gsub('\\', '/', x, fixed=TRUE) > [1] "\t" > > > It seems far from trivial, which is why I wrote this function and am > looking for a better one. > > > Thanks for the reply. > > > Spencer >> >> The rest of this e-mail makes absolutely no sense to me -- what exactly are >> you taking about? What else do you want to achieve? >> >> Cheers, >> Simon >> >> >> >> >> >> >>> Several years ago, Prof. Ripley provided a solution, which I lost and >>> have not been able to find. >>> >>> >>> Below please find a function to do this. I do not find this very >>> satisfactory, however, because it uses "scan" and therefore operates on an >>> input not a character string. Unless someone suggests something better, I >>> plan to add this to the "sos" package and issue a new release very soon. >>> (The new release is needed, because the RSiteSearch capability has been >>> modified in a way that breaks the current "findFn" core of "sos".) >>> >>> >>> Thanks, >>> Spencer >>> >>> back2forwardslash<- function (nmax = 1, pattern = "\\", replacement = "/") { >>>x<- scan(what = character(), quote = pattern, nmax = nmax) >>>x.<- gsub(pattern, replacement, x, fixed = TRUE) >>>paste(x., collapse = " ") >>> } >>> >>> (x<- back2forwardslash()) >>> c:\Users\ >>> >>> # nmax must be one more than the number of embedded blanks >>> (x3<- back2forwardslash(3)) >>> c:\u\a b\c d >>> >>> >>> -- >>> Spencer Graves, PE, PhD >>> President and Chief Technology Officer >>> Structure Inspection and Monitoring, Inc. >>> 751 Emerson Ct. >>> San José, CA 95126 >>> ph: 408-655-4567 >>> web: www.structuremonitoring.com >>> >>> __ >>> R-devel@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >>> >>> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > > > -- > Spencer Graves, PE, PhD > President and Chief Technology Officer > Structure Inspection and Monitoring, Inc. > 751 Emerson Ct. > San José, CA 95126 > ph: 408-655-4567 > web: www.structuremonitoring.com > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Alternative to .Internal(.dfltStop(msg, call))?
Hi, I'm looking for a way to generate a "full stop" that will not be caught by signal handlers, cf. .Internal(.dfltStop(msg, call)). RATIONALE: In the R.oo package I have throw() which (leaving out some details) basically does what stop() does but appends a stack trace string to the error message that shows up at the R prompt. Example: bar <- function() throw("A foo error"); foo <- function() bar(); > foo() Error: A foo error at foo() at bar() versus bar <- function() stop("A foo error"); foo <- function() bar(); > stop("A foo error") Error: A foo error CURRENT SOLUTION: throw() does this in a way such that the stack trace is *not* part of the getMessage() of the 'error' condition object, which is important when catching the error in signal handlers. Here is a stub what is done, leaving out the details how to retrieve the stack trace (call history): throw <- function(msg, ...) { cond <- simpleError(msg); signalCondition(cond); # A dummy stracktrack / call history stackTraceStr <- "at foo()\nat bar()\n"; call <- NULL; # Also a dummy for this example # If the condition is not caught, do a "full stop" showing error message and stacktrace fullmsg <- paste(msg, "\n", stackTraceStr, sep=""); .Internal(.dfltStop(fullmsg, call)); } # throw() QUESTION: Is it possible to achieve this without using an .Internal() call? Note that stop() will use the same message string for both signalCondition() and .Internal(.dfltStop(...)), cf. > base::stop function (..., call. = TRUE, domain = NULL) { ... message <- conditionMessage(cond) call <- conditionCall(cond) .Internal(.signalCondition(cond, message, call)) .Internal(.dfltStop(message, call)) ... } ALTERNATIVE?: Is there an alternative way to have the stack trace/traceback() being automatically displayed after the error message being displayed at the prompt? /Henrik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel