Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R View() does not display all columns of data frame

Tags:

r

rstudio

I have been adding columns to a data frame and using View() to check that it did what I expected. I have repeated lines of code along the lines of:

x$p <- 3 * x$a x$q <- sqrt(x$b + x$c) View(x) 

This worked fine until the number of columns exceeded 100 (there are 47,000 rows). When I added another two columns, dim(x) shows 102 columns, names(x) shows 102 names, summary(x) shows summaries of all the expected columns. However, View(x) only displays the first 100 columns and doesn't display the last two added columns.

If I try View(x[,-(1:10)]) the most recently added columns are displayed.

I can't see any mention in the View documentation of a limit on the number of columns. Can anyone explain what is happening here?

like image 604
Ross Gayler Avatar asked Oct 13 '13 04:10

Ross Gayler


People also ask

How do I see all columns in a dataset in R?

You can have View() open in one of the quadrants or in a separate notepad-ish window. It opens in the quadrant where my source code is displayed on my machine at work, and in another window on my machine at home. In the latter case, it displays >1k rows & >100 columns (I just checked).

Why is view function not working in R?

View function in R is not working. 2 with RStudio Version 0.98. 1091, then the View() function from the “utils” package is not supported. So to solve this, you should upgrade your RStudio. So, often you can solve this type of error by updating your packages related to R.

How do I view columns in a Dataframe in R?

To access a specific column in a dataframe by name, you use the $ operator in the form df$name where df is the name of the dataframe, and name is the name of the column you are interested in. This operation will then return the column you want as a vector.


2 Answers

(Updated)

You can have View() open in one of the quadrants or in a separate notepad-ish window. It opens in the quadrant where my source code is displayed on my machine at work, and in another window on my machine at home. In the latter case, it displays >1k rows & >100 columns (I just checked).

I'm not sure how you can get this to change permanently, IIRC when I updated RStudio and ran View() the first time, a window popped up and asked me to choose what program I wanted to use to display the file. In one case I selected RStudio, and in the other case, I selected notepad. In both cases, the 'use this program by default from now on' radio button was selected; I have never seen this window since. If you can switch to displaying with notepad, you should be able to get out of this problem. However, short of a permanent change, you can get View() to display your data in a separate window using the code utils::View(). This approach works on my machine at work. Here is what it looks like:

enter image description here

Note that I am running RStudio version 0.97.248 on a Windows 7 machine.

Here is what it looks like on my home machine where it comes up in a new window automatically:

enter image description here

like image 169
gung - Reinstate Monica Avatar answered Oct 04 '22 16:10

gung - Reinstate Monica


I also see this problem with x <- matrix(1:200,nrow=1); View(x) in RStudio, but not in vanilla R. It is a known limitation and they're working on it. You can contact the devs on their forum to give your feedback (and have done so, I see).

like image 36
Frank Avatar answered Oct 04 '22 15:10

Frank