[R] Sweave, SweaveHooks and printing the label

2011-04-16 Thread David.Epstein
I would like to print the label of each code chunk, just before printing the code chunk itself. Is that possible using SweaveHooks, or by some other mechanism? Thanks David -- View this message in context: http://r.789695.n4.nabble.com/Sweave-SweaveHooks-and-printing-the-label-tp3453829p3453829.

Re: [R] Storing user-defined R functions

2011-03-25 Thread David.Epstein
Thanks to everyone for writing. A well-known phenomenon in mathematics, statistics and/or complex computing is that everything one already knows feels trivial and easy. It's as though one is permanently climbing a vertical cliff-face, while, if you look back from where you've come, you see a level

[R] Storing user-defined R functions

2011-03-24 Thread David.Epstein
Hello, I don't want to find out how to make packages unless that becomes necessary. Also, I don't want to clog up the computer memory with functions that I'm not using. (It would be great if someone in this forum would explain how memory is used when I type library(MASS) and then use only one funct

[R] Sweave, white space and code blocks

2011-03-21 Thread David.Epstein
Sweave is very useful, and I'm gradually getting used to it. I've just been battling Sweave over the re-use of code chunks. As I am pretty ignorant in the byways of both Sweave and R, this took a chunk of time to sort out. Here is what I learned: If one re-uses a code chunk, then Sweave (but not

[R] Convert Sweave document to a function

2011-03-20 Thread David.Epstein
I like Sweave, which I consider to be a great contribution. I have just written a .Rnw document that comes to about 6 pages of mixed code and mathematical explanation. Now I want to turn the R code into a function. My R code currently contains statements like N<-1000 and theta<- pi/10. In the next

Re: [R] puzzles with assign()

2010-05-05 Thread David.Epstein
Duncan Murdoch-2 wrote: > > .. > That's because constructing names like this is generally a bad idea. > But you can do it; you use get() to get the object whose name is in > temp.name. So put data=get(temp.name) into your lm() call. > I had another useful answer (sent privately) from

[R] puzzles with assign()

2010-05-05 Thread David.Epstein
I'm trying to get code along the following lines to work: temp.name <- paste(TimePt,'df',sep='.') # invent a relevant name/symbol as a character string. assign(temp.name,IGF.df[IGF.df$TPt==TimePt,]) # this works. The relevant variable is now a data frame lm(b ~ Strain+BWt+PWt+PanPix, data=temp.nam

[R] Sweave: centering with echo=TRUE

2010-04-26 Thread David.Epstein
In a .Rnw file I want to insert the R command pairs(mydataframe) and achieve the following effects 1. the command itseld is echoed into the tex document generated by Sweave <>= 2. The graphics generated appears in the tex document, with the graphics centred. 3. The R command > pairs(mydataframe)

[R] unorder an ordered factor

2010-04-18 Thread David.Epstein
Given an ordered factor, how does one unorder it? I tried various commands with reorder, with order=F, but they all gave me error messages. I also tried to drop the order with various 'as dot something' commands, but these didn't work either. -- View this message in context: http://n4.nabble.com

Re: [R] perhaps regular expression bug with | sign ??

2010-04-11 Thread David.Epstein
William Dunlap wrote: > > >> > sub(x='>|t|',pattern = '\|t',replacement='zz') >> [1] "zz>|t|" >> Warning messages: >> 1: '\|' is an unrecognized escape in a character string >> 2: unrecognized escape removed from "\|t" >> How can \| be an unrecognized escape? This flatly contradicts >> help('

[R] simple question about contrasts, lm and factors

2010-04-11 Thread David.Epstein
I have a data frame with two variables that are factors. One is actually a TRUE/FALSE factor, and I have coded it as 1/0, a continuous variable, but I could turn it back into a factor. The second is an ordered factor and consists of five timepoints. There are several continuous variables as well.

[R] perhaps regular expression bug with | sign ??

2010-04-09 Thread David.Epstein
Here is my interaction with R: > sub(x='>|t|',pattern = '|t',replacement='zz') [1] "zz>|t|" So I say to myself "Clearly the | signs need to be escaped, so let's try this" > sub(x='>|t|',pattern = '\|t',replacement='zz') [1] "zz>|t|" Warning messages: 1: '\|' is an unrecognized escape in a charact

Re: [R] how does one print code

2010-04-08 Thread David.Epstein
I downloaded the code, as Duncan Murdoch suggested. I also used sink() as suggested by others and found that the two methods gave identical results. I then fixed the bug in a private file and tried it out on a number of examples. It now seems to work fine, as far as I can tell. >From CRAN, I foun

[R] how does one print code

2010-04-08 Thread David.Epstein
There is quite a long piece of code defining a certain function in one of the R packages. I think the code has a bug and I want to get the code into a file so that I can take a proper look, and possibly fix it. how does one do this? (I mean getting the code into a file, not fixing the bug.) I sup

Re: [R] appending an R-object to a list

2010-04-06 Thread David.Epstein
Thanks. A nice simple answer and exactly what I want. David -- View this message in context: http://n4.nabble.com/appending-an-R-object-to-a-list-tp1753544p1753665.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org m

[R] appending an R-object to a list

2010-04-06 Thread David.Epstein
How do I append an R-object to a list? I want to start with an empty list, and append R-objects one by one. Does this start with a command like mylist <- NULL ?? I have read a few answers on R-help to questions like this, but they all seem to be well off the point. Sometimes it's assumed that the