[R] How to replace all commas with semicolon in a string
jun.shen.ut at gmail.com
Fri May 27 17:21:22 CEST 2016
Thanks Ulrik and Bob for your reply.
gsub worked for one column!
If I want to replace the whole data frame, gsub doesn't seem to work. Any
On Fri, May 27, 2016 at 11:14 AM, Ulrik Stervbo <ulrik.stervbo at gmail.com>
> use gsub()
> On Fri, 27 May 2016 at 17:12 Jun Shen <jun.shen.ut at gmail.com> wrote:
>> Dear list,
>> Say I have a data frame
>> test <- data.frame(C1=c('a,b,c,d'),C2=c('g,h,f'))
>> I want to replace the commas with semicolons
>> sub(',',';',test$C1) -> test$C1 will only replace the first comma of a
>> How do I replace them all in one run? Thanks.
>> [[alternative HTML version deleted]]
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help