Skip to content

Discrepancy between mlba::BostonHousing and code for creating Figure 3.1 #4

Open
@WACKE127

Description

@WACKE127

In the BostonHousing.csv.gz file, there is a column "CAT. MEDV". The code references this value as "CAT.MEDV" but R coerces the whitespace when using read.csv() to be another '.', resulting in the column representing as "CAT..MEDV" to R. This causes downstream errors when using the aggregation method and attempting to reference this misnomer.

Problem can be resolved by either changing the CSV file's column name to be "CAT.MEDV" by deleting the whitespace, or by altering the source code for Figure 3.1 to be "CAT..MEDV"

#Non-functional Code
CAT.MEDV.per.CHAS <- aggregate(housing.df$CAT.MEDV,
by=list(housing.df$CHAS),
FUN=mean)
names(CAT.MEDV.per.CHAS) <- c("CHAS", "MeanCATMEDV")
CAT.MEDV.per.CHAS$CHAS <- factor(CAT.MEDV.per.CHAS$CHAS)

#Functional Code
CAT.MEDV.per.CHAS <- aggregate(housing.df$CAT..MEDV,
by=list(housing.df$CHAS),
FUN=mean)
names(CAT.MEDV.per.CHAS) <- c("CHAS", "MeanCATMEDV")
CAT.MEDV.per.CHAS$CHAS <- factor(CAT.MEDV.per.CHAS$CHAS)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions