r - Why does combining two `data.frame` objects using the `data.frame` function cut off a long variable name? -
i have noticed if try combine 2 different data.frame
objects larger data.frame
using data.frame
function, variable names cut off (i.e. see output of names(db)
code below.
i avoid situation combining variables using data.table
function instead.
my question is:
why data.frame
command cut off variable names? may quite simple question, , can solved using as.data.frame
function on data.table
object convert data.frame
, curious why variable names cut off in first place if use data.frame
function. have tried looking insight using in r, , on google, have found no success far. seeking answer more me better understand how r, , data.table
, data.frame
works (as relatively new r user, having switched stata).
thanks in advance!
> <- data.frame(rnorm(100)) > b <- data.frame(rnorm(100)) > names(a) <- "thisisaveryverylongvariablename-mean()" > names(b) <- "thisisanotherveryverylongvariablename-std()" > db <- data.frame(a, b) > names(db) [1] "thisisaveryverylongvariablename.mean.." "thisisanotherveryverylongvariablename.std.." > names(c(a, b)) [1] "thisisaveryverylongvariablename-mean()" "thisisanotherveryverylongvariablename-std()" > db2 <- data.table(a, b) > names(db2) [1] "thisisaveryverylongvariablename-mean()" "thisisanotherveryverylongvariablename-std()"
the variable names not cut-off; simply, made more "compatible" r environment. can override check.names=false
argument data.frame()
:
a <- data.frame(rnorm(100)) b <- data.frame(rnorm(100)) names(a) <- "thisisaveryverylongvariablename-mean()" names(b) <- "thisisanotherveryverylongvariablename-std()" db <- data.frame(a, b, check.names = false) names(db) # [1] "thisisaveryverylongvariablename-mean()" "thisisanotherveryverylongvariablename-std()"
Comments
Post a Comment