Anyway, I simplfy my question. We have a dataframe like this:
dt <- data.frame(x=c(1,2,3), y=c("a", "b", "c"))
f <- function(x, y){
#f is a function that only take vector whose length is one.
}
So I need to use f function like the following:
f(1, "a")
f(2, "b")
f(3, "c")
I know I can use for-loop as the following:
for (i in 1:3) {
f(dt$x[i], dt$y[i])
}
But it seems stupid and ugly. Is there any better way to do such work?