This is the code I was using in R to extract the standard deviation of the numeric columns of my dataset. But, the for loop is ending without displaying any output. What is the problem in my code? I know for sure that there are numeric columns in my dataset.
for(col in colnames(stats)){
if(is.numeric(stats[, col])){
cat(paste(col, "sd is ", as.character(round(sd(stats[, col]), 2)), '\n'))
}
}
Structure of my dataframe(stats)
> str(stats)
tibble [3,145 x 11] (S3: tbl_df/tbl/data.frame)
$ Name : chr [1:3145] "A. Urzi" "V. Castellanos" "E. Palacios" "L. MartÃnez" ...
$ Age : num [1:3145] 19 20 20 21 21 21 21 21 21 21 ...
$ Nationality : chr [1:3145] "Argentina" "Argentina" "Argentina" "Argentina" ...
$ Club : chr [1:3145] "Club Athletico Banfield" "New York City FC" "River Plate" "Ajax" ...
$ Overall : num [1:3145] 69 63 77 77 68 73 81 66 66 78 ...
$ Potential : num [1:3145] 87 80 87 85 81 87 89 76 79 87 ...
$ International Reputation: num [1:3145] 1 1 1 1 1 1 1 1 1 1 ...
$ Skill Moves : num [1:3145] 3 3 4 3 3 2 4 2 2 4 ...
$ Team Position : chr [1:3145] "Attacker" "Attacker" "Midfielder" "Defender" ...
$ Contract Valid Until : num [1:3145] 2021 2022 2021 2023 2019 ...
$ Value in Euros : num [1:3145] 2.3e+06 8.0e+05 1.4e+07 1.2e+07 1.7e+06 8.0e+06 2.7e+07 9.5e+05 1.2e+06 1.6e+07 ...
> dput(head(stats))
structure(list(Name = c("A. Urzi", "V. Castellanos", "E. Palacios",
"L. MartÃnez", "F. Moyano", "C. Romero"), Age = c(19, 20, 20,
21, 21, 21), Nationality = c("Argentina", "Argentina", "Argentina",
"Argentina", "Argentina", "Argentina"), Club = c("Club Athletico Banfield",
"New York City FC", "River Plate", "Ajax", "Argentinos Juniors",
"Genoa"), Overall = c(69, 63, 77, 77, 68, 73), Potential = c(87,
80, 87, 85, 81, 87), `International Reputation` = c(1, 1, 1,
1, 1, 1), `Skill Moves` = c(3, 3, 4, 3, 3, 2), `Team Position` = c("Attacker",
"Attacker", "Midfielder", "Defender", "Midfielder", "Defender"
), `Contract Valid Until` = c(2021, 2022, 2021, 2023, 2019, 2024
), `Value in Euros` = c(2300000, 8e+05, 1.4e+07, 1.2e+07, 1700000,
8e+06)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))