I am new(ish) to R and I am still unsure about loops.
If I had a large matrix object in R with columns having values of 0 - 4, and I would like to invert these values for specified columns.
I would use the code:
b[, "AX1"] <- 4 - b[, "AX1"]
Where b
is a Matrix extracted from a larger list object and AX1
would be a column in the matrix.
I would then replace the changed Matrix back into its list using the code:
DF1$geno[[1]]$data <- b
How would I loop this code through a list of column names(AX1
, AX10
, AX42
, ...)for about 30 columns of the 5000 columns in the matrix if I used a list with the 30 Column names to be inverted?