Identifying dataframe columns by their first few characters

后端 未结 1 887
暗喜
暗喜 2021-01-23 06:46

I have a dataframe in which the column names begin with certain characters:

> colnames(df)
[1] \"p.crossfencing\"  \"p.livestockdrinking\"  \"v.livestocktrai         


        
1条回答
  •  执笔经年
    2021-01-23 07:10

    Are you looking for df[,grep("^v.",names(df))]?

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