Dear all,
it seems to be that 'recode' can't handle any line breaks in its
code.
The following command causes no problem:
datameta$smpid.r <-
recode(datameta$smpid,"c(101,25,167,45,75)=25;c(104,51)=51")
But if I type ...
datameta$smpid.r <-recode(datameta$smpid,
"c(101,25,167,45,75)=25;
c(104,51)=51")
... the result is a syntax error.
TIA
Bernd
--
Bernd Weiss, M.A.
Universitaet zu Koeln / University of Cologne
Forschungsinstitut fuer Soziologie / Research Institute for Sociology
Greinstr. 2 / 50 939 Cologne / Germany
Phone: +49 221 / 470-4234
E-Mail: <bernd.weiss at uni-koeln.de>
Nothing to do with recode: you cannot have line breaks inside quoted strings.> "c(101,25,167,45,75)=25;Error: syntax error> c(104,51)=51"Error: syntax error On Tue, 4 Nov 2003, Bernd Weiss wrote:> Dear all, > > it seems to be that 'recode' can't handle any line breaks in its code. > > The following command causes no problem: > > datameta$smpid.r <- > recode(datameta$smpid,"c(101,25,167,45,75)=25;c(104,51)=51") > > But if I type ... > > datameta$smpid.r <-recode(datameta$smpid, > "c(101,25,167,45,75)=25; > c(104,51)=51") > > ... the result is a syntax error. > > TIA > > Bernd >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Dear Bernd,
As Brian Ripley points out, the problem is that you can't break a quoted
string over input lines.
It is nevertheless awkward that you have to provide the recode directives
in one long line. I'll think about alternatives for the next version of the
car package. One simple possibility would be to allow several strings, so
that your example could be entered as
datameta$smpid.r <-recode(datameta$smpid,
"c(101,25,167,45,75)=25",
"c(104,51)=51")
It would also be nice to figure out a way to do this without using strings.
The recode dialog in my Rcmdr package, which assembles a call to recode(),
has a much nicer interface, but it's able to parse the input.
Thanks for the (implicit) suggestion.
John
At 11:52 AM 11/4/2003 +0100, Bernd Weiss wrote:>Dear all,
>
>it seems to be that 'recode' can't handle any line breaks in its
code.
>
>The following command causes no problem:
>
>datameta$smpid.r <-
>recode(datameta$smpid,"c(101,25,167,45,75)=25;c(104,51)=51")
>
>But if I type ...
>
>datameta$smpid.r <-recode(datameta$smpid,
> "c(101,25,167,45,75)=25;
> c(104,51)=51")
>
>... the result is a syntax error.
>
>TIA
>
>Bernd
>--
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox