1

see: Selecting significant cases from a chi-squared test

The model example given in the case above is:

  f = function(N=1000){
   out <- data.frame("Row" = 1:N
                , "Column" = 1:N
               , "Chi.Square" = runif(N)
               ,  "df"= sample(N, 1:10, replace=T)
                ,  "p.value" = round(runif(N), 3)
               )
  return(out)
  }

but when I would apply this to my model I would turn this into:

 f = function(N=7000){
 combos <- combn(ncol(final),2)

 adply(combos, 2, function(x) {
 test <- chisq.test(final[, x[1]], final[, x[2]])

 out <- data.frame("Row" = colnames(final)[x[1]]
               , "Column" = colnames(final[x[2]])
               , "Chi.Square" = round(test$statistic,3)
               ,  "df"= test$parameter
               ,  "p.value" = round(test$p.value, 3)
                  )
return(out)
}}

yet R does not see this as a finished command line. Why?

Community
  • 1
  • 1
Bert Jacobs
  • 51
  • 1
  • 3
  • 2
    So you're having trouble finding where to put the `)`? I'll bet if you try putting a `)` in a few random spots near the end, you'll figure it out. – joran Oct 16 '11 at 18:59
  • @joran: that's terribly inefficient. You need to write a genetic algorithm to add characters, and mutate and combine the lines until it produces the correct code. – Joshua Ulrich Oct 16 '11 at 20:59

1 Answers1

0

Get yourself a decent editor :-)

adply(

isn't closed.

Edit: nor

function(...){

It looks like the final } should really be a ) + }

KarlP
  • 5,149
  • 2
  • 28
  • 41