I am solving a task for my online R course. I have the following vector:
L<-list(Surname=c("Javi","James","Thomas","Arjen","David","Arturo","Robert"),
Number=c(8,11,25,10,27,23,9),
Name=c("Martinez","Rodriguez","Mueller","Robben","Alaba","Vidal","Lewandowski")
The task is to output the following result using the paste0()-function:
[1] "8:Javi Martinez" "11:James Rodriguez" "25:Thomas Müller"
[4] "10:Arjen Robben" ...
Using the function:
paste0(L$Nummer,L$Vorname,L$Name)
results in:
[1] "8JaviMartinez" "11JamesRodriguez" "25ThomasMueller"
[4] "10ArjenRobben"
I've tried to use the sep and the collapse arguments, but both of them only affect the end of the elements, for example 8JaviMartinez-, when using sep="-".
paste
and notpaste0
. There you can specify sep and collapse. Or writepaste0(L$Nummer, " ", L$Vorname, " ", L$Name)
– kathpaste0
is a shortcut forpaste(x, sep="")
– Amarpaste0
literally doesn't use a seperator. So try something else – Rohit