Re: [R] How to source a part of the file

2011-03-13 Thread Paul Y. Peng
Many thanks to Jim Holtman and Gabor Grothendieck for your quick responses. Jim's solution works beautifully for my tasks. Thanks. I also tried Gabor's solution based on pipe(). Unfortunately it only works on a linux PC, not on Windows 7/Vista. Submitting the command in Windows results in nothing.

Re: [R] How to source a part of the file

2011-03-13 Thread Gabor Grothendieck
On Sun, Mar 13, 2011 at 11:32 PM, Paul Y. Peng pywp...@gmail.com wrote: Many thanks to Jim Holtman and Gabor Grothendieck for your quick responses. Jim's solution works beautifully for my tasks. Thanks. I also tried Gabor's solution based on pipe(). Unfortunately it only works on a linux PC,

Re: [R] How to source a part of the file

2011-03-13 Thread Paul Y. Peng
Yes, I do have Rtools installed on two Windows PCs I tested, and I used them to build R packages. I use sed all the time with no problems. Thanks for confirming me that it works on your Windows PC. I will test it again and will update you if I find out what's wrong in my pc. On Sun, Mar 13, 2011

Re: [R] How to source a part of the file

2011-03-13 Thread Gabor Grothendieck
On Mon, Mar 14, 2011 at 12:07 AM, Paul Y. Peng pywp...@gmail.com wrote: Yes, I do have Rtools installed on two Windows PCs I tested, and I used them to build R packages. I use sed all the time with no problems. Thanks for confirming me that it works on your Windows PC. I will test it again and

[R] How to source a part of the file

2011-03-11 Thread Paul Y. Peng
I have a text file of R commands. Some times I only want to run a few lines of the R commands in an existing R session and wonder whether there is a simple way to do this. To run a few lines in a new session of R, I could use sed to pick up the lines from the file and pipe them into R. source()

Re: [R] How to source a part of the file

2011-03-11 Thread Gabor Grothendieck
On Fri, Mar 11, 2011 at 4:41 PM, Paul Y. Peng pywp...@gmail.com wrote: I have a text file of R commands. Some times I only want to run a few lines of the R commands in an existing R session and wonder whether there is a simple way to do this. To run a few lines in a new session of R, I could

Re: [R] How to source a part of the file

2011-03-11 Thread jim holtman
You can do: source(readLines(yourFile)[10:20]) # lines 10-20 of the file On Fri, Mar 11, 2011 at 4:41 PM, Paul Y. Peng pywp...@gmail.com wrote: I have a text file of R commands. Some times I only want to run a few lines of the R commands in an existing R session and wonder whether there is a

Re: [R] How to source a part of the file

2011-03-11 Thread jim holtman
I meant to say, but my fingers got ahead of my brain: source(textConnection(readLines(yourFile)[10:20])) On Fri, Mar 11, 2011 at 4:53 PM, jim holtman jholt...@gmail.com wrote: You can do: source(readLines(yourFile)[10:20])   # lines 10-20 of the file On Fri, Mar 11, 2011 at 4:41 PM, Paul Y.