Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rstudio autocomplete variables

Tags:

r

rstudio

I am new to both R and Rstudio. I like the autocompletion of functions, models and data.frames. My question concerns autocompletion of variables.

So lets say I load the well known iris data.

I can start typing "ir", click click tab and get the rest of the dataset to autocomplete.

I also know can get the names of the variables by various means such as names(iris). Which I can copy and paste.

Now, how can I do a good autocomplete with variables? I would like to be able to type "pet" and tab and it gives me the different possible variables options to autocomplete (like it does for functions).

Is something like that possible?

The only workaround I can see is type out the full dataset$variable name such as iris$ then tab, when then allows me to select iris$petalwitdth. But that it more typing and makes for some ugly code. I just want "petalwidth" to autocomplete.

Options? Suggestions?

like image 892
mpg Avatar asked Mar 05 '26 09:03

mpg


1 Answers

I think iris$P tab is preferable, but if you must, you can attach the dataset to the search path

attach(iris)

Then, P tab will auto complete

like image 102
GSee Avatar answered Mar 08 '26 03:03

GSee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!