Displaying 20 results from an estimated 6000 matches similar to: "warning message for setAs when using class AsIs"
2004 Sep 08
1
A couple of issues with colClasses/setAs
Consider this:
$ cat test.dat
1 a
2 b
Now, we want to read the 2nd column as a factor and ignore the first
(since it's just a sequential ID). We can't just put "factor" among
the colClasses (would have been nice), so let's try this instead
> setAs("character","factor",as.factor)
Arguments in definition changed from (x) to (from)
>
2009 Aug 05
1
S4 method dispatch: coercion of arguments with setAs defined
Hi list,
I've got a class B that contains a slot obj of class A. I'd like to be
able to call all the methods of class A directly on objects of class B
as if I had called the method on slot obj. This without overloading all
methods of class A to work on class B.
I don't define B as an extension of A, because I want class B to also
work with objects of classes that inherit from
2001 Aug 24
1
RFC: type conversion in read.table
Currently read.table is rather limited in its type conversion.
The algorithm is
0) Read as character
1) Try to convert to numeric. If that works, quit
2) Convert to factor unless !as.is.
I am thinking about adding more flexibility and more classes by the
following two changes.
A) Anticipating the arrival of classes for all R objects, add an
argument say `colClasses' that allows the user to
2008 Mar 17
1
setAs vs setIs
Hi the list
I am fighting with the twins setAs and setIs...
Here are some questions and comments (comments to myself but that migth
be wrong, it is why I am posting them)
1. Very surprising : using setIs define 'is', 'as<-' but not 'as' ???
2. Using setAs define 'as', 'as<-' but not 'is'...
What surprise me is that as<- can be define by
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc
2020 Oct 23
2
Change to I() in R 4.1
Hi there,
Is that change in R-devel intentional?
library(Matrix)
m <- as(matrix(c(0, 1)), "sparseMatrix")
isS4(m)
# [1] TRUE
x <- I(m)
# Warning message:
# In `class<-`(x, unique.default(c("AsIs", oldClass(x)))) :
# Setting class(x) to multiple strings ("AsIs", "dgCMatrix", ...);
result will no longer be an S4 object
2002 May 21
1
I() fails on objects of class POSIXct (PR#1587)
Although the documentation is somewhat sketchy, I() can be used to create
objects of class AsIs:
> I("a")
[1] "a"
attr(,"class")
[1] "AsIs" "character"
> I(4)
[1] 4
attr(,"class")
[1] "AsIs" "numeric"
> I(4 + 0i)
[1] 4+0i
attr(,"class")
[1] "AsIs" "complex"
>
This
2020 Oct 05
2
S4 - inheritance changed by order of setClassUnion and setAs()
Dear colleagues,
there is a behaviour with S4 (virtual) classes that I find very hard to understand: Depending on the position
of setAs(), the tree of inheritance changes.
This is my baseline example that defines the classes "grandma", "mother", "daughter" and a virtual
class "mr_x". For a new instance if "daughter", "mr_x" is betweeen
2004 Nov 26
1
Namespaces, coercion and setAs
I'm trying to resolve a small problem that has arisen from introducing a
NAMESPACE for the package SparseM. Prior to the namespace I had
a class "matrix.diag.csr" that consisted of diagonal sparse matrices.
It
was defined to have the same attributes as the matrix.csr class and
setAs
was used to define how to coerce integers and vectors into this form:
2003 Sep 28
1
infinite recursion during package installation with methods, setAs
I ran into a problem recently trying to update a package which uses S4
methods using a recent beta of R. I think I can reproduce it with a
simple example. I have package called `testpkg' in directory testpkg/.
In the R/ subdirectory of testpkg/ I have a file called testpkg.R which
contains the following two lines:
setClass("testpkg", representation(pts = "list"))
2019 Nov 17
2
Inappropriate class(o)[!inherits(o,"AsIs")] in get_all_vars
SVN?revision?77401?changes
????????x[isM]?<-?lapply(x[isM],?function(o)?`class<-`(o,?class(o)[class(o)?!=?"AsIs"]))
to
????????x[isM]?<-?lapply(x[isM],?function(o)?`class<-`(o,?class(o)[!inherits(o,"AsIs")]))
in?function?'get_all_vars'?in?src/library/stats/R/models.R?in?R?devel.
The?change?is?inappropriate.
2019 Nov 18
2
Inappropriate class(o)[!inherits(o,"AsIs")] in get_all_vars
>>>>> Martin Maechler
>>>>> on Mon, 18 Nov 2019 12:15:38 +0100 writes:
>>>>> suharto anggono--- via R-devel
>>>>> on Sun, 17 Nov 2019 10:34:31 +0000 writes:
>> SVN revision 77401 changes
>> x[isM] <- lapply(x[isM], function(o) `class<-`(o, class(o)[class(o) != "AsIs"]))
>> to
2002 Jul 15
1
Suppressing "creating new generic" and "expanding the signature" messages
Hi all,
I am building a R package which defines a class. I have overloaded methods
for this class using setMethod, and now, when I require my package, I get
diagnostic messages.
setMethod("[", signature(x = "portfolio"),
function(x, i, j, ...) {
# ...
})
> require(portfolio)
Loading required package: portfolio
[... loading other required packages ...]
Creating a new
2024 Jul 12
1
xftrm is more than 100x slower for AsIs than for character vectors
Good evening,
I recently have observed slow merges when combining multiple data frames
derived from DataFrame and base::data.frame. I observed that the index
column of intermediate tables was of class <AsIs> (automatically
converted from character). The problem occurred mainly when using the
sorted = T option in base::merge.
This can be traced to xtfrm.AsIs being more than 100 times slower
2024 Jul 14
2
xftrm is more than 100x slower for AsIs than for character vectors
? Fri, 12 Jul 2024 17:35:19 +0200
Hilmar Berger via R-devel <r-devel at r-project.org> ?????:
> This can be finally traced to base::rank() (called from
> xtfrm.default), where I found that
>
> "NB: rank is not itself generic but xtfrm is, and rank(xtfrm(x), ....)
> will have the desired result if there is a xtfrm method. Otherwise,
> rank will make use of ==, >,
2020 Mar 29
2
is.vector could handle AsIs class better
Dear R-devel,
AsIs class seems to be well handled by `typeof` and `mode` function.
Those two functions are being referred when explaining `is.vector`
behaviour in manual. Yet `is.vector` does not seem to be handling AsIs
class the same way.
is.vector(1L)
#[1] TRUE
is.vector(I(1L))
#[1] FALSE
Is there any reason behind this behaviour?
Could we have it supported so AsIs class is ignored when
2020 Mar 30
1
is.vector could handle AsIs class better
Thank you Gabriel,
Agree, although I think that could be relaxed in this single case and
AsIs class could be ignored.
Best,
Jan
On Sun, Mar 29, 2020 at 7:09 PM Gabriel Becker <gabembecker at gmail.com> wrote:
>
> Jan,
>
> I believe it's because it has "a non-NULL attribute other than names" as per the documentation. In this case its class of "AsIs".
>
2003 Sep 08
0
setAs() and namespaces
An example sent by Ross Ihaka points out a non-obvious step needed to
export the results of setAs().
The as() mechanism can't use ordinary method dispatch because the second
argument is the name of a class, not an object from the class. So it
uses a "helper" function, coerce(), and sets methods for that function.
Therefore, if you want to export the results of setAs(), at the
2020 Oct 30
2
Change to I() in R 4.1
Hi Martin,
On 10/26/20 04:52, Martin Maechler wrote:
>>
>> Hi there,
>> Is that change in R-devel intentional?
>>
>> library(Matrix)
>> m <- as(matrix(c(0, 1)), "sparseMatrix")
>>
>> isS4(m)
>> # [1] TRUE
>>
>> x <- I(m)
>> # Warning message:
>> # In `class<-`(x,