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?
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
Related
In order to create the exam sheets without solution, everything works fine with exams2nops (apart from the logo which is not taken for some reason). I can add the name of the institution, change the title, and setup a non-English language and the date. But if I want to create examsheets with the solutions, then, if I understand correctly, I cannot use anymore exams2nops, but I have to use exams2pdf with template="solution" which does not take into account the institution, the date, the language, nor the title.
Any help?
You are correct that exams2nops() does not provide a version of the PDF with the {solution} environment and the complete answer text. The nops_eval() only provides a HTML report with the correct boxes that needed to be checked.
So to produce a PDF as desired you can run exams2pdf(...) or exams2pdf(..., type = "solution") after setting the same random seed that you set before running exams2nops(). If you want to modify anything like layout/logo/language/etc. in exams2pdf() you have full flexibility but need to do the work yourself. That is you need to come up with a LaTeX template file that looks the way you want. As a starting point you can take solution.tex from the package. The easiest way to get all templates shipped with the package is to run exams_skeleton() and then look at the templates folder.
Background info: exams2nops() also just calls exams2pdf() internally after setting up a suitable LaTeX template file based on the arguments specified by the user.
Sublime text has a feature that allows you to highlight multiple identical selections to rename variables quickly. It is initiated with Ctrl+D on your keyboard. Most importantly it is context aware. If I want to rename the variable is to xy, it won't, for instance, rename this to thxy.
How do I get Atom to recognize scope? If I Ctrl+D the same as in Sublime it does not differentiate between is and this.
Highlight the first two letters in this code chunk below (ie 'is') and press Ctrl+D. It's jumps to the 'is' in this.
is
this is really cool
code
this is really cool
code
My answer is valid for JavaScript, for which I had the same question as you did.
I installed two more packages in atom:
https://atom.io/packages/refactor
https://atom.io/packages/js-refactor
The first one is the core package i think and the second one is javascript-specific. It worked after installing and restarting atom one time.
For you this package alone should do: https://atom.io/packages/cpp-refactor
For the purpose of uniformity in my code, I repeatedly type four hashes followed by a tab, like this (#### ). Is there a way to create a shortcut key-combination in R/Rstudio where such a string can be defined?
Although it doesn't answer your question, it might still be helpful for what you are trying to do.
You can organize your code in RStudio using "sections". A typical section looks like this:
# Some Section -------------------------
These can be manually entered (like the code chunk above, and with a few other variations) or you can use the convenient shortcut, Ctrl + Shift + R.
One great result of using these sections is that you can navigate to a particular section by its name, as shown in the screenshot below:
I am calling gvisMotionChart from the R package googleVis and I would like to set the colorvar parameter to "Unique colours". I tried colorvar="Unique colours" but it doesn't work for me.
I would also like to set it to select=All by default, although I am not sure if this option can be passed on right now.
Any ideas?
You should pass a list of options to gvisMotionChart command, like this
..., options=list(state='{"colorOption":"_UNIQUE_COLOR"};')
I don't know if there is an option for selecting all items. I usually select a couple of them, using iconKeySettings in the state definition, like this:
"iconKeySettings":[{"key":{"dim0":"actual"}},{"key":{"dim0":"baseline"}}]
Does Rstudio have a mechanism to configure snippets of code, like Geany for example? For faster writing whole sections of user predefined frequent code.
It is not exactly the same as TAB completion already built in rstudio.
Example by mimicking geany snippets
While snippet definition is like line below:
fun = %cursor% <- function(x, ...)\s{\n\n}\n
the usage is like this:
fun<TAB> (like bash style completion)
# will end up in following insertion:
<- function(x, ...) {
}
so the user can then faster write the code by using her own snippets definition. And user can define ANY snippet of any size for completion by TAB.
It is not the Rstudio extract cmd, nieder Rstudio existing TAB context browser.
Code snippets are available in RStudio version 0.99.
https://support.rstudio.com/hc/en-us/articles/204463668-Code-Snippets
The "Extract Function" feature in RStudio may be what you're looking for. Scroll down to the Extract Function section and accompanying screenshot on this page of rstudio.com's documentation: http://www.rstudio.com/ide/docs/using/source
The text of the section reads, "RStudio can analyze a selection of code from within the source editor and automatically convert it into a re-usable function. Any 'free' variables within the selection (objects that are referenced but not created within the selection) are converted into function arguments."
Also see this screenshot: http://www.rstudio.com/images/screenshots/rstudio-code-transform.png
I do not know of such functionality. However, if you want to quickly want to implement functionality with small changes you could also achieve this using functions.
Ok, your question is now clear to me. To my knowledge, Rstudio currently does not have this kind of functionality. You could, however, post a request on their forum for this feature. They respond quite actively to these kinds of requests, so you could give it a try.