For loops in R Programming
*From your lecture you did this .
title <- c("Catch", "me", "if", "you", "can")
new.title <- vector (lenght = 5)
for (i in 1:5) {
new.title[i] <- title[i]
}
----------------------------------------------------------------------
*if i do this, am i still in order, even though i arrived at same output
title <- c("Catch", "me", "if", "you", "can")
new.title <- c(1:5)
for (i in 1:5) {
new.title[i] <- title[i]
}
1 answers ( 0 marked as helpful)
Hi Ashakah,
both solutions you've shown give the same result, so you're approach is correct, as well.
Well done!
Best,
365 Eli