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?
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).
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.
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.
(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 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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With