I want to add two data.frame.
One is empty and the second has 20 rows only where there are only characters.
However i want to do this one several times, with while loop.
Like this :
one <- data.frame()
#initialization of the loop
i <- 1
while (i != 10){
final <- cbind(one, two)
}
And the console answer me :
Error in data.frame(..., check.names = FALSE) :
the arguments involve different numbers of lines: 0, 20
How can i resolve it ? Because when try, simplier, final <- cbind(one, two) ten times, it's okay...
Your while loop doesn't make any sense to me. First of all, you're not updating i, so this loop will run forever. Second, even if you add a stopping condition (say i <- (i + 1) before closing the while loop), what will you get? final will still be cbind(one, two), and repeating it has no meaning. Perhaps, you were planning to update final in each repetition, or something like that?
How did you run cbind(one, two), where one is an empty data frame, and two has 20 rows? I failed to run it, as you can find below:
one <- data.frame()
two <- data.frame(1:20)
cbind(one, two)
#> Error in data.frame(..., check.names = FALSE): arguments imply differing number of rows: 0, 20
Please try to ask a properly formulated question with a minimal reproducible example. This will help others to help you. You can go through these helpful posts: