Subtract a column in a dataframe from many columns in R

If you need to subtract the columns 3:ncol(df) from the second column

df[3:ncol(df)] <- df[3:ncol(df)]-df[,2]

Leave a Comment