[R] r function definition
FJ M
chicagobrownblue at hotmail.com
Tue Dec 4 15:07:19 CET 2012
Are you using windows? If you are you may want to try to run your R code from a batch file:
REM on Microsoft Windows (adjust the path to R.exe as needed)
"C:\Program Files\R\R-2.13.2\bin\x64\R.exe" CMD BATCH "C:\Users\Frank\Documents\R\Projects\Heinrich\Heinrich.txt" "C:\Users\Frank\Documents\R\Projects\Heinrich\Heinrich.out"
PAUSE
Where ...Heinrich.txt is the following R code in a text file:
pdf("Heinrich.pdf")
## load Pearson package
library(PearsonDS)
## calculate probability density function Fig. 1
x <- seq(0.0, +20.0, length=100)
hx<- dpearsonIV(x,m=2.25,nu=5,location=17,scale=2)
k<-0.0206631
plot(x, hx , type="l", lwd=2, tck=1, xlab="x value", ylab="Density", main="J. Heinrich Fig. 1")
## calculate probability density function Fig 2
hx<- dpearsonIV(x,m=0.75,nu=1.0,location=15,scale=0.5)
k<-0.218991
plot(x, hx , type="l", lwd=2, tck=1, xlab="x value", ylab="Density", main="J. Heinrich Fig. 2")
quit()
and Heinrich.out will contain the output of the results of the commands. Look at Heinrich.out for results and errors. Then correct the text file and rerun.
GL
Frank
Chicago
----------------------------------------
> Date: Mon, 3 Dec 2012 12:30:31 -0800
> From: qiz5 at hotmail.com
> To: r-help at r-project.org
> Subject: [R] r function definition
>
> I am a very new R user. I am trying to write functons and debug functions.
> One problem for me is that I need to alwasy copy the whole function body and
> resubmit to R console every time I changed even one line of the function.
> Because I have long algorithm function, copying and pasting is very tedious
> for me. I assume if I save the function files, R should be able to just use
> the new function body since it is a scripting language. Can somebody let me
> know his best practice of using R function?
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/r-function-definition-tp4651943.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list