Issue
I am trying to pass variable as an argument to system command in R.
> system("ls>abc.csv") #this works
> k<-"abc.csv"
> system("ls>k") #this does not work
> system2("ls>k") #this does not work
sh: ls>k: command not found
> system("ls>$k") #this does not work
sh: $k: ambiguous redirect
Solution
You can use paste
to build the OS command and pass to system
system(paste("ls >", k))
Answered By - Sonny Answer Checked By - Senaida (WPSolving Volunteer)