I keep getting an error that says subscription of bounds
statex77_stats <- summary(state.x77[["Income"]])
statex77_stats
I keep getting an error that says subscription of bounds
statex77_stats <- summary(state.x77[["Income"]])
statex77_stats
The problem is that state.x77
isn't a data frame.
str(state.x77)
#> num [1:50, 1:8] 3615 365 2212 2110 21198 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : chr [1:50] "Alabama" "Alaska" "Arizona" "Arkansas" ...
#> ..$ : chr [1:8] "Population" "Income" "Illiteracy" "Life Exp" ...
s <- as.data.frame(state.x77)
# equivalent
summary(s[["Income"]])
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 3098 3993 4519 4436 4814 6315
summary(s$Income)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 3098 3993 4519 4436 4814 6315
summary(s["Income"])
#> Income
#> Min. :3098
#> 1st Qu.:3993
#> Median :4519
#> Mean :4436
#> 3rd Qu.:4814
#> Max. :6315
s[2] |> summary()
#> Income
#> Min. :3098
#> 1st Qu.:3993
#> Median :4519
#> Mean :4436
#> 3rd Qu.:4814
#> Max. :6315
Created on 2023-04-07 with reprex v2.0.2
This topic was automatically closed 42 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.