Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list output truncated - How to expand listed variables with str() in R

I have a data.frame df with 600+ variables. I'm writing a function that automates the creation of columns and need to visually check them once.

The str function provides a good summary:

str(df) 'data.frame':   29 obs. of  602 variables:  $ uniqueSessionsIni: POSIXct, format: "2015-01-05 15:00:00" "2015-01-05 16:00:00" "2015-01-05 17:00:00" ...  $ uniqueSessionsEnd: POSIXct, format: "2015-01-05 15:59:00" "2015-01-05 16:59:00" "2015-01-05 17:59:00" ...  $ m0p0             : POSIXct, format: "2015-01-05 15:00:00" "2015-01-05 15:00:00" "2015-01-05 15:00:00" ...  $ m1p0             : POSIXct, format: "2015-01-05 15:01:00" "2015-01-05 15:01:00" "2015-01-05 15:01:00" ...  $ m2p0             : POSIXct, format: "2015-01-05 15:02:00" "2015-01-05 15:02:00" "2015-01-05 15:02:00" ...     

and it goes on...
but truncates the output, as below:

$ m33p1            : POSIXct, format: "2015-01-05 15:34:00" "2015-01-05 15:34:00" "2015-01-05 15:34:00" ... $ m34p1            : POSIXct, format: "2015-01-05 15:35:00" "2015-01-05 15:35:00" "2015-01-05 15:35:00" ... $ m35p1            : POSIXct, format: "2015-01-05 15:36:00" "2015-01-05 15:36:00" "2015-01-05 15:36:00" ... $ m36p1            : POSIXct, format: "2015-01-05 15:37:00" "2015-01-05 15:37:00" "2015-01-05 15:37:00" ... [list output truncated] 

How can I display the full list of 602 variables?

like image 723
jpinelo Avatar asked Mar 06 '15 08:03

jpinelo


People also ask

What does str () do in R?

str() function in R Language is used for compactly displaying the internal structure of a R object. It can display even the internal structure of large lists which are nested. It provides one liner output for the basic R objects letting the user know about the object and its constituents.

What is truncated in R?

September 9, 2021 February 4, 2021 by Krunal Lathiya. The trunc() method in R is truncate, which rounds to the nearest integer in the direction of 0. The trunc() function truncates the values in the decimal places.


2 Answers

You can use the argument list.len:

str(df, list.len=ncol(df)) 

and if you want to print more observations you could set the argument vec.len, also have a look at ?str for documentation of all arguments.

like image 93
user1981275 Avatar answered Oct 05 '22 18:10

user1981275


By using argument list.len one can choose the number of variables in the data frame to list. There are two options:

a) You choose the number of variables that you want to list;

str(df, list.len = 602) # in this case I'm listing 602 variables. 

b) You choose to list the total number of variables of the data frame (as mentioned by user1981275);

str(df, list.len = ncol(df)) 

Check R help for more info

> ?str 
like image 35
jpinelo Avatar answered Oct 05 '22 17:10

jpinelo