Displaying 15 results from an estimated 15 matches for "row_names_info".
2023 Nov 14
1
data.frame weirdness
They differ in whether the row names are "automatic":
> .row_names_info(a1)
[1] -3
> .row_names_info(a2)
[1] 3
Best,
-Deepayan
On Tue, 14 Nov 2023 at 08:23, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
>
> What is going on here? In the lines ending in #### the inputs and outputs
> are identical yet one gives a warning and the other does...
2023 Nov 14
1
data.frame weirdness
In that case identical should be FALSE but it is TRUE
identical(a1, a2)
## [1] TRUE
On Tue, Nov 14, 2023 at 8:58?AM Deepayan Sarkar
<deepayan.sarkar at gmail.com> wrote:
>
> They differ in whether the row names are "automatic":
>
> > .row_names_info(a1)
> [1] -3
> > .row_names_info(a2)
> [1] 3
>
> Best,
> -Deepayan
>
> On Tue, 14 Nov 2023 at 08:23, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
> >
> > What is going on here? In the lines ending in #### the inputs and outputs
> >...
2008 Jul 01
1
[.data.frame speedup
...xtMethod("[")
cols <- names(y)
if (!is.null(cols) && any(is.na(cols)))
stop("undefined columns selected")
if (any(duplicated(cols)))
names(y) <- make.unique(cols)
return(structure(y, class = oldClass(x),
row.names = .row_names_info(x, 0L)))
}
if (missing(i)) {
if (missing(j) && drop && length(x) == 1L)
return(.subset2(x, 1L))
y <- if (missing(j))
x
else .subset(x, j)
if (drop && length(y) == 1L)
return(.subset2(y, 1L))
cols <- names(y)
if (any(is.na(c...
2023 Nov 14
1
data.frame weirdness
...should be FALSE but it is TRUE
>
> identical(a1, a2)
> ## [1] TRUE
>
>
> On Tue, Nov 14, 2023 at 8:58?AM Deepayan Sarkar
> <deepayan.sarkar at gmail.com> wrote:
> >
> > They differ in whether the row names are "automatic":
> >
> > > .row_names_info(a1)
> > [1] -3
> > > .row_names_info(a2)
> > [1] 3
> >
> > Best,
> > -Deepayan
> >
> > On Tue, 14 Nov 2023 at 08:23, Gabor Grothendieck
> > <ggrothendieck at gmail.com> wrote:
> > >
> > > What is going on here? In the...
2023 Nov 14
1
data.frame weirdness
...entical(a1, a2)
> > ## [1] TRUE
> >
> >
> > On Tue, Nov 14, 2023 at 8:58?AM Deepayan Sarkar
> > <deepayan.sarkar at gmail.com> wrote:
> > >
> > > They differ in whether the row names are "automatic":
> > >
> > > > .row_names_info(a1)
> > > [1] -3
> > > > .row_names_info(a2)
> > > [1] 3
> > >
> > > Best,
> > > -Deepayan
> > >
> > > On Tue, 14 Nov 2023 at 08:23, Gabor Grothendieck
> > > <ggrothendieck at gmail.com> wrote:
> > >...
2009 Sep 15
2
why is nrow() so slow?
dear R wizards: here is the strange question for the day. It seems to me
that nrow() is very slow. Let me explain what I mean:
ds= data.frame( NA, x=rnorm(10000) ) ## a sample data set
> system.time( { for (i in 1:10000) NA } ) ## doing nothing takes
virtually no time
user system elapsed
0.000 0.000 0.001
## this is something that should take time; we need to add 10,000
2009 May 26
1
Bug in "$<-.data.frame" yields corrupt data frame (PR#13724)
...me" )
A single object matching '$<-.data.frame' was found It was found in the
following places
package:base
registered S3 method for $<- from namespace base
namespace:base
with value
function (x, i, value)
{
cl <- oldClass(x)
class(x) <- NULL
nrows <- .row_names_info(x, 2L)
if (!is.null(value)) {
N <- NROW(value)
if (N > nrows)
stop(gettextf("replacement has %d rows, data has %d",
N, nrows), domain = NA)
if (N < nrows && N > 0L)
if (nrows%%N == 0L && len...
2023 Nov 14
1
data.frame weirdness
What is going on here? In the lines ending in #### the inputs and outputs
are identical yet one gives a warning and the other does not.
a1 <- `rownames<-`(anscombe[1:3, ], NULL)
a2 <- anscombe[1:3, ]
ix <- 5:8
# input arguments to #### are identical in both cases
identical(stack(a1[ix]), stack(a2[ix]))
## [1] TRUE
identical(a1[-ix], a2[-ix])
## [1] TRUE
res1 <-
2010 Dec 07
3
How to find out if a data frame has automatic row names?
Hi all,
I just stumbled across the difference between explicit and 'automatic'
row names for data frames. Is there a quick way to find out if a data
frame has automatic row names or not? Of course I know this for data
frames that I create myself, but what if a function needs to extract
this information for an argument?
The following example shows that this property is not easily
2009 Mar 29
0
Another incorrect behaviour of [.data.frame (PR#13629)
...matching) and d as the argument 'i' (because of subsequent positional argument
matching). When [.data.frame calls NextMethod('['), a list is returned, and
then [.data.frame wraps the list into a structure as follows:
return(structure(y, class = oldClass(x),
row.names = .row_names_info(x, 0L)))
(src/library/base/r/dataframe.R:531-532) since x is 1:2 and oldClass(1:2) is
NULL, the structure is a list and not a data frame, and thus the final result.
The result is clearly incorrect wrt. the documentation:
- there should be no dimension dropping when only one index is given (ev...
2014 Nov 10
1
subscripting a data.frame (without changing row order) changes internal row.names
Dear R-devel,
Can anyone help me to understand this? It seems that subscripting the
rows of a data.frame without actually changing their order, somehow
changes an internal representation of row.names that is revealed by e.g.
dput/dump/serialize
I have read the docs and inspected the (R) code for data.frame,
rownames, row.names and dput without enlightenment.
df=data.frame(a=1:10, b=1)
2023 Oct 25
4
Bug in print for data frames?
Hi! I came across this unexpected behaviour in R. First I thought it was a bug in the assignment operator <- but now I think it's maybe a bug in the way data frames are being printed. What do you think?
Using R 4.3.1:
> x <- data.frame(A = 1, B = 2, C = 3)
> y <- data.frame(A = 1)
> x
A B C
1 1 2 3
> x$B <- y$A # works as expected
> x
A B C
1 1 1 3
> x$C
2007 Aug 03
4
FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)
Hi all,
What are current methods people use in R to identify
mis-spelled column names when selecting columns
from a data frame?
Alice Johnson recently tackled this issue
(see [BioC] posting below).
Due to a mis-spelled column name ("FileName"
instead of "Filename") which produced no warning,
Alice spent a fair amount of time tracking down
this bug. With my fumbling fingers
2007 Apr 24
0
R 2.5.0 is released
...ble(), write.table() and allies have been moved to package
utils.
o rgb() now accepts the red, green and blue components in a
single matrix or data frame.
o New utility function RShowDoc() in package 'utils' to find and
display manuals and other documentation files.
o New .row_names_info() utility function finds the number of rows
efficiently for data frames; consequently, dim.data.frame()
has become very fast for large data frames with 'automatic'
row names.
o RSiteSearch() now also allows to search postings of the 'R-devel'
mailing list.
o screeplot(...
2007 Apr 24
0
R 2.5.0 is released
...ble(), write.table() and allies have been moved to package
utils.
o rgb() now accepts the red, green and blue components in a
single matrix or data frame.
o New utility function RShowDoc() in package 'utils' to find and
display manuals and other documentation files.
o New .row_names_info() utility function finds the number of rows
efficiently for data frames; consequently, dim.data.frame()
has become very fast for large data frames with 'automatic'
row names.
o RSiteSearch() now also allows to search postings of the 'R-devel'
mailing list.
o screeplot(...