Hello Guys,
I need help. I am kinda new to R. I have an R file and i would like to know what does the below means
help_by_rank_2023 <- data.table::transpose(ranking_2023[,c(10:35,43:46)])
Note that this is from an excel sheet. To the best of my knowledge, 10:35 Means, Column 10 to Column 35 in the excel sheet. But 43:46 is what i am not sure of.
Thanks.
FJCC
May 21, 2023, 5:12am
2
The code ranking_2023[,c(10:35,43:46)]
is selecting columns 10 through 35 and columns 43 through 46. The c() function combines those two series of numbers.
c(10:35, 43:46)
[1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
[25] 34 35 43 44 45 46
Step-by-step shows what happens—a subset of variables of the original data frame is put in wider form
dim(mtcars)
#> [1] 32 11
# pick column variables
mtcars[,c(5:8,10:11)] |> dim()
#> [1] 32 6
# transpose with the data.table function
data.table::transpose(mtcars[,c(5:8,10:11)]) |> dim()
#> [1] 6 32
Created on 2023-05-20 with reprex v2.0.2
Thanks, This is really helpful.
Thanks, This is really helpful. I have a better understanding on how it works now.
1 Like
system
Closed
May 31, 2023, 6:43am
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.