[Moving this thread to R-devel instead]

I suspect your "random" results are due to a bug in gsub(). On my R v1.9.0
(Rterm and Rgui) R crashes when I do

% R --vanilla
> gsub(" ", "", "abb + c | a*b", perl=TRUE)

Trying 

> gsub(" ", "", "b c + d | a * b", perl=TRUE)

and I'll get NULL. With 

> gsub("\\s", "", "bc + d | a * b", perl=TRUE)

it works as expected. So there is something buggy for sure.

This might have been fixed in R v1.9.1 or its patched version. (I'm still
busy to recover from a HDD crash, but, yes, I will update to Rv1.9.1. BTW,
what's the name of the error logger for Windows that is once in a while
recommended on this list and that gives more detailed errors than the
default Windows one?)

Cheers

Henrik

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of hadley wickham
> Sent: Friday, July 16, 2004 10:50 PM
> To: [EMAIL PROTECTED]
> Subject: [R] Strange (non-deterministic) problem with strsplit
> 
> 
> I'm having an odd problem with strsplit (well I think it's 
> strplit that's causing the problem).  When I run the code 
> below as follows:  str(parseFormulaMin(y +x +d ~ b +d +e| a * b))
> 
> I expect to get
> List of 3
>  $ y: chr "y+x+d"
>  $ x: chr "b+d+e"
>  $ g: chr "a*b"
> 
> But about half the time I get 
> 
> List of 3
>  $ y: chr "y+x+d"
>  $ x: chr "b+d+e"
>  $ g: chr "a*[square box]"
> (square box not reproduced here because copy and pasting it 
> seems to break my web mail)
> 
> Can anyone reproduce the problem and/or suggest any solutions? 
> 
> parseFormula <- function(formula) {
>       splitvars <- function(x) {
>               strsplit(x, "\\+|\\*")[[1]]
>       }
>       stripwhitespace <- function(x) {
>               gsub("\\s", "", x, perl=T)
>       }
>       
>       vars <- stripwhitespace(as.character(formula)[3])
>       varsplit <- strsplit(vars, "|", fixed=TRUE)[[1]]
> 
>       parts <- list(
>               y = stripwhitespace(as.character(formula)[2]),
>               x = varsplit[1],
>               g = varsplit[2]
>       )
>       lapply(parts, splitvars)
> } 
> 
> Thanks,
> 
> Hadley
> 
> ______________________________________________
> [EMAIL PROTECTED] mailing list 
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

Reply via email to