我正在尝试使用批处理文件来运行函数 SPLOT 以将变量引入我的响应表面代码。我已经确认变量正确传递并且是数字的,但是,当它到达 as.coded.data 函数时,我收到错误消息,它无法找到变量。这是此功能的限制吗?当我手动输入值代替这些变量时,它起作用了。
'''
SPLOT <-function(workdir, savedir, TREAT1_LABEL, TREAT2_LABEL, TREAT3_LABEL,RESP1_LABEL, RESP2_LABEL,
T1LOW, T1HIGH, T1MID, T2LOW, T2HIGH, T2MID,
T3LOW, T3HIGH,T3MID){
file_list <- list.files(path=workdir, pattern="*.csv")
for (x in 1:NROW(file_list)) {
PROJ_DATA<-read.csv(file=file_list[x])
i <- 1
while (i <= NROW(file_list)) {
name<-regmatches(file_list[x], regexpr("*.*", file_list[x])) # extract the text from the file-name inorder to name the plot
mytitle = paste(name,".pdf")
mytitle1 = paste(name, ".tiff")
PROJ_DATA.adj <- PROJ_DATA
results <- "savedir"
setwd(workdir)
#### Summarize Data ####
PROJ_DATA1 <- PROJ_DATA.adj %>% group_by(FACTOR) %>%
summarise(N = length(FACTOR),
mean.TREAT1 = mean(TREAT1, na.rm=TRUE),
mean.TREAT2 = mean(TREAT2, na.rm=TRUE),
mean.TREAT3 = mean(TREAT3, na.rm=TRUE),
mean.RESP1 = mean(RESP1, na.rm=TRUE),
mean.RESP2 = mean(RESP2, na.rm=TRUE))%>% drop_na()
PROJ_DATA2 <- na.omit(PROJ_DATA1)
#### Relativize the Dataset - coding ####
PROJ_DATA.coded <- as.coded.data(PROJ_DATA, TREAT1.coded ~ (mean.TREAT - T1MID)/(0.5*(T1HIGH-T1LOW)),
TREAT2.coded ~ (mean.TREAT2 - T2MID)/(0.5*(T2HIGH-T2LOW)),
TREAT3.coded ~ (mean.TREAT3 - T3MID)/(0.5*(T2HIGH-T2LOW)))
PROJ_DATA2.rsm <- rsm(RESP1 ~ FACTOR + SO(TREAT1.coded, TREAT2.coded, TREAT3.coded), data = PROJ_DATA.coded)
PROJ_DATA2.rsm$studres <- rstudent(PROJ_DATA2.rsm)
summary(PROJ_DATA2.rsm)