[R] Problem with recode -Error in parse(text = range[[1]][1]) : unexpected end of input in " c(0"

David Winsemius dwinsemius at comcast.net
Wed Apr 14 14:44:58 CEST 2010


On Apr 14, 2010, at 2:56 AM, Simon Kiss wrote:

> Dear colleagues,
> in the help archive there was a previous person who encountered a  
> problem with the "recode" command in the car library. I'm not sure  
> if that was solved, there was no posting to that effect, but I'm  
> having the same problem.
>
> I'm trying to recode a numeric variable with values from 0-100 into  
> a binary variable with values (0,1).
>
> The following command:
>
> recode(green_2004_2$french, "c(50:100)=0; c(0:49.99)=1")

Look at the last example in the recode help page:
recode(x, "1:2='A'; 3='B'")
## [1] "A" "A" "B" "A" "A" "B" "A" "A" "B"
It appears to me that the c() function around your sequences may be  
part of the problem and I further wondered whether 0:49.99 can  
succeed. Generally the ":" operator expects integer arguments, but the  
help page is not clear in this area and it appears that recode has a  
different interpretation.
 > require(car)
 > recode(x, "-Inf:0=-1; 0.000001:Inf=1") # succeeds
-- 
David

>
> gets the following error message
>
> Error in parse(text = range[[1]][1]) : unexpected end of input in "  
> c(0"
>
> I tried it with a second numerical variable in the same data set,  
> but get precisely the same error at precisely the same location in  
> the command, i.e. the second colon.
> As far as I can tell I have the most up-to-date version of car  
> installed.
> Any suggestions?
> Yours, Simon Kiss
>
> *********************************
> Simon J. Kiss, PhD
> SSHRC and DAAD Post-Doctoral Fellow
> John F. Kennedy Institute of North America Studies
> Free University of Berlin
> Lansstraße 7-9
> 14195 Berlin, Germany
> Cell: +49 (0)1525-300-2812,
> Web: http://www.jfki.fu-berlin.de/index.html
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.



More information about the R-help mailing list