Hi all. I feel like this should be simple but I can't figure it out. I have a short vector of values
five_values <- (c("17", "93", "119", "399", "439"))
and a dataframe:
df <- data.frame("Col1" = sample(1:100, 10), "Col2" = sample(1:100, 10), "Col3" = sample(1:100, 10))
I want to append the five values to the end of each column of the data frame. So the last five rows of all columns should have exactly the same five values. If I use rbind() like this:
rbind(df, c("17", "93", "119", "399", "439"))
it appears to attempt to add the first value to Col1, the second to Col2 etc, rather than adding the full set of five to Col1, then to Col2 etc. as I want. So I get an error message because the number of values is not a multiple of the number of columns.
I tried a for loop, something like this:
for(i in 1:3) {
output = c("17", "93", "119", "399", "439")
rbind(df[,1:3], output)
}
But got the same result.
Can anyone help?