Selecting non-consecutive columns in R tables

前端 未结 4 1479
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 04:19

Let\'s say I have a some table, T. Assume T has 5 columns. I understand how to select any consecutive subset of columns and store them as a new table. For that I would use brack

4条回答
  •  一个人的身影
    2021-02-01 05:09

    If I understand your question correctly, you should try something similar to the following:

    df1 = data.frame(state=c("KS","CO","CA","FL","CA"), value=c(1,2,3,7,9))
    df1
    
    df1[c(c(1,3),4:5),]
    df1[c(1,3,4:5),]
    

提交回复
热议问题