data.frame - R getting columns that follow specific pattern -
i want select specific columns r dataframe , using below line , works fine:
maindata <- rbind(maindata, dat[c('segment','hwave')]) but want select columns names such q2_1, q2_2 q2_18. how effectively? can type individual column name won't efficient.
the line below gives me error.
maindata <- rbind(maindata, dat[c('segment','hwave','q2_1':'q2_18')])
try:
maindata <- rbind(maindata, dat[c("segment","hwave",paste("q2",1:18,sep="_"))]) r data.frame
No comments:
Post a Comment