Hi,
I would like to select odd and even columns from a matrix that in columns' names has got odd and even numbers as a strings.
Here is my_matrix:
my_matrix <- structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA), .Dim = c(6L, 14L), .Dimnames = list(
c("P18", "P19", "P20", "P21", "P22", "P23"), c("P35_cor",
"P35_p", "P36_cor", "P36_p", "P37_cor", "P37_p", "P38_cor",
"P38_p", "P39_cor", "P39_p", "P40_cor", "P40_p", "P41_cor",
"P41_p")))
I have tried with parse_number but it converts all variables to V1, V2 and so on.
colnames(my_matrix) <- names(parse_number(colnames(my_matrix)))
How do I do it ? Thank you for any ideas.