Divide each number in each column by 1000 in R

I would like to divide each number in all columns by 1000. I would like to omit the row header and 1st column from this function.

I tried this code:

 TEST2=(TEST[2:503,]/(1000))

But that is not what I am looking for. There are 503 columns in my data frame.

+4
source share
1 answer

Is a TESTfile frame? In this case, the row header will not be divided by 1000. To select all columns except the first, use the index in jto select all columns except the first? eg.

TEST[, 2:ncol(TEST)]/1000 # selects every row and 2nd to last columns
# same thing
TEST[, -1]/1000 # selects every row and every but the 1st column

Or you can select columns by name, etc. (you select columns in the same way as you currently select rows).

, ?'[', , .

+6

Source: https://habr.com/ru/post/1532263/


All Articles