0

I'm trying to create a barplot with the following code:

# Make an ID variable to keep track of each person
person_id <- seq(1, 20, 1) # Enter folks ’ responses into R
r_difficulty <- c("moderate",
"moderate",
"easy",
"difficult",
"very difficult",
"very difficult",
"difficult",
"very easy",
"moderate",
"very difficult",
"difficult",
"easy",
"moderate",
"difficult",
"very difficult",
"moderate",
"difficult",
"easy",
"difficult",
"very difficult")

# Combine the variables into a data frame object
data <- data.frame(person_id , r_difficulty ). 

When I try to create a barplot, I receive the error "height must be a vector or a matrix. Im not sure what information I am missing here. Thanks!

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46
rainekoua
  • 21
  • 1
  • What do you expect your final plot to look like? Does `barplot(table(data$r_difficulty))` produce your expected outcome? – jared_mamrot Apr 04 '22 at 00:13
  • When you say barplot, do you mean histogram? If so, something like this might work for you: '''plot(table(data$r_difficulty), ylab = "count", xlab = "r_difficulty")''' – Sudaraka Apr 04 '22 at 00:13
  • 1
    It would help to see the code that you used to generate the barplot. – neilfws Apr 04 '22 at 00:23
  • Does this answer your question? [Making a Barplot](https://stackoverflow.com/questions/13281860/making-a-barplot) – jared_mamrot Apr 04 '22 at 03:21

0 Answers0