0
나는 ggplot을 사용하기 시작하고이 example 시도하고있다 :ggplot2의 geombar()와 binwidth는
a4<-structure(list(MAACP = c(2.81, 2.28, 2.38, 3.96, 1.99, 4.69,
3.07, 3.41, 4.18, 1.67, 3.88, 2.89, 3.32, 4.15, 5.53, 2.19, 2.36,
5.07, 3.18, 1.58, 2.81, 3.09, 4.9, 3.69, 3.48, 4.58, 4.54, 3.42,
2.92, 3.83, 3.42, 2.51, 2.95, 3.97, 2.95, 5.55, 5.54, 3.39, 0,
2.06, 5.21, 2.64, 5.66, 2.15, 3.87, 4.09, 2.81, 5.19, 3.55, 5.17,
3.55, 2.19, 3.51, 4.9, 4.95, 2.91, 3.61, 3.06, 3.02, 3.49, 3.14,
4.23, 4.11, 2.36, 2.81, 2.82, 2.94, 4.17, 4.14, 4.35, 3.52, 3.35,
5.45, 3.41, 4.31, 4.31, 2.45, 3.35, 4.11, 3.21, 2.52, 4.91, 3.92,
4.84, 2.84, 2.95, 2.98, 3.67, 4.75, 3.62, 2.88, 3.09, 3.36, 3.29,
2.47, 3.59, 3.59, 2.6, 1.85, 5.06), type = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L,
1L, 1L), .Label = c("1", "2"), class = "factor")), .Names = c("MAACP",
"type"), row.names = c(NA, 100L), class = "data.frame")
불행하게도, 내가 표시 할 음모를 얻을 수 없습니다 내 데이터에
library(ggplot2)
set.seed(6298)
diamonds_small <- diamonds[sample(nrow(diamonds), 1000), ]
hist_cut <- ggplot(diamonds_small, aes(x=price, fill=cut))
hist_cut + geom_bar() # defaults to stacking
을 히스토그램. 변화하지 않는 binwidth
변경
hist_cut<-ggplot(a4,aes(x="MAACP",fill=type),binwidth=.1)
hist_cut+geom_bar()
: 만 변수 x를 통과 할 때 geom_bar
는 기본적으로 히스토그램을 생성처럼
hist_cut<-ggplot(a4,aes(x="MAACP",fill=type),binwidth=.1)
hist_cut+geom_bar(binwidth=0.1)
나는 혼란 스러워요. 히스토그램을 생성 할 수있는 코드는 표시하지 않습니다. 일반적으로'geom_histogram'을 사용합니다. – Roland
@roland : 감사합니다. 링크 된 페이지의 중간 부분을 살펴보십시오. (필자가 재현 한 다섯 번째 코드 줄 바로 아래에,'fill = cut '에 대해'ctrl-F'를 사용하면 얻을 수있는 코드입니다). 그게 뭐든간에 나는 그런 음모를 원해. – user189035