다음과 같이 R 명령이 있습니다. 다음과 같이g gplot2를 사용한 조건부 그래프
library(ggplot2)
df <- read.csv(file="c:\\query.csv"))
ggplot(df) +)
geom_point(aes(Time, Users)) +)
geom_point(data=df[df$Users>30,], aes(Time, Users),)
pch=21, fill=NA, size=4, colour="red", stroke=1) +)
theme_bw())
위의 명령에 사용 된 CSV 파일은 시간, 사용자, 판매 등으로 열이
내 질문에
Time Users Sellers
7 1 2
7 2 4
17 3 6
19 4 8
34 5 10
35 6 12
47 7 14
63 7 18
64 7 20
80 7 22
93 12 24
94 13 26
있습니다
1) 우리는 선을 그어야합니까 각 데이터 포인트를 첨부 하시겠습니까? 위의 명령을 아래와 같이 업데이트했지만 실패했습니다.
ggplot(df) + geom_point(aes(Time, Users)) + geom_point(data=df[df$Users>30,], aes(Time, Users),pch=21, fill=NA, size=4, colour="red", stroke=1) +
geom_line() + theme_bw()
2) 어떻게 시간 대 사용자 그래프에서 판매를위한 또 다른 그래프를 포함합니까? 나는 이것을 아래의 방식으로 수행했다.
ggplot(df, aes(Time, Users)) +
geom_point() + geom_point(data = df[df$Users > 30,], pch = 21, fill = NA, size = 4, colour = "red", stroke = 1) +
geom_line()+
theme_bw()
광고 2) 당신이 gridExtra
패키지를 사용할 수 있습니다 (참조 :하지만, 그래프 출력은 내가
ggplot(df) +
geom_point(aes(Time, Users)) +
geom_point(data=df[df$Users>30,], aes(Time, Users),pch=21, fill=NA, size=4, colour="red", stroke=1) + geom_point(aes(Time, Sellers)) +
geom_point(data=df[df$Sellers>10,], aes(Time, Sellers), pch=21, fill=NA, size=4, colour="red", stroke=1) +
theme_bw()
2 가지 의견 : 먼저 두 가지 문제가 있습니다. 두 가지 문제가 있습니다. 하나는 아니지만 두 가지 문제가 있습니다. 둘째로, 재현 가능한 예제를 얻기 위해서는'dput (df)'를 실행하고 그 결과를 질문에 추가하면 항상 도움이됩니다. – Qaswed
줄 끝의 닫는 괄호는 무엇입니까?! –