similar to: using initialize or using a constructor function

Displaying 20 results from an estimated 10000 matches similar to: "using initialize or using a constructor function"

2011 Apr 20
3
Make as.factor an S3 generic?
as.factor / as.ordered is not written as a generic. This differs from as.numeric, as.matrix, and other as.*. The following seems to address this and does not break make check-all. FWIW, the patch is against r55563, because with r55564 I see /home/mtmorgan/src/R-devel/src/main/dounzip.c:75:15: error: storage size of ?dt? isn?t known /home/mtmorgan/src/R-devel/src/main/dounzip.c:88:5: warning:
2009 Jul 09
1
How to: initialize, setValidity, copy-constructor
Hello list, I'm having troubles setting up a basic calss hierarchy with S4. Here is a simplified schema of what I'd like to do: - Two classes: A and B that extends A - Ensure that the slots added by B are consistent with the slots of A - Let A initialize itself (I'm not supposed to know the internal cooking of A) - By default set the slots of B based on the slots that A initialized
2010 Feb 02
1
S4 setClass / initialize misunderstanding
Hi, I recently ran into this problem. I couldn't find any mention of it in the setClass documentation. setClass("Foo", representation(file = "character")) setMethod("initialize", "Foo", function(.Object, file) { print(file) }) setClass("Bar", contains = "Foo") And the error: Error in print(file) : argument "file" is
2011 Apr 20
2
Package Name Not Found Warning
Hello, I've got a DESCRIPTION file with a the first line: Package: Repitools But, when I run R CMD INSTALL Repitools I get: * installing *source* package Repitools ... ** R ** data ** inst ** preparing package for lazy loading Warning in FUN(X[[1L]], ...) : Created a package name, "2011-04-20 09:05:40", when none found ** help *** installing help indices ** building package
2013 Feb 05
1
S4 Classes and Initialize methods
Hello, I am trying to improve my skill on S4 classes. But there's something strange (to me) happening with "initialize" methods. This is probably a normal behaviour... but... something is unclear in my mind I declare two classes, namely "A", and "B", which has a slot of type A. The class "A" has an initialize method. What I do not understand is that
2012 Jan 10
1
Can "prototype" and "initialize" coexist?
Folks, My object oriented background is in Java and C++. I am a novice to using S4/object-oriented coding in R but not to R. Below is an example that I found that I have expanded on. I am not getting how "prototype" and "initialize" work together, if at all. Here is output from a short "session" > setClass("xx", +
2015 May 10
2
S4 method dispatch sometimes leads to incorrect when object loaded from file?
Loading an S4 object from a file without first loading the library sometimes (?, the example below and actual example involves a virtual base class and the show generic) leads to incorrect dispatch (to the base class method). The attached package reproduces the problem. It has setClass("A") setClass("B", contains="A") setMethod("show", "A",
2015 May 12
1
S4 method dispatch sometimes leads to incorrect when object loaded from file?
>>>>> Martin Morgan <mtmorgan at fredhutch.org> >>>>> on Mon, 11 May 2015 10:18:07 -0700 writes: > On 05/10/2015 08:19 AM, Martin Morgan wrote: >> Loading an S4 object from a file without first loading the library sometimes (?, >> the example below and actual example involves a virtual base class and the show >> generic)
2015 Aug 25
3
Issues with libcurl + HTTP status codes (eg. 403, 404)
Hi Martin, Indeed it does (and I should have confirmed myself with R-patched and R-devel before posting...) Thanks, and sorry for the noise. Kevin On Tue, Aug 25, 2015, 13:11 Martin Morgan <mtmorgan at fredhutch.org> wrote: > On 08/25/2015 12:54 PM, Kevin Ushey wrote: > > Hi all, > > > > The following fails for me (on OS X, although I imagine it's the same >
2009 Jul 29
3
Object equality for S4 objects
To test two environments for object equality (Lisp EQ), I can use 'identity': > e1 <- environment(local(function()x)) > e2 <- environment(local(function()x)) > identical(e1,e2) # compares object identity [1] FALSE > identical(as.list(e1),as.list(e2)) # compares values as name->value mapping [1] TRUE # (is there a
2011 Oct 31
1
Question about copying reference objects using the initialize method
Dears, I have a question about copying reference objects using the initialize method. 1) If the latter has no arguments, there is no problem to copy an object. myClass = setRefClass("myClass", fields = list(value = "numeric") ) myClass$methods(initialize = function(...){ ? value <<- 1 ? callSuper(...) }) newObject = myClass$new() newObject$value = 2 copyObject =
2010 Mar 31
1
You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package
Hi Martin, It is really a 'PATH' problem. After adding C:\Program Files\Graphviz2.20\bin to the 'PATH' environment variable, the Rgraphviz package can be loaded without any error messages. Sorry that I ONLY set my 'PATH' environment variable correctly for R but not for Graphviz. Thank you and Duncan so much for your great help. Howard On Tue Mar 30 18:12:54
2011 Apr 13
5
for loop performance
Dear list I am running some simulations in R involving reading in several hundred datasets, performing some statistics and outputting those statistics to file. I have noticed that it seems that the time it takes to process of a dataset (or, say, a set of 100 datasets) seems to take longer as the simulation progresses. Has anyone else noticed this? I am curious to know if this has to do with how R
2015 Jul 07
3
List S3 methods and defining packages
Hi, from the man page ?methods, I expected to be able to build pairs (class,package) for a given S3 method, e.g., print, using attr(methods(print), 'info'). However all the methods, except the ones defined in base or S4 methods, get the 'from' value "registered S3method for print", instead of the actual package name (see below for the first rows). Is this normal
2011 Apr 06
4
problem with all/all.equal
Hi! In a function, I may have an instance in which all elements are equal. > x <- rep(1,5) > > x [1] 1 1 1 1 1 > identical(x) Error in .Internal(identical(x, y, num.eq, single.NA, attrib.as.set)) : 'y' is missing > all.equal(x) Error in is.expression(x) : 'x' is missing > I don't care what particular value it is, I just want to know if they are all
2011 Sep 10
3
Very slow using S4 classes
Hi everybody! I'm creating an object of a S4 class that has two slots: ListExamples, which is a list, and idx, which is an integer (as the code below). Then, I read a data.frame file with 10000 (ten thousands) of lines and 10 columns, do some pre-processing and, basically, I store each line as an element of a list in the slot ListExamples of the S4 object. However, many operations after this
2012 Aug 21
1
parLapply fails to detect default cluster?
invoking parLapply without a cluster fails to find a previously registered cluster > library(parallel) > setDefaultCluster(makePSOCKcluster(2)) > parLapply(X=1:2, fun=function(...) {}) Error in cut.default(i, breaks) : invalid number of intervals This is because in parLapply length(cl) is determined before defaultCluster(cl) is called. By inspection, this appears to be true of
2010 Oct 24
1
R-devel CMD build fails when vignette present
If I try to build a package with a vignette R CMD build Biobase I see * checking for file 'Biobase/DESCRIPTION' ... OK * preparing 'Biobase': * checking DESCRIPTION meta-information ... OK * cleaning src * installing the package to re-build vignettes * creating vignettes ... OK * cleaning src Error in setwd(pkgname) : cannot change working directory Execution halted This is
2011 Oct 25
1
Windows download.file sometimes pauses / truncates large files
With C:\Users\User>R --version R version 2.14.0 RC (2011-10-23 r57410) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-mingw32/x64 (64-bit) running download.file('http://www.ebi.ac.uk/microarray-as/ae/files/E-TABM-25/E-TABM-25.raw.1.zip', tempfile()) sometimes gets 52% (according to the dialog box) of the way through, and then
2011 Dec 15
1
R CMD check fails to warn about undocumented classes and methods
In > R.version.string [1] "R Under development (unstable) (2011-12-15 r57901)" PkgA promotes 'unique' to a generic and exports that DESCRIPTION: Imports: methods R/f.R: setGeneric("unique") NAMESPACE: export(unique) and PkgB creates and exports a method on unique DESCRIPTION Imports: methods, PkgA R/f.R: setClass("B",