I have a config.R
file which has variable P.
P_val<-function(s){
if(s==1){
return(p<-0.01)
}
else if(s==2){
return(p<-0.031)
}
else if(s==3){
return(p<-0.001)
}
else if(s==4){
return(p<-0.021)
}
else if(s==5){
return(p<-0.1)
}
else if(s==6){
return(p<-0.77)
}
else if(s==7){
return(p<-0.35)
}
else if(s==8){
return(p<-0.66)
}
}
In my main.R
file I want to use this P value but the thing is this p variable here is in a loop and I want different value for each loop run. I am showing you a sample demonstration of what I want:
d<-function(num){
for(s in seq(1,8,1)){
x=2*s ##some variable
source("config.R")
P_val(s)
reset(x,p)
}
reset<-function(x,p){
l_val= (x/p) * num
return(l_val)
}
}
I am using source("config.R")
in my main.R
file but I don't know how to use it as I am getting this error
Error in reset(x, p) : object 'p' not found