Displaying 7 results from an estimated 7 matches for "set_row_nam".
Did you mean:
set_row_names
2013 Oct 30
2
Huge performance difference between implicit and explicit print
...below? I see the difference in both Rstudio
and in a terminal.
# Construct large df as quickly as possible
dummy <- 1:18e6
df <- lapply(1:10, function(x) dummy)
names(df) <- letters[1:10]
class(df) <- c("myobj", "data.frame")
attr(df, "row.names") <- .set_row_names(18e6)
print.myobj <- function(x, ...) {
print.data.frame(head(x, 2))
}
start <- proc.time(); df; flush.console(); proc.time() - start
# user system elapsed
# 0.408 0.557 0.965
start <- proc.time(); print(df); flush.console(); proc.time() - start
# user system elapsed
# 0.019...
2009 Mar 31
1
as.data.frame peculiarities
The documentation of as.data.frame is not explicit about how it generates
column names for the simple vector case, but it seems to use the character
form of the quoted argument, e.g.
names(as.data.frame(1:3))
[1] "1:3"
But there is a strange case:
names(as.data.frame(c("a")))
[1] "if (stringsAsFactors) factor(x) else x"
I feel fairly comfortable calling this a
2017 Dec 01
1
Bug is as.matrix.data.frame with nested data.frame
Converting a data.frame with a nested data.frame to a matrix fails:
x <- structure(list(a = data.frame(letters)),
class = "data.frame",
row.names = .set_row_names(26))
as.matrix(x)
#> Error in ncol(xj) : object 'xj' not found
The offending code is here, in the definition of as.matrix.data.frame
(source/base/all.R):
for (j in pseq) {
if (inherits(X[[j]], "data.frame") && ncol(xj) > 1L)
X[[j]] &l...
2019 Mar 12
3
as.data.frame.table() does not recognize default.stringsAsFactors()
...row.names) || length(row.names) != nrows)
if (length(collabs) == ncols)
names(value) <- collabs
else if (!optional)
names(value) <- paste0("V", ic)
class(value) <- "data.frame"
if (autoRN)
attr(value, "row.names") <- .set_row_names(nrows)
else .rowNamesDF(value, make.names = make.names) <- row.names
value
}
<bytecode: 0x29995c0>
<environment: namespace:base>
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: d...
2019 Mar 14
0
as.data.frame.table() does not recognize default.stringsAsFactors()
...es) != nrows)
> if (length(collabs) == ncols)
> names(value) <- collabs
> else if (!optional)
> names(value) <- paste0("V", ic)
> class(value) <- "data.frame"
> if (autoRN)
> attr(value, "row.names") <- .set_row_names(nrows)
> else .rowNamesDF(value, make.names = make.names) <- row.names
> value
> }
> <bytecode: 0x29995c0>
> <environment: namespace:base>
>
>
>> sessionInfo()
> R version 3.5.2 (2018-12-20)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Runn...
2009 Jun 25
2
stringsAsFactors has no impact in expand.grid()?
Hi
I have the feeling, that the argument stringsAsFactors has no impact in the
function expand.grid:
a <- c("PR", "NC", "A2", "BS")
b <- c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)
class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
[1] "factor"
class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
[1] "factor"
Also, when
2012 Jan 15
0
patching ?merge to allow the user to keep the order of one of the two data.frame objects merged
...names(y) <- nm.y
res <- cbind(x, y)
if (sort)
res <- res[if (all.x || all.y)
do.call("order", x[, seq_len(l.b), drop = FALSE])
else sort.list(bx[m$xi]), , drop = FALSE]
}
attr(res, "row.names") <- .set_row_names(nrow(res))
if(!missing(keep_order) && any(keep_order == c(1,2))) return(order.by.id...
and.remove.it(res))
res
}
#############################
########## Example
#############################
if(F) # example
{
x <- data.frame(
ref = c( 'Ref1', 'Re...