Nashville ZZZZZZZZZZZZZZZZZZZZZZ

1

JHorner (Read 156 times)

Trent


Good Bad & The Monkey

    If you do a clustered block randomization of an intervention on groups of clinical providers (say, half to one method of clinical charting and half to another), is it ever valid to analyze results at the level of their patients? So if you have 10 clinics that care for 18000 patients, and randomize the clinics 5 to each arm, would you look at outcomes per patient (and end up with HUGE power) or per clinic (and possibly be underpowered)?
      42

      When it’s all said and done, will you have said more than you’ve done?

      JakeKnight


        42
        Strange. I came up with the same answer.

        E-mail: eric.fuller.mail@gmail.com
        -----------------------------

        Trent


        Good Bad & The Monkey

          No clue, I'm not a statistician. I answer questions like these: Duncan Murdoch wrote on 08/04/2008 08:11 AM: > On 04/08/2008 8:50 AM, Peter Jaeger wrote: >> Dear List, >> >> When I try to parse code containing newline characters with >> R_ParseVector, I >> get a compilation error. How can I compile code that includes comments >> and >> newlines? >> >> I am using the following: >> >> void* my_compile(char *code) >> { >> SEXP cmdSexp, cmdExpr = R_NilValue; >> ParseStatus status; >> >> PROTECT (cmdSexp = allocVector (STRSXP, 1)); >> SET_STRING_ELT (cmdSexp, 0, mkChar (code)); >> PROTECT (cmdExpr = R_ParseVector (cmdSexp,-1,&status, >> R_NilValue)); >> UNPROTECT_PTR (cmdSexp); >> >> if (status != PARSE_OK) { >> return (void*)0; >> } else { >> return (void*)cmdExpr; >> } >> } > > You need to put together a reproducible example if you want help. > parse() uses R_ParseVector, and it handles newlines fine. I say: As a follow up, it'd be good to know the exact value of your status variable. You've only tested for PARSE_OK, but there's also PARSE_INCOMPLETE, PARSE_NULL, PARSE_ERROR, and PARSE_EOF. Here's a function that I use in rapache that not only parses but executes the code as well. While it doesn't really help you with your parsing problem, I suspect that you'll want to do something with the returned expressions after you've parsed the code, and the point is that R_ParseVector() can return more than one expression. Thus you'll need to loop through each expression and eval() it separately. The function returns 1 when the code was parsed and executed, and 0 on failure. (it's been awhile since I've had to touch this, and although I do keep up with R development, my skills at remembering which macros and functions to use are lacking. Anyone spot something I shouldn't be doing? like mkChar() or some such? ) static int ExecRCode(const char *code, SEXP env, int *error){ ParseStatus status; SEXP cmd, expr, fun; int i, errorOccurred=1, retval = 1; PROTECT(cmd = allocVector(STRSXP, 1)); SET_STRING_ELT(cmd, 0, mkChar(code)); /* fprintf(stderr,"ExecRCode(%s)\n",code); */ PROTECT(expr = R_ParseVector(cmd, -1, &status,R_NilValue)); switch (status){ case PARSE_OK: for(i = 0; i < length(expr); i++){ r_tryeval(vector_elt(expr, i),env,&erroroccurred); if (error) *error = erroroccurred; if (erroroccurred){ retval=0; break; } } break; case parse_incomplete: case parse_null: case parse_error: case parse_eof: default: retval=0; break; } unprotect(2); return retval; } length(expr);="" i++){="" r_tryeval(vector_elt(expr,="" i),env,&erroroccurred);="" if="" (error)="" *error="errorOccurred;" if="" (erroroccurred){="" retval="0;" break;="" }="" }="" break;="" case="" parse_incomplete:="" case="" parse_null:="" case="" parse_error:="" case="" parse_eof:="" default:="" retval="0;" break;="" }="" unprotect(2);="" return="" retval;="" }=""></ length(expr); i++){ r_tryeval(vector_elt(expr, i),env,&erroroccurred); if (error) *error = erroroccurred; if (erroroccurred){ retval=0; break; } } break; case parse_incomplete: case parse_null: case parse_error: case parse_eof: default: retval=0; break; } unprotect(2); return retval; } >
          Trent


          Good Bad & The Monkey

            Dude, it is the old curly braces problem all over again.
              Wha?