I am working on a task for my R course. I have the following vector:
vector<-c("If;umbrella.;rains,;it;take;I;will;an")
The task is to:
1) remove the ; 2) order the vector (If it rains, I will take an umbrella.) 3) write the result to the console without the ""
I can do step 3) with just using cat(B), although I am not sure that is the correct way. Step 1) and 2) are a bit confusing - do you have any suggestions?
cat(paste(strsplit(vector,";")[[1]][c(1,4,3,6,7,5,8,2)],collapse=" "))
# If it rains, I will take an umbrella.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.