I have a large dataset that i am trying to subset by selecting columns based on an arithmetic progression. My dataset has 370 columns. I want to remove 6 columns every 18 columns. What I did was
a=seq(from=5, to =365, by=18)
# num [1:21] 5 23 41 59 77 95 113 131 149 167 ...
and
b=seq(from=10, to =370, by=18)
to find the numbers of columns I need to remove.
I essentially need to remove columns: -[a:b]
, meaning [c(-5:-10,-(5+1*18):-(5+1*18),-(5+2*18):-(5+2*18),etc)
I tried to create a for loop to do that as follows:
for(i in 1:21) {temp <- subset(set, select = -c( a[i]:b[i]))}
# Error in a[i]:b[i] : NA/NaN argument
but it doesn't work because I get this error!