Marc, it's the second "expansion" type transformation I was after, although
your expand.dft looks quite complicated? here's what I finaly came up with -
the bold lines correspond to what expand.dft does?
> orig<-matrix(c(40,5,30,25), c(2,2))
> orig
[,1] [,2]
[1,] 40 30
[2,]5 25
>
Is this what you want?
> xtabs(Freq ~ Var1 + Var2, data = orig)
Var2
Var1 A B
A 40 30
B 5 25
See ?xtabs
Or is this what you want?
expand.dft <- function(x, na.strings = "NA", as.is = FALSE, dec = ".")
{
DF <- sapply(1:nrow(x), function(i) x[rep(i, each = x$Freq[i]), ],
On May 22, 2008, at 8:56 AM, maiya wrote:
sorry, my mistake!
the data frame should read:
orig<-as.data.frame.table(orig)
orig
Var1 Var2 Freq
1AA 40
2BA5
3AB 30
4BB 25
but basicaly i would simply like a sample of the original matrix
( which is
a fre
sorry, my mistake!
the data frame should read:
orig<-as.data.frame.table(orig)
orig
Var1 Var2 Freq
1AA 40
2BA5
3AB 30
4BB 25
but basicaly i would simply like a sample of the original matrix ( which is
a frequency table/contingency table/crosstabulation)
Not exactly clear what you are asking for. Your data.frame.table does not
seem related to the original 'orig'. What exactly are you expecting as
output?
On Wed, May 21, 2008 at 10:16 PM, maiya <[EMAIL PROTECTED]> wrote:
>
> i appologise for the trivialness of this post - but i've been searching
i appologise for the trivialness of this post - but i've been searching the
forum wothout luck - probably simply because it's late and my brain is
starting to go..
i have a frequency table as a matrix:
orig<-matrix(c(40,5,30,25), c(2,2))
orig
[,1] [,2]
[1,] 40 30
[2,]5 25
i basic
6 matches
Mail list logo