1
data <- read.csv("/Users/infinite/Desktop/covid_19_india.csv", header = TRUE)
table(data$State.UnionTerritory)
barplot(table(data$State.UnionTerritory), ylab = 'No. of confirmed cases', main= "Bar plot 
of covid19 cases")

But I want to plot confirmed cases variable on x axis and State.UnionTerritory on y axis. I want to use two variables to plot. But the Method i tried using has just one variable with its frequency on y axis. Please help me.

Note : This file has two variable 1. State.UnionTerritory, 2. Confirmed

I want to plot them against each other using bar plot.

Amit Yadav
  • 39
  • 4

1 Answers1

1

You mark this question with the tag ggplot2 In that case the basic code is:

library("ggplot2")
ggplot(data=data) +
    geom_col(aes(x=confirmed, y=State.UnionTerritory))

In base R think it something liki this

barplot(height=data$confirmed, names=data$State.UnionTerritory, horiz=T , las=1)

PD: try to avoid name your variables with names used by base R (in this case "data")