display all column of a df in r

To display all columns of a dataframe in R, you can use the options function to increase the max.print value. This value specifies the maximum number of printed output lines, so increasing it will show more columns of the dataframe.

main.r
# create a sample dataframe
df <- data.frame(a = c(1,2,3), b = c("one", "two", "three"), c = c(TRUE, FALSE, TRUE))

# display all columns
options(max.print = Inf)
df
166 chars
7 lines

This will output:

main.r
  a    b     c
1 1  one  TRUE
2 2  two FALSE
3 3 three  TRUE
61 chars
5 lines

Note: Setting the max.print value to Inf may not be practical for large dataframes, as it can consume a lot of memory and slow down your R session. In those cases, you may want to selectively choose which columns to display or use other data manipulation functions like subset or dplyr to manipulate your data.

gistlibby LogSnag