Convert R vector to string vector of 1 element

StringRVectorArgumentsSystem

String Problem Overview


Im working with the programming language R now. I have a vector:

a <- c("aa", "bb", "cc")

And I want to paste these to a system command, I'm trying it this way now:

args <- paste(a, sep=" ")
system(paste("command",args, sep=" "))

But now I'm only getting the arguments aa, and I want the arguments aa, bb and cc...

Anyone knows what I'm doing wrong?

String Solutions


Solution 1 - String

Use the collapse argument to paste:

paste(a,collapse=" ")
[1] "aa bb cc"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJetseView Question on Stackoverflow
Solution 1 - StringJamesView Answer on Stackoverflow