0
Hello! When building a bar chart on R Language
using the RStudio
I came across the following mistake:
Error in barplot.default(database$results, main = "EvasionChart", xlab = rotulo[1], :
'height' must be a vector or a matrix
I researched a little about, I saw answers of various types but that did not solve my problem, to help in the context I am sharing the script. Below is the code:
database <- data.frame("curso" = 1:10, "e_eolica" = 1:10)
database$curso <- c("ItemA", "ItemB", "ItemC", "ItemD", "ItemE", "ItemF", "ItemG", "ItemH", "ItemI", "sdois")
database$results <- c(1, 2, 3, 4, 5, 6, 7, 8)
rotulo <- c(1, 2)
par(mgp=c(1,1,0))
png(filename = "C:/Users/BREWERTONTHIAGOOLIVE/Desktop/chart.png", width = 800, height = 800)
barplot(database$results, main = "EvasionChart", xlab = rotulo[1], ylab = rotulo[2], names.arg = database$curso, ylim = c(0, database$results[8]), cex.names = 0.8, xaxs = "i")
grid(nx=NA, ny=NULL)
barplot(database$results, main = "EvasionChart", xlab = rotulo[1], ylab = rotulo[2], names.arg = database$curso, ylim = c(0, database$results[8]), cex.names = 0.8, xaxs = "i", add = TRUE)
dev.off()