6b)  Getting pretty close with some nasty code.  I think I could copy and
paste to openoffice calc and make it pretty fairly easily at this point.

I should make a function to clean up the repeated part at least.  Overall, I
think I could make a function that applies another function to generate a
table.  It might be something like:

rcTableCreate(c(4:5), c(6:8), dataframe, function)

So the first input is rows, the second is columns, the third is the data
frame(and whatever else might work) I'm pulling from, and function will be a
function that creates a mini-table that I'm trying to repeat.

My function that creates a block would be

cell = function(r,c)
{
  temp <- table(X[,r],X[,c])
  temp <- cbind(temp,prop.table(temp))
  temp <- subset(temp, select=c(2,4))
  colnames(temp) <- c("Num","%")
  return(temp)
} 
 
I'm going to test that out after I post here, but my code that is working at
the moment follows

---------------------------------------------------------------------
temp <- table(X[,3],X[,197])
temp <- cbind(temp,prop.table(temp))
temp <- subset(temp, select=c(2,4))
colnames(temp) <- c("Num","%")

 for (i in 198:229)
 {
   temp2 <- table(X[,3],X[,i])
   temp2 <- cbind(temp2,prop.table(temp2))
   temp2 <- subset(temp2, select=c(2,4))
   colnames(temp2) <- c("Num","%")
   temp <- cbind(temp,temp2)
 }

for (j in 4:5)
{
 temp2 <- table(X[,j],X[,197])
 temp2 <- cbind(temp2,prop.table(temp2))
 temp2 <- subset(temp2, select=c(2,4))
 colnames(temp2) <- c("Num","%")
 for (i in 198:229)
 {
   temp3 <- table(X[,j],X[,i])
   temp3 <- cbind(temp3,prop.table(temp3))
   temp3 <- subset(temp3, select=c(2,4))
   colnames(temp3) <- c("Num","%")
   temp2 <- cbind(temp2,temp3)
 }
 temp <- rbind(temp,temp2)
}
print(temp, digits = 1)
--------------------------------------------------------------------

I might be better off printing values instead of forming the table, but
there are
formatting issues I don't know how to solve at the moment.  Unfortunately, I
think
I'm taking the roundabout route to get this output, but that may be because
it's 6am.
Put into Calc and back out again, it looks something like this.

                            Num    %     Num        %    Num         %
Male                            7       0.05    36      0.24    2       0.01
Female                  2       0.01    16      0.11    0       0
< HS                            3       0.02    14      0.09    0       0
HighSchool/GED          1       0.01    13      0.09    0       0
some college            2       0.01    19      0.13    1       0.01
BA/BS                   3       0.02    4       0.03    1       0.01
>BS                             0       0       2       0.01    0       0
African American                9       0.06    39      0.26    1       0.01
White,Non-Hispanic      0       0       13      0.09    1       0.01
Other                   0       0       0       0       0       0

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Non-Parametric-Adventures-in-R-tp2952754p2964666.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to