How to create bar chart in R?

Description

To create a bar chart for the given data using R programming.

Bar Chart

   Representation data in rectangular barswith the length of the bar proportionalto the value of the variable.

   R Function : barplot()

#Data Visualization in Bar Chart

#Read File
print(getwd())
setwd(“/home/soft13″)
print(getwd())
data<-read.csv(‘input.csv’)
print(data)

#Bar Chart
barplot(data$salary,names.arg = data$name,main=”Bar Plot”,xlab=”Name”,ylab=”Salary”,col=rainbow(length(data$salary)))
legend(“topright”,legend=data$name,fill=rainbow(length(data$salary)))

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit