Selecting non-consecutive columns in R tables

前端 未结 4 1467
没有蜡笔的小新
没有蜡笔的小新 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 04:56

    You can also use logical values. Eg. df[c(TRUE,FALSE,TRUE)] selects the first and third column. The logical vector must have a number or elements equal to the number of columns in the data frame, otherwise its elements are replicated up to the number of columns.

提交回复
热议问题