[rkward-users] [rkward - Help] RE: trouble with crosstabs and regression out

SourceForge.net noreply at sourceforge.net
Sun Nov 18 23:49:53 UTC 2007


Read and respond to this message at: 
https://sourceforge.net/forum/message.php?msg_id=4630286
By: edoviak

Here's the message I sent to rkward-devel [at] lists [dot] sourceforge [dot]
net

Is that the correct address? I'll also try resending it. Apologies in advance
if you get it a few times.

- Eric

-------------------

Hi Thomas and RKWard Developers,

Last month, I promised to create labels for the output of the  crosstabs (N
to 1) plugin. Apologies for being a bum.

On a positive note, I found a simple way to use R code to create the labels.
Below this message is the text of the R script and the simple comma-separated
value dataset that I used to test the script.

Since a month has passed ... Here's a summary of the bug that this script fixes:
In the current version of RKWard (0.4.8a), the output table of the crosstabs
(N to 1) plugin is very confusing. For example, create a fictional dataset with
two dummy variables: RKWard_user (1 if uses RKWard, 0 otherwise) and female
(1 if female, 0 otherwise). Then run the N to 1 crosstab and look at the output.
The only labels on the rows and columns are 0 and 1.

The script below adds labels to the rows and columns of the output table. It
can handle any number of independent variables and any number of values.

I hope this small contribution helps. Let me know if you have any questions.

Thanks again for producing a great product!
- Eric



local({
## Prepare
## Compute
x <- my.csv.data[["white"]]
yvars <- list (substitute (my.csv.data[["gray"]]), substitute
(my.csv.data[["black"]]))
results <- list()
descriptions <- list ()

# calculate crosstabs
for (i in 1:length (yvars)) {
   yvar <- eval (yvars[[i]], envir=globalenv ())
   results[[i]] <- table(x, yvar)

   descriptions[[i]] <- list ('Dependent'=rk.get.description
(my.csv.data[["white"]]), 'Independent'=rk.get.description (yvars[[i]],
is.substitute=TRUE))
}

## make row and column names
nu_dep     <- c( rep( NA , times=length( results ) ) )
nu_indep   <- c( rep( NA , times=length( results ) ) )

dep_dim_names    <- c( rep( NA , times=length( results ) ) )
indep_dim_names  <- c( rep( NA , times=length( results ) ) )


for (i in 1:length( results ) ) {
       nu_dep[i]     <- length( row.names(   results[[i]]  ) )
       nu_indep[i]   <- length( row.names( t(results[[i]]) ) )

       dep_name   <- c( rep( NA , times = nu_dep[i]   ) )
       indep_name <- c( rep( NA , times = nu_indep[i] ) )

       for (j in 1:nu_dep[i]) {
         dep_name[j]   <- as.character( paste( descriptions[[i]][['Dependent']],
"=", row.names( results[[i]] )[j] , ": " ) )         }

       for (j in 1:nu_indep[i]) {
         indep_name[j]   <- as.character( paste(
descriptions[[i]][['Independent']],"=", row.names( t( results[[i]] ) )[j] ,
": " ) )
       }

       dep_dim_names[i]   <- list(dep_name)
       indep_dim_names[i] <- list(indep_name)
}

## Print result
for (i in 1:length (results)) {
    rk.header ("Crosstabs (n to 1)", parameters=list ("Dependent",
descriptions[[i]][['Dependent']], "Independent",
descriptions[[i]][['Independent']]))
   rk.print (as.data.frame( matrix( results[[i]] , nrow=nu_dep[i] , ncol=nu_indep[i]
,
              dimnames= list( dep_dim_names[i][[1]] , indep_dim_names[i][[1]]
) ) ) )
 }
})


black,white,gray
2,3,1
0,3,3
1,1,1
0,2,2
1,2,4
0,0,1
1,0,2
0,0,1
2,0,1
0,0,4
1,1,1
0,1,2
2,1,1
0,1,2
1,1,1
0,0,2
2,1,0
0,0,0
1,0,0
2,0,3
1,1,0
0,1,0
1,1,3
0,1,0
1,1,0
1,0,0
1,1,0
1,0,3
1,0,4
0,0,0




______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit: 
https://sourceforge.net/forum/unmonitor.php?forum_id=165574




More information about the Rkward-users mailing list