Quantcast
Channel: How to convert an atomic vector to a class of another vector - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by Roland for How to convert an atomic vector to a class of another...

This looks like an xy problem, but the following function should work in many cases:convertClass <- function(from, to){ stopifnot(is.atomic(c(unclass(to)))) if (is.factor(to)) return(factor(from))...

View Article



How to convert an atomic vector to a class of another vector

I'm trying to write a function that coerces an atomic vector to class of another vector, but it doesn't work very well...convertClass <- function(from, to){ # this is really ugly and fails in some...

View Article
Browsing all 2 articles
Browse latest View live




Latest Images