Displaying 20 results from an estimated 514 matches for "unclassed".
2005 Apr 02
4
factor to numeric in data.frame
Dear All,
Assume I have a data.frame that contains also factors and I would like to
get another data.frame containing the factors as numeric vectors, to apply
functions like sapply(..., median) on them.
I read the warning concerning as.numeric or unclass, but in my case this
makes sense, because the factor levels are properly ordered.
I can do it, if I write for each single column
2017 Mar 07
0
length(unclass(x)) without unclass(x)?
> Henrik Bengtsson:
>
> I'm looking for a way to get the length of an object 'x' as given by
> base data type without dispatching on class.
The performance improvement you're looking for is implemented in the
latest version of pqR (pqR-2016-10-24, see pqR-project.org), along
with corresponding improvements in several other circumstances where
unclass(x) does not
2003 Aug 16
4
unclass
Have I been sleeping in class?
rw1071 from CRAN, windows XP
incidencia is made by a call to tapply
> class(incidencia)
[1] "array"
> incidencia <- unclass(incidencia)
> class(incidencia)
[1] "array"
Kjetil Halvorsen
2012 Dec 21
2
Why can't I "unclass" an array?
In a real example I was trying to remove the class from the result of table, just because
it was to be used as a building block for other things and a simple integer vector seemed
likely to be most efficient.
I'm puzzled as to why unclass doesn't work.
> zed <- table(1:5)
> class(zed)
[1] "table"
> class(unclass(zed))
[1] "array"
>
2012 Dec 21
2
Why can't I "unclass" an array?
In a real example I was trying to remove the class from the result of table, just because
it was to be used as a building block for other things and a simple integer vector seemed
likely to be most efficient.
I'm puzzled as to why unclass doesn't work.
> zed <- table(1:5)
> class(zed)
[1] "table"
> class(unclass(zed))
[1] "array"
>
2018 Sep 03
0
True length - length(unclass(x)) - without having to call unclass()?
Regarding the discussion of getting length(unclass(x)) without an
unclassed version of x being created...
There are already no copies done for length(unclass(x)) in pqR
(current version of 2017-06-09 at pqR-project.org, as well as the
soon-to-be-release new version). This is part of a more general
facility for avoiding copies from unclass in other circumstances as
well -...
2017 Mar 05
0
length(unclass(x)) without unclass(x)?
I'm looking for a way to get the length of an object 'x' as given by
base data type without dispatching on class. Something analogous to
how .subset()/.subset2(), e.g. a .length() function. I know that I
can do length(unclass(x)), but that will trigger the creation of a new
object unclass(x) which I want to avoid because 'x' might be very
large.
Here's a dummy example
2018 Sep 05
0
True length - length(unclass(x)) - without having to call unclass()?
...sounds unlikely. Unless you have a strong reason to believe it is the
case I would just use length(unclass(x)).
If the copying is really a problem, I would think about why the
underlying vector length is needed at R level - whether you really need
to know the length without actually having the unclassed vector anyway
for something else, so whether you are not paying for the copy anyway.
Or, from the other end, if you need to do more without copying, and it
is possible without breaking the value semantics, then you might need to
switch to C anyway and for a bigger piece of code.
If it were sti...
2018 Aug 24
5
True length - length(unclass(x)) - without having to call unclass()?
Is there a low-level function that returns the length of an object 'x'
- the length that for instance .subset(x) and .subset2(x) see? An
obvious candidate would be to use:
.length <- function(x) length(unclass(x))
However, I'm concerned that calling unclass(x) may trigger an
expensive copy internally in some cases. Is that concern unfounded?
Thxs,
Henrik
2018 Sep 01
0
True length - length(unclass(x)) - without having to call unclass()?
...<- function(x) {
cls <- class(x)
# setattr() does not make a copy, but modifies by reference
data.table::setattr(x, "class", NULL)
# get the length
len <- base::length(x)
# re-set original classes
data.table::setattr(x, "class", cls)
# return the unclassed length
len
}
# to check that we do not make unwanted changes
orig_class <- class(x)
# check that the address in RAM does not change
a1 <- data.table::address(x)
# 'unclassed' length
stopifnot(.length(x) == 2L)
# check that address is the same
stopifnot(a1 == data.table::address...
2018 Sep 10
0
True length - length(unclass(x)) - without having to call unclass()?
...g reason to believe it is the
>> case I would just use length(unclass(x)).
>>
>> If the copying is really a problem, I would think about why the
>> underlying vector length is needed at R level - whether you really need
>> to know the length without actually having the unclassed vector anyway
>> for something else, so whether you are not paying for the copy anyway.
>> Or, from the other end, if you need to do more without copying, and it
>> is possible without breaking the value semantics, then you might need to
>> switch to C anyway and for a bigge...
2008 Feb 16
3
Arithmetic bug? (found when use POSIXct) (PR#10776)
Full_Name: Bo Zhou
Version: 2.6.1 (2007-11-26)
OS: Windows XP
Submission from: (NULL) (207.237.54.242)
Hi,
I found an arithmetic problem when I'm doing something with POSIXct
The code to reproduce it is as follows (This is the recommended way of finding
out time zone difference on R News 2004-1 Page 32 URL
http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf)
a=Sys.time()
2018 Sep 03
0
True length - length(unclass(x)) - without having to call unclass()?
...etattr() does not make a copy, but modifies by reference
>> data.table::setattr(x, "class", NULL)
>> # get the length
>> len <- base::length(x)
>> # re-set original classes
>> data.table::setattr(x, "class", cls)
>> # return the unclassed length
>> len
>> }
>>
>> # to check that we do not make unwanted changes
>> orig_class <- class(x)
>>
>> # check that the address in RAM does not change
>> a1 <- data.table::address(x)
>>
>> # 'unclassed' length
>> st...
2018 Sep 05
4
True length - length(unclass(x)) - without having to call unclass()?
...ess you have a strong reason to believe it is the
> case I would just use length(unclass(x)).
>
> If the copying is really a problem, I would think about why the
> underlying vector length is needed at R level - whether you really need
> to know the length without actually having the unclassed vector anyway
> for something else, so whether you are not paying for the copy anyway.
> Or, from the other end, if you need to do more without copying, and it
> is possible without breaking the value semantics, then you might need to
> switch to C anyway and for a bigger piece of code....
2018 Sep 03
2
True length - length(unclass(x)) - without having to call unclass()?
...lt;- class(x)
> ? # setattr() does not make a copy, but modifies by reference
> ? data.table::setattr(x, "class", NULL)
> ? # get the length
> ? len <- base::length(x)
> ? # re-set original classes
> ? data.table::setattr(x, "class", cls)
> ? # return the unclassed length
> ? len
> }
>
> # to check that we do not make unwanted changes
> orig_class <- class(x)
>
> # check that the address in RAM does not change
> a1 <- data.table::address(x)
>
> # 'unclassed' length
> stopifnot(.length(x) == 2L)
>
> # check...
2005 Apr 07
2
axis colors in pairs plot
The following command produces red axis line in a pairs
plot:
pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
pch = "+", col = c("red", "green3", "blue")[unclass(iris$Species)])
Trying to fool pairs in the following way produces the
same plot as above:
pairs(iris[1:4], main = "Anderson's Iris Data -- 3
2018 Sep 05
0
True length - length(unclass(x)) - without having to call unclass()?
More generally, I think one of the issues is that R is not yet able to
decrement a reference count (or mark a 'shared' data object as
'unshared' after it knows only one binding to it exists). This means
passing variables to R closures will mark that object as shared:
x <- list()
.Internal(inspect(x)) # NAM(1)
identity(x)
.Internal(inspect(x)) # NAM(3)
I think
2005 May 08
3
Light-weight data.frame class: was: how to add method to .Primitive function
Hi,
Encouraged by a tip from Simon Urbanek I tried to use the S3 machinery
to write a faster version of the data.frame class.
This quickly hits a snag: the "[.default"(x, i) for some reason cares
about the dimensionality of x.
In the end there is a full transcript of my R session. It includes the
motivation for writing the class and the problems I have encountered.
As a result I see
2006 Dec 15
1
Switching labels on a factor
Hi All,
I'm perplexed by the way the unclass function displays a factor whose
labels have been swapped with the relevel function. I realize it won't
affect any results and that the relevel did nothing useful in this
particular case. I'm just doing it to learn ways to manipulate factors.
The display of unclass leaves me feeling that the relevel had failed.
I've checked three books
2014 Apr 10
3
Unión de subconjuntos procedentes de bucles
Buenas tardes a todos los participantes del foro.
Me dirijo a vosotros porque estoy atascado con una duda de programación respecto al data frame:
> dd # Data frame de 5 variables, leído de un archivo txt
id sexo nacim origen final
1 1 0 02/09/1955 01/04/1985 01/02/2014
2 2 1 29/10/1951 15/08/1996 01/05/2009
3 3 0 30/10/1942 02/08/2000 01/02/2014
4 4 1