How do I plot a bar graph using data from 3 columns in a dataframe read from a csv file? I tried doing it with the following code but had some difficulty getting my desired output:
setwd("\\path\\to\\csv")
df = read.csv("xxxx.csv")
# All hospitals in AL
AL = df[grep("AL", df$State),]
hos <-subset(AL,Hospital.Name=='COOPER GREEN MERCY HOSPITAL')
# Gives me "Error in -0.01 * height : non-numeric argument to binary operator"
hos <- data.frame (HeartAttack=hos$Heart.Attack.Mortality,HeartFailure=hos$Heart.Failure..Mortality,
Pneumonia=hos$Pneumonia.Mortality)
# Gives me the graph without displaying the x-axis values
# but completely defeats the purpose of reading from a csv file since the values are hard-written
#hos <- data.frame (HeartAttack=c(1),HeartFailure=c(5),Pneumonia=c(10))
barplot(t(as.matrix(hos)),main='Mortality Rate in Cooper Green Mercy Hospital',
xlab='Illness',ylab='Mortality Rate',beside=TRUE)
The csv file has 10 headers (from left to right): Hospital.Name, City, State, County.Name, Heart.Attack.Mortality, Heart.Attack.Readmission, Heart.Failure..Mortality, Heart.Failure.Readmission, Pneumonia.Mortality and Pneumonia.Readmission. Bold ones are the columns I'm interested in.

Note: I have already looked at these two SO questions, but they did not quite solve my problem.

hosis not reproducible. Can you post sample data? Please edit the question with the output ofdput(hos). Or, if it is too big with the output ofdput(head(hos, 20)).ggplot2::geom_col. You can usetidyr::gatherto reflow columns into a variable:value pair.