Thursday, 15 December 2016
r - Concatenate a vector of strings/character
Answer
Answer
If I have a vector of type character, how can I concatenate the values into string? Here's how I would do it with paste():
sdata = c('a', 'b', 'c')
paste(sdata[1], sdata[2], sdata[3], sep ='')
yielding "abc"
.
But of course, that only works if I know the length of sdata ahead of time.
Answer
Try using an empty collapse argument within the paste function:
paste(sdata, collapse = '')
Thanks to http://twitter.com/onelinetips/status/7491806343
Subscribe to:
Post Comments (Atom)
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
A fair amount of the second act of The Dark Knight Rises has a class warfare plotline. This is foreshadowed in the trailers with Selina Ky...
-
I want to create an options array from a string. How can i create an array as { width : 100, height : 200 } from a string ...
-
I'm new to Programming. I would like to implement a program with a yield keyword . So That, I have created a new List and ask the user ...
No comments:
Post a Comment