Correlation Plot in R Won't Graph

157 Views Asked by At

DATA (hope this link works): https://www.dropbox.com/sh/eizrotzgdkssyx4/AABr_0PBJjaSXxooz3c0bSAZa?dl=0https://www.dropbox.com/sh/eizrotzgdkssyx4/AABr_0PBJjaSXxooz3c0bSAZa?dl=0

I am trying to analyze the various medical conditions (diabetes, asthma, highblood, etc) and their impact on readmission rates. Each column is for a different disease with a factor of either "Yes" or "No". I have to use multiple linear regression for the project. I recoded everything from Yes -> 1 and No -> 0 then changed all my columns to numeric. Now I am trying to do a correlation matrix and the actual matrix looks ok but when I go to plot it, nothing appears. Makes me think that I set up the data wrong.

medical_data <- read_csv("C:/Users/amand/Dropbox/School/D208 - Predictive/MLR_health_data_original/medical_clean.csv")

# Import file
medical_data <- data linked
# Create subset of data with just the medical conditions
conditions <- medical_data[27:38]
# Remove the "Complication_risk" column from the list of medical conditions since it does not qualify as a diagnosable disease under the purposes for this analysis
conditions <- conditions[-c(3)]
# Adds readmission column
conditions <- cbind(conditions, medical_data[20])

# Convert all variables from type "character" to type "factor" to convert later into numeric data
conditions[,colnames(conditions)] <- lapply(conditions[,colnames(conditions)] , factor)

# Convert factors to numeric
conditions[,colnames(conditions)] <- lapply(conditions[,colnames(conditions)] , as.numeric)

# Convert 1's to 0's
for (i in 1:12) {
conditions[i][conditions[i] == 1] <- 0
}

# Convert 2's to 1's
for (i in 1:12) {
  conditions[i][conditions[i] == 2] <- 1
}

When I use cor(conditions), I get very tiny values (-e05) for the columns Stroke and Reflux_esophagitis but everything looks okayish.

I tried using the Hmisc library using rcorr(as.matrix(conditions)) and I got the same values. I tried even making a heatmap and the values will not appear there either.

What am I doing wrong? Why are my values so small for only those two columns? Why can't I plot my correlation matrix?

0

There are 0 best solutions below