Reputation: 189
I have a requirement of creating pivot table from dataframe given below :
Kindly help me to get pivot table as given below (I have copied from excel) :
I need exactly given as using R.
To generate the similar set of dataset you can use the command given below :
enter code here
Data1 <- data.frame(
X = sample(1:10),
Y = sample(1:10),
Z = sample(1:10),
count= sample(11:20))
Thanks in advance !
Upvotes: 1
Views: 313
Reputation: 54277
Try ftable
:
exData <- setNames(as.data.frame(unique(t(combn(rep(1:3, 3), m=3)))), paste0("P", 1:3))
ftable(exData)
Upvotes: 2