search for: coerc

Displaying 20 results from an estimated 2011 matches for "coerc".

Did you mean: coerce
2008 Apr 09
1
coerce methods and inheritance
Hi, It doesn't seem that the dispatching algo is finding my coerce method under some circumstances. Let's say I have 2 classes, A and AA and that AA is just a direct extension of A with no additional slots: setClass("A", representation(ii="integer")) setClass("AA", contains="A") I can define a method for coercin...
2012 Jul 30
1
fractal package
...ied your example in the following site http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=fractal:corrDim  > library(fractal) > png(filename="corrDim_%03d_med.png", width=480, height=480) > beam.d2 <- corrDim(beamchaos, olag=10, dim=10, res=4) Warning messages: 1: In any(diff(x)) : coercing argument of type 'double' to logical 2: In any(diff(x)) : coercing argument of type 'double' to logical 3: In any(diff(x)) : coercing argument of type 'double' to logical 4: In any(diff(x)) : coercing argument of type 'double' to logical 5: In any(diff(x)) : coer...
2007 Jul 16
1
S4 coerce
(I am not sure if this is a bug or a request for a more understandable warning, or possible something obvious I should be posting on r-help.) I am trying to coerce an new class object to be a DBIConnection and it does not work the way I think it should: R version 2.5.1 (2007-06-27) ... > require("RMySQL") # or require("RSQLite") Loading required package: RMySQL Loading required package: DBI [1] TRUE > m <- dbDriver("MySQ...
2011 Jan 11
1
how to coerce part of each column of a matrix to a vector and merge them
Hello Suppose I have a matrix mat=(1:16,2) [,1] [,2] [,3] [,4] [1,] 1 5 9 13 [2,] 2 6 10 14 [3,] 3 7 11 15 [4,] 4 8 12 16 there is a vector end=c(2,3,1,3) #coerce the 1st 2 numbers of the 1st column to a vector [1] 1 2 #coerce the 1st 3 numbers of the 2nd column and append it to the previous vector [1] 1 2 5 6 7 #coerce the 1st number of the 3rd column and append it to the previous vector [1] 1 2 5 6 7 9 #coerce the 1st 3 numbers of the 4th...
2015 Dec 08
2
For integer vectors, `as(x, "numeric")` has no effect.
We do need an explicit method here, I think. The issue is that as() uses methods for the generic function coerce() but cannot use inheritance in the usual way (if it did, you would be immediately back with no change, since "integer" inherits from "numeric"). Copying in the general method for coercing to "numeric" as an explicit method for "integer" gives the expected...
2003 Aug 24
2
setClass question
I would like to add a class to the SparseM package. I have a class "matrix.csr" that describes a matrix in compressed sparse row format, now I would like a class matrix.diag.csr that describes such objects when they happen to be diagonal. The idea is that matrix.diag.csr objects should behave (later in life) exactly like matrix.csr objects, the distinction is only needed in order to
2004 May 13
0
using trace() on S4 coerce method
I'm trying to use trace() on an S4 coerce method, but get the error Error in bindingIsLocked(what, whereM) : no binding for "coerce" What am I doing wrong? Example code follows. (I've googled the R mailing lists for "trace coerce" and "trace bindingisLocked" without finding anything relevant. Perh...
2008 Oct 14
1
library MICE warning message
...pmm","logreg","logreg"),m=5)  for a variable with no missing data, a numeric one and two variables with binary data. I got the following message: There were 37 warnings (use warnings() to see them) > warnings() Warning messages: 1: In any(predictorMatrix[j, ]) ... : coercing argument of type 'double' to logical 2: In any(predictorMatrix[, j]) ... : coercing argument of type 'double' to logical 3: In any(predictorMatrix[j, ]) ... : coercing argument of type 'double' to logical 4: In any(predictorMatrix[j, ]) ... : coercing argument of type ...
2004 Jun 14
4
Coercing a dataframe column to datetime
I am trying to coerce a data frame column from character to datetime using strptime but keep getting an error because the length of the coerced object is always 9. What am I doing wrong here: ................................................................. > ds <- cbind(1:2, c("02/27/92 23:03:20",...
2012 Oct 01
1
False positive note about ambiguous dispatch
...setAs("ANY", "A", function(from) new("A", stuff=as.complex(from))) > as(6, "A") An object of class "A" Slot "stuff": [1] 6+0i > as(6L, "A") Note: Method with signature ?numeric#A? chosen for function ?coerce?, target signature ?integer#A?. "ANY#A" would also be valid An object of class "A" Slot "stuff": [1] 6+0i First thing is that the note is in contradiction with the output of selectMethod (seems like it's the method with signature "ANY#A"...
2000 Sep 19
3
coerce mode list?
...0 2 1 0 0 0 1 3 0 0 0 0 1 4 1 0 0 0 0 5 0 1 1 0 0 > Xbar1 <- mean(X1) > S1 <- (t(X1 - Xbar1)) %*% W1 %*% (X1 - Xbar1) Error in as.double: Cannot coerce mode list to double: .Data = list(.. Dumped > S1 <- (t(as.double(X1 - Xbar1))) %*% W1 %*% (as.double(X1 - Xbar1)) Error in as.double: Cannot coerce mode list to double: .Data = list(.. Dumped I don't understand the error message. Can anyone help? Many thanks in advance....
2006 Jun 05
2
grep() and factors
Hi all, Based upon an offlist communication this morning, I am somewhat confused (more than I usually am on most Monday mornings...) about the use of grep() with factors as the 'x' argument. The argument guidance in ?grep indicates: x, text a character vector where matches are sought. Coerced to character if possible. and in the Details section: Arguments which should be character strings or character vectors are coerced to character if possible. The wording of both would seem to reasonably lead to the conclusion that a factor could be coerced to a character vector by the...
2011 Feb 07
2
as.list(subclassed function) -> cannot coerce type 'closure' to vector of type 'list'
...first argument is called "link". is.family <- function(object) is.function(object) && identical(names(as.list(object))[1], "link") It threw an error when applied to SSfol > is.family(SSfol) Error in as.vector(x, "list") : cannot coerce type 'closure' to vector of type 'list' but works when I unclass SSfol > is.family(unclass(SSfol)) [1] FALSE It looks like as.list fails on any function that is assigned a class: > as.list(function(x)x+1) $x [[2]] x + 1 > as.list(structure(fu...
2008 Apr 23
1
S4 default for coercing
Something has changed in the S4 default for coercing. Am I now suppose to use setAs, or is there something else I should do to make this work: R version 2.7.0 (2008-04-22) .... > require("methods") > setClassUnion("OptionalPOSIXct", c("POSIXct", "NULL")) [1] "OptionalPOSIXct" >...
2006 Apr 09
2
type converters not being saved to workspace
Any one can explain why this happens or any work arounds? > setClass('foo') [1] "foo" > setAs('foo', 'character', function(from) from) > showMethods('coerce') Function "coerce": from = "ANY", to = "array" from = "ANY", to = "call" from = "ANY", to = "character" from = "ANY", to = "complex" from = "ANY", to = "environment" from = "ANY...
2006 Apr 09
2
type converters not being saved to workspace
Any one can explain why this happens or any work arounds? > setClass('foo') [1] "foo" > setAs('foo', 'character', function(from) from) > showMethods('coerce') Function "coerce": from = "ANY", to = "array" from = "ANY", to = "call" from = "ANY", to = "character" from = "ANY", to = "complex" from = "ANY", to = "environment" from = "ANY...
2012 Apr 01
1
Error in xy.coords(x, NULL, log = log) : (list) object cannot be coerced to type 'double'
Hi there, When I run the code below I get the error Error in xy.coords(x, NULL, log = log) :(list) object cannot be coerced to type 'double' Any tips how I can resolve this? > > library("waveslim") > > vols=read.csv(file="C:/Users/ocuk/My Documents/Abs Vol.csv", header=TRUE, > sep=",") > x<-c(vols[,1]) > #x > #data(ibm) > av.la8 <- mra(x, &quot...
2010 Mar 31
1
as(1:4, "numeric") versus as.numeric(1:4, "numeric")
Hi, > class(as(1:4, "numeric")) [1] "integer" Surprising but an explanation could be that an integer vector being a particular case of numeric vector, this coercion has nothing to do because 1:4 is already numeric. And indeed: > is.numeric(1:4) [1] TRUE > is.numeric(as(1:4, "numeric")) [1] TRUE However, 'as(1:4, "numeric")' is inconsistent with > class(as.numeric(1:4)) [1] "numeric" And, e...
2010 Feb 20
1
coerce (list) object to type 'double'
...ly new to R, and I have problem here. I searched around, but did not get a solution. I have a numetrix matrix (20 by 25) saved in .csv. I read it as >sx<-read.csv("sx.csv",header=F) Then I try to convert it to numeric using >sx<-as.numeric(sx) Error: (list) object cannot be coerced to type 'double' The class of sx is "data.frame". I tried to unlist it as, s<-unlist(sx), but when I look at the dimension, > dim(s) NULL Can anyone tell me how should I load my data as a numeric matrix rather than "data.frame", or how to convert the data.f...
2008 Aug 27
1
S4 coercion
I am extending a DBI connection by setClass("TSPostgreSQLConnection", contains=c("PostgreSQLConnection","TSdbOptions")) but the first time I use this I am getting a warning when it tries to coerce the TSPostgreSQLConnection to a PostgreSQLConnection. After the first use the warning stops, but the first warning is causing me problems when I do automatic checks and set my tests to stop on warnings. (I think there should be a correct way to do this that does not produce a warning.) I c...