-2

i have data frame which contains Quarter and Unique Customer ID columns what i want is plot a graph which will count the Unique customers by Quarter.

what i tried is

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")

and also i tried hist

hist(uniqueCustomer, plot=TRUE)

but here how to assign Quarter i am not getting

Here is my data

 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 Q3                   13210


2009 Q4                   10143
snehal
  • 429
  • 5
  • 11
  • 25
  • 2
    Please provide a reproducible example or give adequate description of your data. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for help on how to do that. – Roman Luštrik Aug 23 '13 at 08:21
  • @Roman Luštrik i have attached the data image. – snehal Aug 23 '13 at 09:32
  • @user2492230 you will get a better response if you add the data as text(not image) - see the [link](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) Roman suggested. No one is going to enter your data by hand. – zx8754 Aug 23 '13 at 10:22
  • sorry.now i edited my image to test. – snehal Aug 23 '13 at 10:48
  • See the link I provided, especially the part about `dput`. – Roman Luštrik Aug 23 '13 at 10:58
  • I am trying to put my output but it is too large not fitting here, – snehal Aug 23 '13 at 11:51

1 Answers1

0

Assuming your customer id is unique, this might be a solution:

# 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

holzben
  • 1,459
  • 16
  • 24