Plotting bar chart ,data is imported via CSV File

I m new to Rstudio When I tried to plot a barchart to show the Name vs Grade, I m getting the error as Preformatted text


Data Set

Check2 <- read.csv("F:/MYFiles/Semester2/Final Data/Check2.csv")

Naame Grade
A :1 Min. :20.00
B :1 1st Qu.:30.00
C :1 Median :50.00
D :1 Mean :52.67
E :1 3rd Qu.:70.00
F :1 Max. :90.00

barplot(Check2, main="Grade",

  •     xlab="Name")

Error in barplot.default(Check2, main = "Grade", xlab = "Name") :
'height' must be a vector or a matrix


  •     main="Marks chart",border="red")

Error in barplot(Grade, names.arg = Naame, xlab = "Name", ylab = "Grade", :
object 'Grade' not found


  •     main="Marks chart",border="red")

Error in barplot.default(Check2, names.arg = Naame, xlab = "Name", ylab = "Grade", :
object 'Naame' not found

Look at the documentation and examples of barplot (help pane in rstudio or ?barplot. You'll see how to work with this function. You cannot provide a data.frame - you must provide a vector with bar height or a matrix. Look at the example.

If you are new to R and want to explore data with graphics, I would advice to use ggplot2. Look at this introduction :

geom_col would be the the function you need to get a barplot, providinx x but also y as you know the height. Something like

ggplot(Check2, aes(x = Name, y = Grade)) + 

Look also at ?geom_col


This topic was automatically closed 21 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.