Sometimes I print out a package and read about it and there are sometimes nice examples that I would like to run myself. Is there a way to bring them into R from the package or are they only meant to be typed in manually ? If manual is the only way, that's fine. I was just checking whether there was a quicker way. Thanks. Mark ********************************************************************** This email and any files transmitted with it are confidentia...{{dropped}}
Mark Leeds wrote:> Sometimes I print out a package > and read about it and there > are sometimes nice examples > that I would like to run myself. > > Is there a way to bring them > into R from the package or > are they only meant to be typed > in manually ? If manual is the > only way, that's fine. I was > just checking whether there was > a quicker way. Thanks.See (you won't believe it): ?example Uwe Ligges> Mark > > > ********************************************************************** > This email and any files transmitted with it are confidentia...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
wow. example() was exactly what I wanted. you all have made all these incredible facilities for a new person. thanks. mark -----Original Message----- From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de] Sent: Monday, January 09, 2006 1:30 PM To: Mark Leeds Cc: R-Stat Help Subject: Re: [R] R newbie example code question Mark Leeds wrote:> Sometimes I print out a package > and read about it and there > are sometimes nice examples > that I would like to run myself. > > Is there a way to bring them > into R from the package or > are they only meant to be typed > in manually ? If manual is the > only way, that's fine. I was > just checking whether there was > a quicker way. Thanks.See (you won't believe it): ?example Uwe Ligges> Mark > > > ********************************************************************** > This email and any files transmitted with it areconfidentia...{{dropped}}> > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html ********************************************************************** This email and any files transmitted with it are confidentia...{{dropped}}
Mark, I am not user where you find your reading material, but if it is online, perhaps you can copy and paste it into an R session. John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC and University of Maryland School of Medicine Claude Pepper OAIC University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 410-605-7119 - NOTE NEW EMAIL ADDRESS: jsorkin at grecc.umaryland.edu>>> "Mark Leeds" <Mleeds at kellogggroup.com> 1/9/2006 1:20 PM >>>Sometimes I print out a package and read about it and there are sometimes nice examples that I would like to run myself. Is there a way to bring them into R from the package or are they only meant to be typed in manually ? If manual is the only way, that's fine. I was just checking whether there was a quicker way. Thanks. Mark ********************************************************************** This email and any files transmitted with it are confidentia...{{dropped}} ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On 09-Jan-06 Mark Leeds wrote:> Sometimes I print out a package > and read about it and there > are sometimes nice examples > that I would like to run myself. > > Is there a way to bring them > into R from the package or > are they only meant to be typed > in manually ? If manual is the > only way, that's fine. I was > just checking whether there was > a quicker way. Thanks. > > Mark > > > ********************************************************************** > This email and any files transmitted with it are > confidentia...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
On 09-Jan-06 Mark Leeds wrote:> Sometimes I print out a package > and read about it and there > are sometimes nice examples > that I would like to run myself. > > Is there a way to bring them > into R from the package or > are they only meant to be typed > in manually ? If manual is the > only way, that's fine. I was > just checking whether there was > a quicker way. Thanks. > > MarkI had the same issue many moons ago, and for the same reasons! It was discussed in a fairly extended, and interesting, thread from 24-27 May 2003 -- go to the R-help archives for that month, by thread, and find the thread [R] help output paged in separate window The solution I finally opted for, and still use, is based (in a Linux environment) on including the following code in your .Rprofile file: .xthelp <- function() { tdir <- tempdir() pgr <- paste(tdir, "/pgr", sep="") con <- file(pgr, "w") cat("#! /bin/bash\n", file=con) cat("export HLPFIL=`mktemp ", tdir, "/R_hlp.XXXXXX`\n", sep="", file=con) cat("cat > $HLPFIL\nxterm -e less $HLPFIL &\n", file=con) close(con) system(paste("chmod 755 ", pgr, sep="")) options(pager=pgr) } .xthelp() rm(.xthelp) (and it's also specific to the 'bash' shell because of the "#! /bin/bash\n", but you should be able to change this appropriately). The above was posted by Roger Bivand on 27 May. When you start an R session, this code is executed as part of sourcing your .Rprofile, and it has the effect that any output from R which would be paged is stored in a temporary file which is then read by 'less' in a separate X window which is detached from your R session (i.e. your command interface will not hang while it is being displayed). You can close the X window displaying the 'less' output by closing 'less' (e.g. type "q"), or you can leave it open and any new paged output will go into a new window -- so you can for instance do ?glm ?family ?binomial and you will have three mutually relevant help windows open at once between which you can cross-reference. As to extracting the code for examples, this is easy in X windows since you just use your mouse: left-button drag to hghlight a block of text, middle-button click to paste the block into another window (of course the mouse must be over the correct window!) So you can use the mouse to copy code from the "help" pages to the command window. As I say, this is a Linux-oriented solution, and I don't know what details would be required for anything similar in a Windows environment. It is also worth reading the various contributions to the above thread, since several suggestions were made. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 10-Jan-06 Time: 13:30:35 ------------------------------ XFMail ------------------------------
Hello, Why not just copy and paste the examples from the help pages? No need to type anything. However, if you'd like to run the entire help section for a function, check out the example function, i.e.:> example(plot)Robert -----Original Message----- From: Mark Leeds [mailto:Mleeds at kellogggroup.com] Sent: Monday, January 09, 2006 1:20 PM To: R-Stat Help Subject: [R] R newbie example code question Sometimes I print out a package and read about it and there are sometimes nice examples that I would like to run myself. Is there a way to bring them into R from the package or are they only meant to be typed in manually ? If manual is the only way, that's fine. I was just checking whether there was a quicker way. Thanks. Mark ********************************************************************** This email and any files transmitted with it are confidentia...{{dropped}} ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html