[R] Substitutions in strings.

Fredrik Karlsson fredrik.karlsson at ling.umu.se
Mon Jul 1 15:42:39 CEST 2002

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:

> token
[1] sal   skal  skal  bak   b_r   d_    gal   kal   l_r   n_r   pak
[13] sal   sl_r  sn_r  spak  sp_r  st_r  s_    bak   d_    gal   l_r
[25] p_r   sak   sl_r  sp_r  t_    kal   n_r   s_    st_r  sak   kal
[37] s_    spik  t_    n_r   spik  spak  gal   pak   p_r   sak   sl_r
[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.

[1] "A"   "AaA"

However, this does not..

Error in gsub(pattern, replacement, x, ignore.case, extended) : 
	invalid argument

Can't see why. Please help me out..


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

More information about the R-help mailing list