[R] How to include (source) R script in other scripts

Duncan Murdoch murdoch.duncan at gmail.com
Wed Jan 8 18:52:25 CET 2014


On 08/01/2014 11:27 AM, Baro wrote:
> Hi experts
>
> I want to read an excel file in an R-script and send the inputs to another
> script to more process
>
> the first file for reading the data is (First.R):
>
> 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
>
>    n<-n+30
> }
>
> and now, I want to use input in other R script for each loop (second.R),
> how can I do that

You should be using functions for this.  Write a function that loads 
your workbook and does the processing above.  Call that in a loop.

Duncan Murdoch




More information about the R-help mailing list