[R] How to remove all characters after comma in R

2013-04-01 Thread Gundala Viswanath
I have the following list of strings: x - c(foo, foo2, foo3, bar, qux, qux1) what I want to do is to obtain foo, bar qux Namely for each element in the vector obtain only string before the first comma. What's the way to do it? - G.V. [[alternative HTML version deleted]]

Re: [R] How to remove all characters after comma in R

2013-04-01 Thread arun
gsub(\\,.*,,x) #[1] foo bar qux A.K. - Original Message - From: Gundala Viswanath gunda...@gmail.com To: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch Cc: Sent: Monday, April 1, 2013 10:13 PM Subject: [R] How to remove all characters after comma in R I have the following list

Re: [R] How to remove all characters after comma in R

2013-04-01 Thread Rolf Turner
On 04/02/2013 03:13 PM, Gundala Viswanath wrote: I have the following list of strings: x - c(foo, foo2, foo3, bar, qux, qux1) what I want to do is to obtain foo, bar qux Namely for each element in the vector obtain only string before the first comma. What's the way to do it? This seems to

Re: [R] How to remove all characters after comma in R

2013-04-01 Thread Peter Ehlers
, April 1, 2013 10:13 PM Subject: [R] How to remove all characters after comma in R I have the following list of strings: x - c(foo, foo2, foo3, bar, qux, qux1) what I want to do is to obtain foo, bar qux Namely for each element in the vector obtain only string before the first comma. What's the way