Skip to content

Instantly share code, notes, and snippets.

@jayeshcp
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save jayeshcp/f910b3f246cf1383b608 to your computer and use it in GitHub Desktop.

Select an option

Save jayeshcp/f910b3f246cf1383b608 to your computer and use it in GitHub Desktop.
Plotting simple bar chart in T

Script:

# Read table data from csv file
data <- read.table("data.csv", header=T, sep=",")

# Start PDF device driver to save output to skills.pdf
pdf(file="skills.pdf", height=3.5, width=5)

# Draw bar chart
barplot(data$rating, main="Skills",  
   ylab="Rating", names.arg=data$skills)

# Turn off device driver (to flush output to PDF)
dev.off()

Sample data.csv file:

skills,rating
Java,8
PHP,6
JavaScript,6
Android,6
C++,4

Chart:

Skills Bar Chart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment