Dear R ussers ,

I was trying to summaryse data with sql, from the sqldf pkg.

it seemed like a promessing solution, yet all i can do in this is 
calculate  " avg"  "count " and "sum".

where i d like to use confidence intervals  and standard deviation as wel.

now i was trying to find  a solution my self , but the closest i got was "
sqlite3_create_function16"
explained on 
                          http://www.sqlite.org/c3ref/create_function.html
sadely i don't understand much of the explanation.

Now i hoped sombody could give me an other SQL solution for this.

the function i hoped to use is this one.

> mean.CI <-
function (X,na.rm=T)
    {   names(X)<-NULL
        if (is.vector(X))  {nn <- length(X)}
        else   {nn <- nrow(X)}
        NAs <- sum(is.na(X))
        n <- nn-NAs
            if (na.rm) 
        avg  <- mean(X,na.rm=T)
        Sd  <- sd(X,na.rm=T)
        Var  <- var(X,na.rm=T)
        if (is.matrix(X)) {
            apply(X, 2, sd, na.rm = T) }
        else if (is.vector(X))  {
           confin <-qt(0.975,df=n-1)*(sd(X, na.rm = T)/sqrt(n))}
        else if (is.data.frame(X)){
           confin <-qt(0.975,df=n-1)*((sapply(X, sd, na.rm = T))/sqrt(n))}
        else {confin <- qt(0.975,df=n-1)*(sd(as.vector(X), na.rm = 
T))/sqrt(n)}
       out <-round (c( avg-confin ,avg+confin) ,digits=3)
       out 
    }


kind regards,
Tom


Disclaimer: click here
        [[alternative HTML version deleted]]

______________________________________________
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