[Rd] Straight-quotes for usage and examples sections in PDF docs?
Is there any way to ensure that quotation marks are left as straight quotes and not converted to curly quotes in the \usage and \examples sections when the pdf versions of the docs are created? __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Function works when custom defined but not when part of a package
Ah, "forgot" is a bit too generous. Seems I failed to get that far in the Extensions manual because I never dealt with S4 classes until now. Thanks for the pointer. Mike -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ 2010/9/28 Uwe Ligges : > I guess you forgot to import the relevant S4 functionality into your > namespace. > > Best, > Uwe > > > > On 28.09.2010 02:33, Mike Lawrence wrote: >> >> Hi folks, >> >> I'm not sure if this is a bug or not so I thought I'd check here >> first. I came across it while working on an update to my package where >> I try to get AICtab slot from the summary of an lmer object ( >> summary(my_lmer)@AICtab ). The attached contains a minimal example, >> where the code below will work if you load the f() function by >> sourcing the package's R code but will throw an error ("trying to get >> slot "AICtab" from an object (class "table") that is not an S4 >> object") if you load the f() function by installing and loading the >> package itself. >> >> library(lme4) >> #here is where you would either source('f.R') or library(dummy) >> >> #fit an lmer model (from ?lmer examples) >> fm1<- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) >> >> #run f() >> f(fm1) >> >> >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Function works when custom defined but not when part of a package
Hi folks, I'm not sure if this is a bug or not so I thought I'd check here first. I came across it while working on an update to my package where I try to get AICtab slot from the summary of an lmer object ( summary(my_lmer)@AICtab ). The attached contains a minimal example, where the code below will work if you load the f() function by sourcing the package's R code but will throw an error ("trying to get slot "AICtab" from an object (class "table") that is not an S4 object") if you load the f() function by installing and loading the package itself. library(lme4) #here is where you would either source('f.R') or library(dummy) #fit an lmer model (from ?lmer examples) fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) #run f() f(fm1) dummy_0.0-1.tar.gz Description: GNU Zip compressed data __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] save() file size (PR#13816)
Full_Name: Mike Lawrence Version: 2.9.0 OS: OS 10.5.7 Submission from: (NULL) (208.98.203.100) When using save() I notice that sometimes saving smaller objects yield larger file sizes. x=data.frame( expand.grid( id=factor(1:1000) ,trial=1:24 ,cue=factor(1:3) ,flank=factor(1:4) ) ) save(x,file='temp1.Rdata') #about 20KB y=x[x$id!='1',] save(y,file='temp2.Rdata') #>500KB __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Aggregate factor names
Understood, but my point is that the naming I suggest should be the default. One should not be 'punished' for being explicit in calling aggregate. On 27-Sep-07, at 1:06 PM, Gabor Grothendieck wrote: > You can do this: > > aggregate(iris[-5], iris[5], mean) > > > On 9/27/07, Mike Lawrence <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> A suggestion derived from discussions amongst a number of R users in >> my research group: set the default column names produced by aggregate >> () equal to the names of the objects in the list passed to the 'by' >> object. >> >> ex. it is annoying to type >> >> with( >>my.data >>,aggregate( >>my.dv >>,list( >>one.iv = one.iv >>,another.iv = another.iv >>,yet.another.iv = yet.another.iv >>) >>,some.function >>) >> ) >> >> to yield a data frame with names = c >> ('one.iv','another.iv','yet.another.iv','x') when this seems more >> economical: >> >> with( >>my.data >> ,aggregate( >>my.dv >>,list( >>one.iv >>,another.iv >>,yet.another.iv >>) >>,some.function >>) >> ) >> >> -- >> Mike Lawrence >> Graduate Student, Department of Psychology, Dalhousie University >> >> Website: http://memetic.ca >> >> Public calendar: http://icalx.com/public/informavore/Public >> >> "The road to wisdom? Well, it's plain and simple to express: >> Err and err and err again, but less and less and less." >>- Piet Hein >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Aggregate factor names
Hi all, A suggestion derived from discussions amongst a number of R users in my research group: set the default column names produced by aggregate () equal to the names of the objects in the list passed to the 'by' object. ex. it is annoying to type with( my.data ,aggregate( my.dv ,list( one.iv = one.iv ,another.iv = another.iv ,yet.another.iv = yet.another.iv ) ,some.function ) ) to yield a data frame with names = c ('one.iv','another.iv','yet.another.iv','x') when this seems more economical: with( my.data ,aggregate( my.dv ,list( one.iv ,another.iv ,yet.another.iv ) ,some.function ) ) -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] SWF animation method
Thanks to Max & Romain for noting alternative methods. As mentioned in my original post, I've tried the png->imagemagick- >gif solution and was displeased with quality of the results (using default quality values at least). Additionally, I disliked the idea (shared with the menconder method) that part of the process involved the creation of a large number of intermediary files which would then have to be deleted at some point. I know 'rm *.png' is as easy as 'rm mypdf.pdf', but the difference in forgetting to do this, from the perspective of gui file browsing at least, is significant. Mike On 8-Aug-07, at 12:20 PM, Kuhn, Max wrote: > Also, > > I've used ImageMagick's convert utility to make animated gifs. > Generate > a series of files (I used png) and then > > convert -delay 50 -page +0+0 im01.png -page +0+0 im01.png -page +0+0 > im01.png -loop 0 mov.gif > > Max > >> -Original Message- >> From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Romain Francois >> Sent: Wednesday, August 08, 2007 11:11 AM >> To: Mike Lawrence >> Cc: r-devel@r-project.org; John Christie >> Subject: Re: [Rd] SWF animation method >> >> Hello Mike, >> >> You might want to give "mencoder" a try. It usually comes with > mplayer. >> I did play with it a while ago and was fairly happy with the results. >> Basically, the idea was to create many jpg files somewhere, which is > not >> too hard using the %03d substitution described in ?jpeg. >> The rest is described here: >> http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html >> >> Cheers, >> >> Romain >> >> PS: You might find some links in this (not really maintained) >> webpage: > >> http://addictedtor.free.fr/movies/ > > -- > LEGAL NOTICE > Unless expressly stated otherwise, this message is confidential and > may be privileged. It is intended for the addressee(s) only. > Access to this E-mail by anyone else is unauthorized. If you are > not an addressee, any disclosure or copying of the contents of this > E-mail or any action taken (or not taken) in reliance on it is > unauthorized and may be unlawful. If you are not an addressee, > please inform the sender immediately. -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] SWF animation method
Hi all, Just thought I'd share something I discovered last night. I was interested in creating animations consisting of a series of plots and after finding very little in the usual sources regarding animation in R directly, and disliking the imagemagick method described here (http://tolstoy.newcastle.edu.au/R/help/05/10/13297.html), I discovered that if one exports the plots to a multipage pdf, it is relatively trivial to then use the pdf2swf command in SWFTools (http://www.swftools.org/download.html; mac install instructions here: http://9mmedia.com/blog/?p=7). pdf2swf seems to generate swf animations with a slow frame rate, but you can increase the framerate using 'swfcombine -r 30 --dummy myslow.swf -o myfast.swf', where the value passed to -r is the framerate. Unfortunately, this method seems to have limitations with regards to the number of plots it can convert. For example, on my system (17" macbook pro, 2.33GHz, 2GB ram, OSX 10.4.10, R 2.5.1) the maximum number of single point plots I can do is about 5400 (i.e. for(i in 1:5400) plot(runif(1),ylim=c(0,1)) ). Complexity of the plots might matter as well, but I only have rather convoluted examples of this. Also, pdf2swf throws up a lot of errors ('ERROR Internal error: drawChar.render!=beginString.render'), the origin of which I know not, that might be slowing things down. Now, if only someone could wrap this process into a single R command (I'm a little too newb to do this myself I think). Mike -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Suggestion to extend aggregate() to return multiple and/or named values
bugfix already :P prior version fails when there is only one factor in Ind. This version also might be faster as I avoid using aggregate to create the dummy frame. agg=function(z,Ind,FUN,...){ FUN.out=by(z,Ind,FUN,...) num.cells=length(FUN.out) num.values=length(FUN.out[[1]]) for(i in 1:length(Ind)){ Ind[[i]]=unique(Ind[[i]]) } temp=expand.grid(Ind) for(i in 1:num.values){ temp$new=NA n=names(FUN.out[[1]])[i] names(temp)[length(temp)]=ifelse(!is.null(n),n,ifelse(i==1,'x',paste ('x',i,sep=''))) for(j in 1:num.cells){ temp[j,length(temp)]=FUN.out[[j]][i] } } return(temp) } On 13-Jul-07, at 1:29 PM, Mike Lawrence wrote: > Hi all, > > This is my first post to the developers list. As I understand it, > aggregate() currently repeats a function across cells in a > dataframe but is only able to handle functions with single value > returns. Aggregate() also lacks the ability to retain the names > given to the returned value. I've created an agg() function (pasted > below) that is apparently backwards compatible (i.e. returns > identical results as aggregate() if the function returns a single > unnamed value), but is able to handle named and/or multiple return > values. The code may be a little inefficient (there must be an > easier way to set up the 'temp' data frame than to call aggregate > and remove the final column), but I'm suggesting that something > similar to this may be profitably used to replace aggregate entirely. > > #modified aggregate command, allowing for multiple/named output values > agg=function(z,Ind,FUN,...){ > FUN.out=by(z,Ind,FUN,...) > num.cells=length(FUN.out) > num.dv=length(FUN.out[[1]]) > > temp=aggregate(z,Ind,length) #dummy data frame > temp=temp[,c(1:(length(temp)-1))] #remove last column from dummy > frame > > for(i in 1:num.dv){ > temp=cbind(temp,NA) > n=names(FUN.out[[1]])[i] > names(temp)[length(temp)]=ifelse(!is.null(n),n,ifelse > (i==1,'x',paste('x',i,sep=''))) > for(j in 1:num.cells){ > temp[j,length(temp)]=FUN.out[[j]][i] > } > } > return(temp) > } > > #create some factored data > z=rnorm(100) # the DV > A=rep(1:2,each=25,2) #one factor > B=rep(1:2,each=50) #another factor > Ind=list(A=A,B=B) #the factor list > > aggregate(z,Ind,mean) #show the means of each cell > agg(z,Ind,mean) #should be identical to aggregate > > aggregate(z,Ind,summary) #returns an error > agg(z,Ind,summary) #returns named columns > > #Make a function that returns multiple unnamed values > summary2=function(x){ > s=summary(x) > names(s)=NULL > return(s) > } > agg(z,Ind,summary2) #returns multiple columns, default names > > > -- > Mike Lawrence > Graduate Student, Department of Psychology, Dalhousie University > > Website: http://memetic.ca > > Public calendar: http://icalx.com/public/informavore/Public > > "The road to wisdom? Well, it's plain and simple to express: > Err and err and err again, but less and less and less." > - Piet Hein > > -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Suggestion to extend aggregate() to return multiple and/or named values
Hi all, This is my first post to the developers list. As I understand it, aggregate() currently repeats a function across cells in a dataframe but is only able to handle functions with single value returns. Aggregate() also lacks the ability to retain the names given to the returned value. I've created an agg() function (pasted below) that is apparently backwards compatible (i.e. returns identical results as aggregate() if the function returns a single unnamed value), but is able to handle named and/or multiple return values. The code may be a little inefficient (there must be an easier way to set up the 'temp' data frame than to call aggregate and remove the final column), but I'm suggesting that something similar to this may be profitably used to replace aggregate entirely. #modified aggregate command, allowing for multiple/named output values agg=function(z,Ind,FUN,...){ FUN.out=by(z,Ind,FUN,...) num.cells=length(FUN.out) num.dv=length(FUN.out[[1]]) temp=aggregate(z,Ind,length) #dummy data frame temp=temp[,c(1:(length(temp)-1))] #remove last column from dummy frame for(i in 1:num.dv){ temp=cbind(temp,NA) n=names(FUN.out[[1]])[i] names(temp)[length(temp)]=ifelse(!is.null(n),n,ifelse(i==1,'x',paste ('x',i,sep=''))) for(j in 1:num.cells){ temp[j,length(temp)]=FUN.out[[j]][i] } } return(temp) } #create some factored data z=rnorm(100) # the DV A=rep(1:2,each=25,2) #one factor B=rep(1:2,each=50) #another factor Ind=list(A=A,B=B) #the factor list aggregate(z,Ind,mean) #show the means of each cell agg(z,Ind,mean) #should be identical to aggregate aggregate(z,Ind,summary) #returns an error agg(z,Ind,summary) #returns named columns #Make a function that returns multiple unnamed values summary2=function(x){ s=summary(x) names(s)=NULL return(s) } agg(z,Ind,summary2) #returns multiple columns, default names -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel