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?
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).
(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:
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:
I just ran into this issue also. As suggested by gung above, the utils::View()
function is helpful as a workaround for browsing all available columns in a data frame, whereas Rstudio still defaults to only the first 100 available columns when using the View()
function.
The workaround is very useful for identifying the column names for creating a subset from an existing data frame. However, it doesn't provide a quick column enumeration that the RStudio View()
function allows. It's been a few years since the original post in 2013, but this limitation in the RStudio environment seems to still be effective in present-day 2017.
Try fix()
. It loads all your columns and rows. The only problem is that it might take long to load large data frames.
I'm not sure if this has been mentioned before but I found this interesting post from 2012:
https://support.rstudio.com/hc/en-us/community/posts/200669267-view-more-than-first-100-columns-.
This indexing allows you to at least check the other columns and if they even exist.
So just use: datafile[row-row, column-column].