I suspect that this is simple, but thanks in advance for any advice...

I have a dataframe, t2:

V1          V2
aaa         3
aaaa       4
aaaaaa    6
a            1
aa          2


V2 is the length of the string in V1 using  nchar(as.character(t1$V1))

I'd like to create a third column, that contains a string of the length of
V2, but containing an alternate text, e.g.

V1          V2     V3
aaa         3      bbb
aaaa       4      bbbb
aaaaaa    6     bbbbbb
a            1     b
aa          2      bb

or

V1          V2    V3
aaa         3     bad
aaaa       4     badb
aaaaaa    6     badbad
a            1     b
aa          2     ba  


Suggestions would be much appreciated!

Thanks.


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Create-new-string-of-same-length-as-entry-in-dataframe-tp3058232p3058232.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to