similar to: Bug: as.matrix.data.frame() treats numeric vectors with "levels" attribute as factors

Displaying 20 results from an estimated 10000 matches similar to: "Bug: as.matrix.data.frame() treats numeric vectors with "levels" attribute as factors"

2007 Mar 29
0
(PR#9578) rbind.data.frame reacts on levels without
In your data frames, 'y' is a category and the following comment in the code makes clear this is deliberate. if( !is.null(levels(xj)) ) { all.levs[[j]] <- levels(xj) facCol[j] <- TRUE # turn categories into factors } else facCol[j] <- is.factor(xj) The behaviour is compatible with S apart from the comment in the R help
2004 May 24
1
as.matrix.data.frame() in R 1.9.0 converts to character when it should (?) convert to numeric
Conversion of a data frame to a matrix using as.matrix() when a column of the data frame is POSIXt and all other columns are numeric has changed in R 1.9.0 from R 1.8.1. The new behavior issues a warning message and converts to a character matrix. In R 1.8.1, such an object was converted to a numeric matrix. Here is an example. #### R 1.9.0 #### > foo <- data.frame(
2015 Dec 08
0
For integer vectors, `as(x, "numeric")` has no effect.
>>>>> John Chambers <jmc at r-project.org> >>>>> on Mon, 7 Dec 2015 16:05:59 -0800 writes: > 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"
2006 Dec 02
0
fixup for debug package and R2.4.0
A number of users have spotted a terminal problem with the 'debug' package under R2.4.0, along the lines of > mtrace(x) > x() Error in attr(value, "row.names") <- rlabs : row names must be 'character' or 'integer', not 'double' This arose from a bug in 'rbind.data.frame' in R2.4.0 itself. The bug is fixed in R2.4.0 patched, so the
2007 Mar 21
1
rbind.data.frame reacts on levels without factor (PR#9578)
Full_Name: Lutz Prechelt Version: 2.4.1 OS: Windows XP Submission from: (NULL) (160.45.111.67) I stack a number of data.frames using rbind. Each of these dataframes has a column 'authorname', which is a factor and a column author = unclass(authorname) as piecewise pseudonyms. When using rbind to stack these dataframes, R warns about invalid factor levels and inserts all NAs in the author
2015 Dec 26
0
[Bioc-devel] For integer vectors, `as(x, "numeric")` has no effect.
Or maybe the "right" concept is that "numeric" is a virtual class with 3 subclasses: "complex", "double", and "integer". Anyway it's probably too late for implementing the "right" concept so it doesn't really matter. Thanks Martin for offering to fix the as(1L, "numeric") bug. Very much appreciated. I guess that means
2015 Dec 11
0
For integer vectors, `as(x, "numeric")` has no effect.
Somehow, the most obvious fixes are always back-incompatible these days. The example intrigued me, so I looked into it a bit (should have been doing something else, but ....) You're right that this is the proverbial thin-edge-of-the-wedge. The problem is in setDataPart(), which will be called whenever a class extends one of the vector types. It does as(value, dataClass) The key point is
2007 Jan 12
0
Minor logical bug in rbind.data.frame ?
When attempting to merge 3 data frames, one of which has fewer columns than the others, rbind.data.frame correctly refuses to perform the bind. However, the error message given is a bit obscure due to a logical bug in the match.names() internal function to rbind.data.frame. Illustration: ## Three data frames with same column variable names: > foo <- data.frame(v1 = c('a',
2019 May 21
0
anyNA() performance on vectors of POSIXct
>>>>> Harvey Smith >>>>> on Wed, 1 May 2019 03:20:55 -0400 writes: > Inside of the anyNA() function, it will use the legacy any(is.na()) code if > x is an OBJECT(). If x is a vector of POSIXct, it will be an OBJECT(), but > it is also TYPEOF(x) == REALSXP. Therefore, it will skip the faster > ITERATE_BY_REGION, which is typically 5x
2019 May 22
0
print.<strorageMode>() not called when autoprinting
>>>>> William Dunlap >>>>> on Tue, 21 May 2019 12:11:45 -0700 writes: > Letting a user supply the autoprint function would be nice also. In a way > you can already do that, using addTaskCallback(), but that doesn't let you > suppress the standard autoprinting. > Having the default autoprinting do its own style of method dispatch
2015 Dec 19
0
For integer vectors, `as(x, "numeric")` has no effect.
>>>>> Martin Maechler <maechler at stat.math.ethz.ch> >>>>> on Sat, 12 Dec 2015 10:32:51 +0100 writes: >>>>> John Chambers <jmc at r-project.org> >>>>> on Fri, 11 Dec 2015 10:11:05 -0800 writes: >> Somehow, the most obvious fixes are always back-incompatible these days. >> The example intrigued
2019 May 01
3
anyNA() performance on vectors of POSIXct
Inside of the anyNA() function, it will use the legacy any(is.na()) code if x is an OBJECT(). If x is a vector of POSIXct, it will be an OBJECT(), but it is also TYPEOF(x) == REALSXP. Therefore, it will skip the faster ITERATE_BY_REGION, which is typically 5x faster in my testing. Is the OBJECT() condition really necessary, or could it be moved after the switch() for the individual TYPEOF(x)
2002 Oct 09
1
problems with missing values created by conversion using as.matri (PR#2130)
> version _ platform sparc-sun-solaris2.8 arch sparc os solaris2.8 system sparc, solaris2.8 status major 1 minor 6.0 year 2002 month 10 day 01 language R
2009 Feb 05
2
non-numeric argument to binary operator
Hi, I compute the value of xi*xj by "for" loops, this how I try: > x1 <- c(1:3) > x2 <- c(2:4) ### to compute x1*x2 > (paste("x", 1, sep = ""))*(paste("x", 2, sep = "")) Error in (paste("x", 1, sep = "")) * (paste("x", 2, sep = "")) : non-numeric argument to binary operator > All
2010 Apr 26
1
Error in pf(q, df1, df2, lower.tail, log.p) : Non-numeric argument to mathematical function
inputfille snpid indid genotype gvariable probeid gene geneexpression rs1040480 CHB_NA18524 C/T 2 GI_19743926-I PTPRT 5.850586 rs1040480 CHB_NA18526 C/C 1 GI_19743926-I PTPRT 6.028641 rs1040480 CHB_NA18529 C/C 3 GI_19743926-I PTPRT 5.944392 rs1040481 CHB_NA18532 C/C 1 GI_19743926-I PTPRT 5.938578 rs1040481 CHB_NA18537 C/C 2 GI_19743926-I PTPRT 5.874439 rs1040481 CHB_NA18540 C/C 3 GI_19743926-I
2007 May 01
1
Levels attribute in integer columns created by model.frame()
The following is evidence of what is surely an undesirable feature. The issue is the handling, in calls to model.frame(), of an explanatory variable that has been derived as an unclassed factor. (Ross Darnell drew this to my attention.) ## Data are slightly modified from p.191 of MASS > worms <- data.frame(sex=gl(2,6), Dose=factor(rep(2^(0:5),2)), +
2020 Feb 16
1
Why is any() only defined for a numeric and not logical data.frame?
Hello, I recently stumbled on an unusual behaviour of any() and all() and have been adviced from StackOverflow to share it here [1]. df1 <- data.frame(A=TRUE, B=FALSE) df2 <- data.frame(A=1, B=0) > any(df1) Error in FUN(X[[i]], ...): only defined on a data frame with all numeric variables > any(df2) [1] TRUE Warning message: In any(c(1,
2009 Oct 14
1
using mapply to avoid loops
Hello, I would like to use mapply to avoid using a loop but for some reason, I can't seem to get it to work. I've included copies of my code below. The first set of code uses a loop (and it works fine), and the second set of code attempts to use mapply but I get a "subscript out of bounds" error. Any guidance would be greatly appreciated. Xj, Yj, and Wj are also lists, and s2,
2014 Sep 08
2
Problem with order() and I()
I have found that order() fails in a rather arcane circumstance, as in this example: > foo <- I( c('x','\265g') ) > order(foo) Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed > foo <-c('x','\265g') > order(foo) [1] 1 2 > sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-apple-darwin13.1.0 (64-bit)
2016 Apr 29
0
selecting columns from a data frame or data table by type, ie, numeric, integer
> dt1[ vapply(dt1, FUN=is.numeric, FUN.VALUE=NA) ] a c 1 1 1.1 2 2 1.0 ... 10 10 0.2 Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Apr 29, 2016 at 9:19 AM, Carl Sutton via R-help < r-help at r-project.org> wrote: > Good morning RGuru's > I have a data frame of 575 columns. I want to extract only those columns > that are numeric(double) or integer to do