Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there maximum number of characters permissible in rownames or colnames in R?

Tags:

r

My script generates row and column names with increasingly large number of characters.

Is there a maximum number of characters in a row or column name permissible for a R matrix?

like image 952
Ray Czaplewski Avatar asked Nov 02 '13 15:11

Ray Czaplewski


People also ask

What is the maximum character size for table or column name?

You're absolutely right: Table names are 30 characters maximum same as column names.

How long can variable names be in R?

name , "Names are limited to 10,000 bytes (and were to 256 bytes in versions of R before 2.13.

What is the difference between names and Colnames in R?

Not quite--the big difference is that colnames also works for matrices, whereas names does not (just dataframes). In addition, you can use names to set/get the names of vectors (and, for obvious reasons, you can't do this with colnames--the result is NULL for getting and an error for setting).

What is Colnames () in R?

colnames() method in R is used to rename and replace the column names of the data frame in R. The columns of the data frame can be renamed by specifying the new column names as a vector. The new name replaces the corresponding old name of the column in the data frame.


1 Answers

Row and column names are attributes of a data frame or matrix object. As such, they are only limited by the system resources available to R.

x <- data.frame(col = 0)
object.size(x)
# 680 bytes

# Huge name for a column
colnames(x)=paste(rep("x",10^8),collapse="")
object.size(x)
# 100000680 bytes
like image 98
Ryan Walker Avatar answered Sep 27 '22 21:09

Ryan Walker