How could one get started with a self-written function? I have a function written in .txt format, but can not find the way to import it to the R space. Would be very appreciated for help. -- View this message in context: http://r.789695.n4.nabble.com/run-a-slef-written-function-tp3356537p3356537.html Sent from the R help mailing list archive at Nabble.com.
you could run source(directory/textfilename.txt) [and then you can use it in R] or paste the function into the console, or highlight and pass the function from the built in R text editor, or highlight and pass the function from your external text editor (notepad++, emacs, textwrangler, etc.) On Tuesday, March 15, 2011 at 8:21 AM, bra86 wrote:> How could one get started with a self-written function? > I have a function written in .txt format, but can not find the way to import > it to the R space. > Would be very appreciated for help. > > -- > View this message in context: http://r.789695.n4.nabble.com/run-a-slef-written-function-tp3356537p3356537.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
?source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD IGBMC, 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France wolfgang.raffelsberger (at) igbmc.fr ________________________________________ De : r-help-bounces at r-project.org [r-help-bounces at r-project.org] de la part de bra86 [anastasia.krikovtseva at tugraz.at] Date d'envoi : mardi 15 mars 2011 14:21 ? : r-help at r-project.org Objet : [R] run a slef-written function How could one get started with a self-written function? I have a function written in .txt format, but can not find the way to import it to the R space. Would be very appreciated for help. -- View this message in context: http://r.789695.n4.nabble.com/run-a-slef-written-function-tp3356537p3356537.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.
source("myfunction.R") is the usual approach. You could also just copy your code and paste it into the R console. Sarah On Tue, Mar 15, 2011 at 9:21 AM, bra86 <anastasia.krikovtseva at tugraz.at> wrote:> How could one get started with a self-written function? > I have a function written in .txt format, but can not find the way to import > it to the R space. > Would be very appreciated for help.-- Sarah Goslee http://www.functionaldiversity.org
On Mar 15, 2011, at 9:21 AM, bra86 wrote:> How could one get started with a self-written function? > I have a function written in .txt format, but can not find the way > to import > it to the R space. > Would be very appreciated for help.It would be more typical to use a file extension of .r but I do not think the source function cares greatly about that issue. The should be material coving this topic in "Introduction to R". ?source -- David Winsemius, MD West Hartford, CT