Reputation: 21
I have the following data set:
Date<-c("9/7/2010","9/7/2010","9/7/2010",
"9/7/2010","9/7/2010","9/7/2010","9/8/2010")
EstimatedQuantity<-c(3535,2772,3279,3411,3484,3274,3305)
ScowNo<-c("4001","3002","4002","BR 8","4002","BR 8","4001")
dataset<- data.frame(EstimatedQuantity,Date,ScowNo)
I'm trying to convert the data set into a contingency table and then back into a regular data frame:
xtabdata<-as.data.frame.matrix(xtabs(EstimatedQuantity~Date+ScowNo,
data=dataset),
row.names=(dataset$Date),optional=F)
Upvotes: 2
Views: 2265
Reputation: 49448
Is this what you want?
as.data.frame(unclass(xtabs(EstimatedQuantity~Date+ScowNo,data=dataset)))
Upvotes: 5