Write the function used to plot the barcharts. Bargraph should have (title of graph, name of x axis, name of y axis, colour is red). Write the code and paste the screenshot of output.
Write the function used to plot the barcharts. Bargraph should have (title of graph, name of x axis, name of …
Share
Syntax: barplot(H,xlab,ylab,main, names.arg,col) Example: # Create the input vectors. colors = c("green","orange","brown") months <- c("Mar","Apr","May","Jun","Jul") regions <- c("East","West","North") # Create the matrix of the values. Values <- matrix(c(2,9,3,11,9,4,8,7,3,12,5,2,8,10,11), nrow = 3, ncol = 5, byrow = TRUE) # Give the chart file a name png(file = "barchartnew.png") # Create the bar chart barplot(Values, main = "total revenue", names.arg = months, xlab = "month", ylab = "revenue", col = colors) # Add the legend to the chart legend("topleft", regions, cex = 1.3, fill = colors) # Save the file dev.off() #goto your current directory(document) open file barchartnew.png #you will get image same as