Skip to content
Prev 180166 / 398506 Next

converting numeric into character strings

Hi,

Im trying to put some numbers into a dataframe , I have a list of numbers
(change points in a time series) like such

[1]  2 11 12 20 21 98 99

but I want R to recognise this as just a character string so it will put it
in one row and column, ideally I want them seperated by commas so I would
have for example

Person              Change points (seconds)
A                       2,11,12,20,21,98,99  
B                        4,5,89
 
etc. Is there any way I can get this

I've tried this:

for example if the command to get the list of numbers was b<-which(a!=s),
then i have tried

as.character(b) but I just end up with 

[1] "2"  "11" "12" "20" "21" "98" "99"

which is not what I want as this is more than one string and is not
seperated by commas, I also tried

paste(b,sep=",") but I end up with the same thing. Sorry it's a bit
confusing to read but any help would be great! 

Melissa