The easiest way to create a null object.
We can use {} to create a NULL object
Simple example, use in for loop.
df <- {}
for (i in 1:10){
tbl <- c(paste('loop', i, sep='-'))
df <- rbind(df,tbl)
}
End result is like this,
But if you want to define the columns,
df <- data.frame(matrix(ncol = 3, nrow = 0))
colnames(df) <- c("name", "school", "grade")
No comments:
Post a Comment