Reputation: 3057
I want to one parameter in one R script in another R script. For example in the first file for reading data:
wb <- loadWorkbook("adress")
dat <-readWorksheet(wb, sheet=getSheets(wb)[1], startRow=strow, endRow=endrow, startCol=spalte, endCol=spalte,header=FALSE)
datalist<-dat[,1]
while(n<=length(datalist))
{
m<-strsplit(datalist[n],split=",")
m<-sapply(m,as.numeric)
m<-c(m)
input<-m
# here I want to set input to another file
run1 <- parse("~/second.R")
n<-n+30
}
In the second.R
I have a parameter which name is input
but this code doesnt run second.R
. What should I do to solve this problem?
Update
the second.R is:
wbdb <- loadWorkbook("C:\\Adress\\Muster.xls")
datdb <-readWorksheet(wbdb, sheet=getSheets(wb)[1], startRow=1, endRow=35, startCol=1, endCol=2,header=FALSE)
datalistdb<-datdb[,1]
ke<-length(input)
i<-1
near<-1000
position<-0
while(i < 35)
{
m<-strsplit(datalistdb[i],split=",")
m<-sapply(m,as.numeric)
m<-c(m)
alignment<-dtw(input,m)
if(alignment$distance < near)
{
near<-alignment$distance
position<-i
}
i<-i+1
}
position
datdb[position,2]
Upvotes: 0
Views: 366
Reputation: 8488
You need to call eval
with second.R
:
run1 <- eval(parse("~/second.R"))
Upvotes: 1