I'm trying to create a plot using boxcox function from package MASS.
but it's creating an rapache error.
The r code:
<%
csvDF<- read.csv(GET$name1, header=TRUE)
a<-lm(csvDF[,GET$col_variable]~1)
require(MASS)
filename1 <- paste(tempfile(tmpdir='/var/www/images'), '.png', sep='')
png(filename1)
bx<-boxcox(a)
dev.off()
%>
**GET$name1 is the csv data file address. **GET$col_variable is the variables column.
When I lose the "bx<-boxcox(a)" line the error disappear, so I guess that the boxcox causes the error.
Here are the rapache errors:
RApache Warning/Error!!!
Error in eval(expr, envir, enclos) : object 'csvDF' not found
RApache Warning/Error!!!
In addition:
RApache Warning/Error!!!
Warning messages:
RApache Warning/Error!!!
1: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step5_box_cox.php'
RApache Warning/Error!!!
2: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step5_box_cox.php'
RApache Warning/Error!!!
3: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step5_box_cox.php'
RApache Warning/Error!!!
4: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step5_box_cox.php'
RApache Warning/Error!!!
5: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step5_box_cox.php'
RApache Warning/Error!!!
Function brew returned开发者_如何学运维 an object of 'try-error'. Returning HTTP response code 500.
I will be gratefull for any suggestion.
It is very difficult to give a complete answer because your whole setup isn't available. The error message (as opposed to the warnings; worry about them later) is the variable csvDF
isn't found. It is unclear whether this error happens before or after you call read.csv
. Either way, the problem isn't the call to boxcox
.
Also note that lm
has a data argument that could make your code clearer. Try something like
lm_formula <- as.formula(paste(col_variable, "1", sep = "~"))
a <- lm(lm_formula, data = csvDF)
You would also benefit from separating out code that reads data, calculates statistics, creates plots and writes plots to file.
精彩评论