I have used paste and gsub before. I have a couple of years experience in R. However now I am not looking to simply merge strings into one. I need the strings to stay seperated and just divided by a comma:
one <- letters[1:9]
assigned.object <- somefunction(one,sep=",")
assigned.object
[1] "a","b","c","d","e","f","g","h","i"
Also searched the site and this thread and its duplicate don't answer my question. Could not find any other answers to this issue. Anybody knows a way in R?
ANSWER:
The duplicate answers the question. However if you need to assign an object to what you directly want this happens:
cat(paste("\"",as.character(one),"\"",collapse=", ",sep=""))
[1] "a","b","c","d","e","f","g","h","i"
assigned.object <- cat(paste("\"",as.character(one),"\"",collapse=", ",sep=""))
assigned.object
NULL
The reason is that there is somewhat an 'error in translation': R can print the object I want, but not store it like the this. The object I want needs to be stored like this:
assigned.object <- paste("\"",as.character(one),"\"",collapse=", ",sep="")
assigned.object
[1] "\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\""
which looks like this if you save it in a txt-file
"a","b","c","d","e","f","g","h","i"
Basically R needs to insert a '\' to distinguish between quotes in the character and those quotes which define beginning and ending in the character.