similar to: Change value of a slot of an S4 object within a method.

Displaying 20 results from an estimated 10000 matches similar to: "Change value of a slot of an S4 object within a method."

2010 Aug 26
1
Passing arguments between S4 methods fails within a function:bug? example with raster package.
Dear all, This problem came up initially while debugging a function, but it seems to be a more general problem of R. I hope I'm wrong, but I can't find another explanation. Let me illustrate with the raster package. For an object "RasterLayer" (which inherits from Raster), there is a method xyValues defined with the signature
2010 Feb 26
2
New methods for generic functions show and print : some visible with ls(), some not
Dear all, I'm trying to understand the S4 way of object-oriented programming, but I still can't grasp completely what R is doing. I have a class definition for a class called PM10Meteo, and I set a initializer function. next, I include a show method and a print method as shown below. setClass( Class="PM10Meteo",...) # end setClass setMethod
2018 May 24
2
Creating S3 methods for S4 classes (coming from r-package-devel)
Dear all, I asked this question on r-package-devel but Martin Maechler pointed out this was more suited on R-devel. So here it goes: per the manual, one should create and register both the S3 and a S4 method if one needs a method for an S4 class for a function using S3 dispatching. This is cumbersome, and not very optimal. I was wondering if there's a better way to do this. Currently I
2010 Jul 02
2
S4 classes and debugging - Is there a summary?
Dear all, I'm getting more and more frustrated with the whole S4 thing and I'm looking for a more advanced summary on how to deal with them. Often I get error messages that don't make sense at all, or the code is not doing what I think it would do. Far too often inspecting the code requires me to go to the source, which doesn't really help in easily finding the bit of code
2018 May 24
1
Creating S3 methods for S4 classes (coming from r-package-devel)
On Thu, May 24, 2018 at 6:20 PM, Michael Lawrence <lawrence.michael at gene.com > wrote: > You only have to make an S4 method if there is already an S4 generic. > If there is just an S3 generic, then just define S3 methods on it. I was refering to the recommendations in ?Methods_for_S3 ( https://stat.ethz.ch/R-manual/R-devel/library/methods/html/Methods_for_S3.html). : "Two
2017 Mar 28
2
`[` not recognized as a primitive in certain cases.
Dear, I have noticed this problem while looking at the following question on Stackoverflow : http://stackoverflow.com/questions/42894213/s4-class-subset-inheritance-with-additional-arguments While going through callNextMethod, I've noticed the following odd behaviour: mc <- call("[",iris,2,"Species") mc[[1]] ## `[` is.primitive(`[`) ## [1] TRUE
2017 Mar 28
2
`[` not recognized as a primitive in certain cases.
?typeof? is your friend here: > typeof(`[`) [1] "special" > typeof(mc[[1]]) [1] "symbol" > typeof(mc2[[1]]) [1] "special" so mc[[1]] is a symbol, and thus not a primitive. - Lukas > On 28 Mar 2017, at 14:46, Michael Lawrence <lawrence.michael at gene.com> wrote: > > There is a difference between the symbol and the function (primitive >
2018 May 24
0
Creating S3 methods for S4 classes (coming from r-package-devel)
You only have to make an S4 method if there is already an S4 generic. If there is just an S3 generic, then just define S3 methods on it. I think we should stay away from defining S4 generics when there is no good reason for them. Good reasons include multiple dispatch, or a non-default signature. Neither of those apply in this case. Michael On Thu, May 24, 2018 at 6:39 AM, Joris Meys
2015 Apr 01
1
evaluation in transform versus within
On 01/04/2015 2:33 PM, Joris Meys wrote: > Thank you for the insights. I understood as much from the code, but I > can't really see how this can cause a problem when using with() or > within() within a package or a function. The environments behave like > I would expect, as does the evaluation of the arguments. The second > argument is supposed to be an expression, so I
2015 Apr 01
2
evaluation in transform versus within
Dear list members, I'm a bit confused about the evaluation of expressions using with() or within() versus subset() and transform(). I always teach my students to use with() and within() because of the warning mentioned in the helppages of subset() and transform(). Both functions use nonstandard evaluation and are to be used only interactively. I've never seen that warning on the help
2017 May 31
1
stats::line() does not produce correct Tukey line when n mod 6 is 2 or 3
> On 31 May 2017, at 16:40 , Joris Meys <jorismeys at gmail.com> wrote: > > And with "equally spaced" I obviously meant "of equal size". It's getting > too hot in the office here... We have a fair amount of cool westerly wind up here that I could transfer to you via WWTP (Wind and Weather Transport Protocol). If you open up a sufficiently large pipe,
2015 Apr 01
0
evaluation in transform versus within
Thank you for the insights. I understood as much from the code, but I can't really see how this can cause a problem when using with() or within() within a package or a function. The environments behave like I would expect, as does the evaluation of the arguments. The second argument is supposed to be an expression, so I would expect that expression to be evaluated in the data frame first. I
2010 Dec 21
2
Warning message when items of Hmisc are masked by loading a package.
I've noticed that I get a warning message every time a package masks some functions from Hmisc. The warning message says : Warning message: In identical(get(., i), get(., lib.pos)) : ignoring non-pairlist attributes This happens with eg: library(plyr) library(xtable) I think I've seen this passing by before, but I'm not sure any more. Just thought I'd mention it. Cheers Joris
2014 Apr 19
1
lag() not returning a time series object
Dear all, Before I file this as a bug, I wanted to check if I didn't miss something. The help page of lag() says that the function returns a time series object. It actually does return something that looks like a ts object (the attribute tsp is set). But when using a vector, the class "ts" is not added to the result: > avec <- 1:10 > lag(avec) [1] 1 2 3 4 5 6 7 8
2011 Feb 15
1
Using rasterImage on a CairoWin device prevents adding further elements to device?
I was pointed to the Cairo package for plotting PNG images on a device. I've been playing around with it, but found that after I use the rasterImage function, I can't add anything any more to the device, eg : img <- readPNG(system.file("img", "Rlogo.png", package="png")) r = as.raster(img[,,1:3]) r[img[,,4] == 0] = "white" CairoWin()
2018 Jan 31
1
Best practices in developing package: From a single file
I fully agree with Joris and Hadley on roxygen2. Additionally: I wrote and published my first package before roxygen (or roxygen2) was available. I found editing .Rd extremely terse (especially when code is updated). For example, the fact that there are no spaces allowed between } and { in \param{}{} has hurt my brain quite a few times, especially since R CMD check did not give any useful error
2017 May 18
2
[R] R-3.4.0 fails test
> On 18 May 2017, at 13:47 , Joris Meys <jorismeys at gmail.com> wrote: > > Correction: Also dlt uses the default timezone, but POSIXlt is not recalculated whereas POSIXct is. Reason for that is the different way values are stored (hours, minutes, seconds as opposed to minutes from origin, as explained in my previous mail) > I would suspect that there is something more subtle
2010 Mar 30
2
weighted.median function from package R.basic
Dear all, I want to apply a weighted median on a huge dataset, and I remember a function from the package R.basic that could do this using an internal sorting algorithm qsort. This speeded things up quite a bit. Alas, I can't find that package anywhere anymore. There is a weighted.median function in the package limma too, but I didn't use that before. Anybody who knows what happened to
2017 May 23
1
help pages base R not rendered correctly?
Hi Duncan, that explains, thank you. If nobody finds the time to fix that, I might give it a shot myself this summer. Barbeque is overrated. Cheers Joris On Tue, May 23, 2017 at 3:10 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > On 23/05/2017 8:39 AM, Joris Meys wrote: > >> Hi all, >> >> Don't know if this is a known issue, but I couldn't find
2014 Oct 03
2
How I() works in a formula
Dear all, I'm updating a package regarding a new type of models, and I'm looking to extend the formula interface with two functions (L() and R() ) for construction of these models. I want to use as much of the formula interface as possible, and hoped to do something similarly to I(). I know the I() function does nothing more than add the class "AsIs". I've been browsing the