names(U1)
[1] "username" "review_count" "forum_posts" "age" "avg_interval"
[6] "avg_sim" "class"
So how do I create an empty data frame U1.RN that will have same columns as U1?
names(U1)
[1] "username" "review_count" "forum_posts" "age" "avg_interval"
[6] "avg_sim" "class"
So how do I create an empty data frame U1.RN that will have same columns as U1?
You can do this:
U1.RN <- U1[0,]
Using dplyr, there are a few good options:
slice(U1, 0)
filter(U1, FALSE)
filter(U1, NA)
The slice approach is probably clearest.
filter(FALSE) also works and is maybe a little clear of intent. slice(0) might be even better.slice(0) seems to be a winner on readability/clarity