R studio List and Dataframes auto name completion not working anymore - r

Suddenly R Studio stopped auto completing my list and data frame contents when entering mylist$ then pressing Tab. The result message I get is
No matches
I tried that on very simple lists or data frames like:
simpledataset <- data.frame(a=rep(0,100),b=rep(1,100))
However, when I load the dataset Mtcars, it correctly shows the column names.
I reset %localappdata%\RStudio-Desktop by renaming it, but didn't change anything.
Any idea of what could be the cause of that?

This sounds like a bug in the autocompletion system that is occasionally triggered when certain packages are loaded, or the byte-compiler optimization setting is increased. You might try checking a few things:
What is the value of compiler::getCompilerOption("optimize")? Autocompletion is known to fail when this value is equal to 3 in the current RStudio release (v0.99.896). You can try running compiler::setCompilerOptions(optimize = 2) to resolve this.
What packages do you have loaded? You can try loading packages one-by-one to see which affects RStudio's ability to provide autocompletions.
Finally, there should be a fix for this in the preview version of RStudio -- you can try it out at https://www.rstudio.com/products/rstudio/download/preview/.

Go to Tools>Global Options... and set autocomplete there.

Related

Annoying RStudio Behavior in debugging

When I am in debug mode in a function and uses "CTRL + Enter" on an object/variable, R takes me back on line 1 of the function and prints the object variable to the console. Is this a bug or an expected behavior?
Another bug in debug mode:
- If there is a print(variable1) somewhere in the function, R will not only print to the console variable1 but also the remaining function code that comes after "print(variable1)"
Are there any ways of avoiding those behaviors of R Studio?
Thanks,
This may be worth reporting to rstudio directly as it may be a bug that was left over from a change of behavior in debug mode. I looked through the browser help file and didn't come across this behavior.
An rstudio article from April 2016 on debugging here, states that
Simply pressing Enter at the console will execute the current statement and move on to the next one. This is a convenient way to step through statements quickly.
Note that most of the commands listed in this section directly match with the behavior of browser.
However, I've been reading Hadley's Advanced R recently and came across the following in section 3.2.2:
There are two other slightly less useful commands that aren’t available in the toolbar:
* Enter: repeats the previous command. I find this too easy to activate accidentally, so I turn it off using options(browserNLdisabled = TRUE).
...
Since Advanced R was published in 2014, my thinking is that this is legacy behavior that you should report to the makers of rstudio, complete with a reproducible example.

"/content?title=....htm not found" error message

I'm trying to view my data in RStudio and I get the above strange message, what is that and how do I fix whatever problem there is? I can still work with the data, I just can't see it.
I haven't done anything special, it just "happened". I just keep trying View(df)... and now all of a sudden my data frame is an endless column of 1's, although the View window states, true enough, that df is "30 observations of 2 variables".
I also had this problem several times. For me it always helped to quit and restart RStudio. You might try this.
EDIT:
Normally when quitting RStudio without saving your workspace manually before, you should get a prompt asking you
Save workspace image to $pathToYourWorkspace ?
If this is not the case maybe u have no writing permission in your selected workspace folder. Be sure about that first. If you have the permission you could try saving your workspace manually by entering
save.image('$pathToYourWorkspace/.RData')
Can you try accessing your previous entered commands in the console by using arrow up key? Does it work?
Do you have a file called .Rhistory in your workspace?
If not check Options if u have it activated (Tools -> Global Options -> General) and then check 'Restore .RData into workspace at startup' and 'Always save history ...'
You could also check if u have the latest Version of RStudio installed.

How to make "buffered output" in R disabled by default?

When I work on the R console, I always want my results to be displayed instantly rather than buffered. Is there any method to turn buffered output off by default, so I don't need to press Ctrl + W every time I start the R console?
It definitely doesn't look like I'm the first one who encounters this, but surprisingly I can find nothing on this issue.
If you look in your R directory under etc, you should find a file called Rconsole, which contains a number of options that govern the behavior of the console. One of them is buffered = yes. Change yes to no and you should be all set.

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

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?
(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).
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.
I found a solution that worked for me in a closed RStudio Github issue. You can change the maximum number of columns displayed (say to 1000) using the following command:
rstudioapi::writeRStudioPreference("data_viewer_max_columns", 1000L)
You should be able to run this just once, and it will thereafter be saved to your settings file as the new default in every subsequent R session. Under my Linux system, these preferences are stored in ~/.config/rstudio/rstudio-prefs.json. The relevant line that the above command will add is:
"data_viewer_max_columns":1000
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].

View command in Eclipse/statET

R has a useful command ("View") that lets one see a table like a spreadsheet in a pop-up window. I used this command in the eclipse console while running statET and the spreadsheet popped up for a few milliseconds and then vanished.
To be specific, I have a matrix called "mat" and I typed
View(mat)
Does anyone know how to fix this?
In the Object Browser window in Eclipse, you should see a list of the R objects you have in memory (under .GlobalEnv), as well as packages you've loaded (like reshape2 or plyr).
If you right-click on an R object in the .GlobalEnv list, you'll see an option to Open in Data Viewer. Clicking this option opens the data in a spreadsheet format in the Editor window, which is useful for getting a quick view of a small data set, or a subset of a larger one.

Resources