开发者

Using summary.lm function in rapache

I have installed rapache and I am trying to fit a linear model inside the R script file. I have configured the RFileHandler in the http.conf. When I am trying to invoke the summary(model) it is giving me a segment fault error ( i see this in the apache log file). I am guessing that it is trying to print to the console and that is why it is failing.

Has anyone encountered a similar problem with R and rapache? I am relatively new to R and summary is doing a lot of things that are not directly exposed as functions so I am hoping I could get it to work

Here is my r script

mydata <- read.table("/home/user/test.csv", header = TRUE, sep = ",")
fit <- lm(y~x1+x2+x3, data = mydata)
setContentType("text/html")
cat('<HTML><BODY>')
cat(summary(fit)$adj.r.squared)
cat('</BODY></HTML>\n')
DONE

if i replace

    cat(summary(fit)$adj.r.squared)

with this

    cat(coef(fit))

it is working!

Thanks Bharani开发者_运维技巧


Did you consider contacting the rapache Google Group as the rapache home page suggests? You may find more experienced reader there than here.


I have tested the following example and cat(summary(fit)$adj.r.squared) works in my (default) setup (latest rapache 1.1.8 and R 2.9.2 under Ubuntu 9.04)

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
fit <- lm(weight ~ group - 1) # omitting intercept
setContentType("text/html")
cat('<HTML><BODY>')
cat(summary(fit)$adj.r.squared)
cat('</BODY></HTML>\n')
DONE


Just found out that it is not with rapache. It is failing in R itself

 *** caught segfault ***
 address (nil), cause 'memory not mapped'

 Traceback:
  1: .Call("La_chol2inv", x, size, PACKAGE = "base")
  2: chol2inv(Qr$qr[p1, p1, drop = FALSE])
  3: summary.lm(fit)
  4: summary(fit)
  5: cat(summary(fit)$adj.r.squared)

 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace

not sure what that means though

-Bharani


I finally figured out the problem. Reading the discussion i wrongly libRlapck.so to lapack.so. Looks like that was causing problems. Did a clean install of R again and then modified apache to explicity load the libraries then it all worked Thanks - Bharani

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜