I'm new to R and need to add a new function file to an existing package. For the programming and testing I used load_all() (from the devtools pkg) to have the original R files. I wrote my function and saved it in the same directory as the rest of the (original) R files. But now when I do load_all(), this function is executed! I have no idea why. What am I doing wrong here?
library(devtools)
calc_curve<-function(){
CurvePars<-c(0,0)
doMIC<-readline("Do you want to calculate MIC? (y/n) \n")
if(doMIC=="y")
{
CAlb<-readline("Do you want to use C.Albicans/FLC standard curve? (y/n)\n")
#use the equation we calculated MIC=a*exp(b*Rad). V1=a, V2=b
if(CAlb=="y") CurvePars=c(7.17, -0.129)
else
{
exFile <- readline("Do you have a standard curve file? (y/n)\n ")
if(exFile=="y"){
setwd(getwd())
curveFile <- tcltk::tk_choose.files(caption = "Select the standard curve data file") ;
tempPars<-read.table(curveFile, header=FALSE,sep=",",dec=".");
CurvePars=unlist(tempPars)
# calculate MIC and add to data file
}
else{
calib<-readline("Do you want to provide data for MIC calibration? (y/n)\n")
if(calib=="y"){
MICFile <- tcltk::tk_choose.files(caption = "Select the MIC calibration file")
MICdata<- read.csv(MICFile, header=FALSE,sep="\t",dec=".");
MIC_length=length(MICdata[[1]])
R1<-0
MIC<-0
for (i in 1:MIC_length)
{
R1[i]<-RAD2.df[MICdata[i,1],"RAD20"];
MIC[i]<-MICdata[i,2]
}
fit<-lm(log(MIC)~R1)
A=summary(fit)$coefficients[1]
CurvePars<-exp(A)
B=summary(fit)$coefficients[2]
CurvePars[2]<-B
CurveFile <- readline( "How would you like to name the curve file?\n ")
# handle the case of a pre-existing file
#open(File=paste(CurveFile,".csv",sep=""),"w")
CurveFile=paste(getwd(),"/",CurveFile,".csv",sep="")
write.table(CurvePars,CurveFile,col.names = FALSE,row.names = FALSE)
}
else {CurvePars[1]=0
CurvePars[2]=0}
}
}
}
CurvePars
}