On Mon, 1 Jul 2002, Fredrik Karlsson wrote:
> Hi all,
>
> Sorry to bother you with the potentially not too bright question, but
> since I cannot get it to work, I'll have to ask someone..
>
> I've got this vector:
That's not a vector (or it would be printed with quotes). My guess is
that it is a factor, Try as.character(token).
>
> > token
> [1] sal skal skal bak b_r d_ gal kal l_r n_r pak
> p_r
> [13] sal sl_r sn_r spak sp_r st_r s_ bak d_ gal l_r
> pak
> [25] p_r sak sl_r sp_r t_ kal n_r s_ st_r sak kal
> spak
> [37] s_ spik t_ n_r spik spak gal pak p_r sak sl_r
> spak
> [49] s_ s_r t_ b_r s_r bak d_ l_r skal sp_r
> sl_r sal
> [61] st_r n_r bak b_r d_ l_r n_r pak p_r sal
> skal sl_r
> [73] sn_r spak sp_r st_r s_ s_r t_ bak d_ l_r
> pak p_r
> [85] sl_r sn_r spak spik s_r t_ gal kal gal n_r
> kal spik
> [97] n_r n_r bak b_r d_ gal l_r sak sal skal
> sl_r sn_r
> [109] spik sp_r st_r s_ s_r gal kal n_r sak kal
> pak p_r
> .
> .
> .
>
> What I whant to do is to substitute all the '_'s in the vector
whith
> some other character.
>
> Trying it out, this works.
>
> >gsub("_","A",c("_","_a_"))
> [1] "A" "AaA"
>
> However, this does not..
>
> >gsub("_","A",token)
> Error in gsub(pattern, replacement, x, ignore.case, extended) :
> invalid argument
>
> Can't see why. Please help me out..
>
> /Fredrik
>
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._