2013-08-23 2 views
-2

나는 Quarter와 Unique Customer ID 컬럼을 포함하는 데이터 프레임을 가지고 있는데, Quarter에서 Unique 고객 수를 세는 그래프를 그립니다. 내가 뭘하려그래프에서 ggplot을 사용하여 그래프를 그리는 방법

uniquegraph<-data.frame(uniqueCustomerdf) 
> uniqueCustomer<-c(uniquegraph$Customer.Id) 
> Quarter<-c(uniquegraph$Quarter) 
> uniquegraphplot<-data.frame(uniqueCustomer=uniqueCustomer,Quarter=Quarter) 
> ggplot(uniquegraphplot,aes(x=Quarter,y=uniqueCustomer)) + geom_bar(stat="identity") 

이며, 또한 내가 hist

hist(uniqueCustomer, plot=TRUE) 

그러나 여기 쿼터를 할당하는 방법을 내가 여기

을받지 오전 내 데이터입니다 시도

Quarter    Customer.Id 


2009 Q1     10025 


2009 Q1     10096 


2009 Q1     10062 


2009 Q1     10030 


2009 Q1     10037 


2009 Q1     10078 


2009 Q1     10032 


2009 Q1     10243 


2009 Q1     10052 


2011 Q1     10019 


2009 Q4     13710 


2009 Q4     15310 


2009 Q4     13814 


2010 Q


2009 Q4     10143 
+2

는 재현 예를 제공하거나 데이터의 적절한 설명을 제공하십시오 . 방법에 대한 도움말은 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example을 참조하십시오. –

+0

@Roman Luštrik 데이터 이미지를 첨부했습니다. – snehal

+0

@ user2492230 데이터를 텍스트가 아닌 이미지로 추가하면 더 나은 응답을 얻을 수 있습니다. [링크] (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r)를 참조하십시오. -reproducible-example) 로마가 제안했다. 아무도 손으로 데이터를 입력하지 않습니다. – zx8754

답변

0

고객 ID가 고유 한 가정이 해결책이 될 수 있습니다

# df--> your posted data 
# converting string to factor 
df[ ,1] <- factor(df[,1]) 

# here the standard R produce this plot: 
plot(df[,1]) 

Rplot

# if you prefer eg. ggplot 
require(ggplot2) 
qplot(df[,1]) + ylab("Frequency")+xlab("Quarters")+ geom_bar(fill="lightblue") 

ggplot

HTH

+0

@ holzbrn. 감사합니다. 나는 그래프를 얻었다. – snehal

관련 문제