Create empty dataframe in R with same columns

后端 未结 3 442
鱼传尺愫
鱼传尺愫 2020-12-29 03:21
 names(U1)

[1] \"username\"     \"review_count\" \"forum_posts\"  \"age\"          \"avg_interval\"
[6] \"avg_sim\"      \"class\"

So how do I cre

相关标签:
3条回答
  • 2020-12-29 03:40

    You can do this:

    U1.RN <- U1[0,]
    
    0 讨论(0)
  • 2020-12-29 03:46

    Along the lines of df[0,] you can also use a boolean mask which might make the code more readable:

     df[FALSE,]
    
    0 讨论(0)
  • 2020-12-29 03:51

    Using dplyr, there are a few good options:

    slice(U1, 0)
    filter(U1, FALSE)
    filter(U1, NA)
    

    The slice approach is probably clearest.

    0 讨论(0)
提交回复
热议问题