Skip to content

Instantly share code, notes, and snippets.

@Akiyah
Last active August 29, 2015 14:04
Show Gist options
  • Save Akiyah/dd6af457ec96d30a0a7b to your computer and use it in GitHub Desktop.
Save Akiyah/dd6af457ec96d30a0a7b to your computer and use it in GitHub Desktop.
Barron's Ap Statisics Topic One:Graphical DisplayをRでやってみる
png("example_1_1.png", width=600, height=600)
dotchart(c(5,5,2,6,10,7),labels=c("Tennis", "Soccor", "Hockey", "Football", "Basketball", "Baseball"))
dev.off()
png("example_1_2.png", width=600, height=600)
barplot(c(55,15,25,5),names=c("End\ntrial","Continue\nwith\nwitnesses","Continue\nbut with\nno witnesses","No Opinion"))
dev.off()
png("example_1_3.png", width=600, height=600)
x <- c(rep(0,300),rep(1,400),rep(2,700),rep(3,300),rep(4,100),rep(5,100),rep(6,100))
hist(x, breaks=seq(-1,7,1))
dev.off()
png("example_1_4.png", width=600, height=600)
x <- c(rep(25,1),rep(35,5),rep(45,10),rep(55,12),rep(65,6),rep(75,4),rep(85,2))
hist(x, breaks=seq(20,90,10),xlab="Salary (in $1000s)")
dev.off()
png("example_1_5.png", width=600, height=600)
x <- c(rep(25.5,1),rep(26.5,2),rep(27.5,4),rep(28.5,3))
hist(x, breaks=seq(24,30,1))
dev.off()
x <- c(17,17,18,13,28,27,24,38,31,35,37,43,50)
stem(x)
# The decimal point is 1 digit(s) to the right of the |
#
# 1 | 3778
# 2 | 478
# 3 | 1578
# 4 | 3
# 5 | 0
x <- c(5.5, 5.57, 5.42, 5.61, 5.53, 5.47, 4.88, 5.62, 5.63, 4.07, 5.29, 5.44, 5.46, 5.55, 5.34, 5.3, 5.36, 5.79, 5.75, 5.29, 5.1, 5.86, 5.58, 5.27, 5.85, 5.65, 5.39)
stem(x, scale=2)
# The decimal point is 1 digit(s) to the left of the |
#
# 40 | 7
# 41 |
# 42 |
# 43 |
# 44 |
# 45 |
# 46 |
# 47 |
# 48 | 8
# 49 |
# 50 |
# 51 | 0
# 52 | 799
# 53 | 0469
# 54 | 2467
# 55 | 03578
# 56 | 1235
# 57 | 59
# 58 | 56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment