Questions tagged [rstudio]
RStudio is an IDE for the R statistical programming language. DO NOT use this tag for general R programming problems, just use the R tag. ONLY use for RStudio-specific questions.
rstudio
7,924
questions
318
votes
10
answers
583k
views
Update R using RStudio
How can I update R via RStudio?
286
votes
16
answers
698k
views
Change R default library path using .libPaths in Rprofile.site fails to work
I am running R on Windows, not as an administrator. When I install a package, the following command doesn't work:
> install.packages("zoo")
Installing package(s) into ‘C:/Program Files/R/R-2.15.2/...
239
votes
4
answers
272k
views
R - Markdown avoiding package loading messages
I have been using Knitr via R-Studio, and think it is pretty neat. I have a minor issue though. When I source a file in an R-Chunk, the knitr output includes external comments as follows:
+ FALSE ...
216
votes
9
answers
89k
views
Difference between R MarkDown and R NoteBook
I am trying to understand at a high level what the differences between R Markdown and R NoteBook. I know they are interrelated but I would like to figure out how they are related. My understanding is ...
125
votes
19
answers
82k
views
rJava load error in RStudio/R after "upgrading" to OSX Yosemite
I recently "upgraded" from OSX Mountain Lion to Yosemite and from R 3.1.3 to 3.2. Immediately after the upgrade, when I opened R or RStudio I got a pop-up message saying that I needed to install Java ...
114
votes
6
answers
77k
views
Rstudio rmarkdown: both portrait and landscape layout in a single PDF
I wonder how to use rmarkdown to generate a pdf which has both portrait and landscape layout in the same document. If there is a pure rmarkdown option that would be even better than using latex.
Here'...
114
votes
5
answers
140k
views
ggplot plots in scripts do not display in Rstudio
I have a strange issue with Rstudio: If a script calls ggplot2 functions to display a plot, then using Source to run the script does not produce the plots. If I select the whole script with Ctrl+A, ...
105
votes
6
answers
105k
views
Auto-format R code in RStudio
Is there any possibilities for auto-formatting code in RStudio?
I found this, but it is not connected with RStudio.
Also it is desirable that it be customizable formatting.
102
votes
3
answers
139k
views
Understanding user file ownership in docker: how to avoid changing permissions of linked volumes
Consider the following trivial Dockerfile:
FROM debian:testing
RUN adduser --disabled-password --gecos '' docker
RUN adduser --disabled-password --gecos '' bob
in a working directory with nothing ...
85
votes
5
answers
129k
views
Code to clear all plots in RStudio
I have code to clear the workspace: rm(list=ls()) and code to clear the console: cat("\014")
Is there code to clear all plots from Rstudio?
80
votes
5
answers
12k
views
Rstudio and Google Drive Syncing Problems: "The process cannot access the file because it is being used by another process"
So I'm using RStudio and storing my files on Google Drive (the version with folders on your system, acting like Dropbox). I'm using it because it provides a lot more space for free than Dropbox, and I ...
79
votes
5
answers
42k
views
R knitr Markdown: Output Plots within For Loop
I would like to create an automated knitr report that will produce histograms for each numeric field within my dataframe. My goal is to do this without having to specify the actual fields (this ...
75
votes
4
answers
54k
views
How to convert R Markdown to HTML? I.e., What does "Knit HTML" do in Rstudio 0.96?
What commands are run when pressing "Knit HTML" on an R Markdown file in Rstudio 0.96?
My motivation is that I might want to run the same command when I'm in another text editing environment or I ...
75
votes
2
answers
15k
views
"long vectors not supported yet" error in Rmd but not in R Script
I am operating matrices with R 3.1 and RStudio 0.99.
I have my R Script and with cmd+enter it works without problem.
I created an Rmd for reporting but I have this error
Error in ...
74
votes
1
answer
48k
views
avoid string printed to console getting truncated (in RStudio)
I want to print a long string to the RStudio console so that it does not get truncated.
> paste(1:300, letters, collapse=" ")
[1] "1 a 2 b 3 c 4 d 5 e 6 f 7 g 8 h 9 i
...
181 y 182 z 183 a 184 b.....
74
votes
4
answers
134k
views
Scale and size of plot in RStudio shiny
Related, but only talks about the allocated plot space in general, not how to directly set the plot image size and then scale it to fill the desired space
Shiny Chart Space Allocation
I'm creating a ...
73
votes
8
answers
114k
views
multiple authors and subtitles in Rmarkdown yaml
I'm trying to follow this pandoc example to add multiple authors to an Rmarkdown file in the yaml metadata block. The pdf will generate in RStudio (Version 0.98.932), but there is no author ...
73
votes
6
answers
70k
views
The R console is in my native language, how can I set R to English?
I am using R on Windows 7. Apparently R somehow found evidence that I speak languages besides English, and stubbornly insists on giving output in the console in my own language. For a variety of ...
70
votes
8
answers
63k
views
How to use objects from global environment in Rstudio Markdown
I've seen similar questions on Stack Overflow but virtually no conclusive answers, and certainly no answer that worked for me.
What is the easiest way to access and use objects (regression fits, data ...
67
votes
9
answers
132k
views
Rtools not being detected by R
Update:
I've written a brief walkthrough guide to installing Rtools on windows.
Original:
I am trying to build an R package using RStudio on Windows 7. When I attempt to build the package via ...
66
votes
7
answers
30k
views
two-column layouts in RStudio presentations/slidify/pandoc
I'm trying to come up with a good system for generating slides and accompanying handouts. The ideal system would have the following properties:
beautiful in both presentation (PDF/HTML) and handout (...
63
votes
6
answers
148k
views
Reset the graphical parameters back to default values without use of dev.off()
Such as margins, orientations and such...
dev.off() does not work for me. I am often using RStudio, with its inbuilt graphics device. I then have plotting functions, which I want to plot either in ...
61
votes
6
answers
91k
views
suppress console output in r markdown, but keep plot
Hi I have the following markdown chunk:
```{r, echo=FALSE,warning=FALSE,message=FALSE,error=FALSE}
lapply(obj,function(x) plot(x,main="some plot") box() axis(1,at=seq(0,25,by=1))
```
The output is ...
60
votes
2
answers
75k
views
How to run an entire R script at once [closed]
How do I run an entire R code script in RStudio?
When I click on the Run button in RStudio, the code runs only on a line-by-line basis and I want it to execute all the code at once instead of ...
60
votes
1
answer
7k
views
Difference: "Compile PDF" button in RStudio vs. knit() and knit2pdf()
TL;DR
What are the (possibly unwanted) side-effects of using knit()/knit2pdf() instead of the "Compile PDF"1 button in RStudio?
Motivation
Most users of knitr seem to write their documents ...
59
votes
4
answers
61k
views
How do I open a script file in RStudio using an R command?
I have a simple script file called test.R. It's saved in the working directory. When I go to File > Open > test.R, it opens the file in the editor (without executing the code, which is what I ...
58
votes
1
answer
3k
views
Persistent warnings from earlier commands with RStudio
I'm struggling to create a reproducible example for this, but I suspect others will know what I mean. Why does R sometimes seem to get stuck with a backlog of warnings/error messages that it repeats ...
57
votes
10
answers
40k
views
Rstudio difference between run and source
I am using Rstudio and not sure how options "run" and "source" are different.
I tried googling these terms but 'source' is a very common word and wasn't able to get good search results :(
56
votes
2
answers
111k
views
How to use Rstudio relative paths
How can I use relative paths in a RStudio project environment?
For example, to access a file, I use the whole path:
# My RStudio project working directory:
getwd()
[1] "C:/Users/MaurizioLocale/...
54
votes
3
answers
32k
views
R: In RStudio how do I make knitr output to a different folder to avoid cluttering up my drive?
I am using RStudio's knit HTMl function to output some presentations. But it always outputs the files to my current work directory. How can I make it output to another directory so that my directory ...
52
votes
5
answers
92k
views
How to output text in the R console without creating new lines?
I would like to output a progress indicator during my lengthy running algorithms. I can easily "bubble up" a progress value from within my algorithm (e.g. via invoking a provided function callback ...
52
votes
2
answers
62k
views
In RStudio/RMarkdown, how to setwd?
setwd in an Rmd file in RStudio does not appear to change the directory in subsequent chunks. Is there a way to set the working directory for good?
Example:
```{r}
setwd("/tmp")
getwd()
```
```{r}
...
50
votes
7
answers
53k
views
Setting work directory in knitr using opts_chunk$set(root.dir = ...) doesn't work
My R project is structured like a package with directories /R, /vignettes, /data etc. In one of my Rmd docs in /vignettes I source a script which in located in /R. Inside this script I use read.csv() ...
50
votes
1
answer
16k
views
Renaming RStudio project under version control
What's the right way to rename an RStudio project (esp., when that project is under version control)?
E.g., I created an RStudio project with version control in "~/myproject". Then I decided I wanted ...
49
votes
12
answers
32k
views
How to add a page break in word document generated by RStudio & markdown
I writing a Word document with R markdown in R Studio. I can get many things, but at the moment I am not figuring out how can I get a page break. I have found solutions but only for rendered latex / ...
49
votes
4
answers
59k
views
How to indent multiple lines of code in Rstudio?
I have tried using "reindent lines" after highlighting the lines but that doesn't work (in fact it removes indentation). For example I want a quick way to
take a script like this
#parameters
b=2
c=1
...
46
votes
5
answers
22k
views
What is a neat command line equivalent to RStudio's Knit HTML?
What is a neat command line equivalent to RStudio's Knit HTML? Given an .Rmd file, you can use RStudio to knit .html, .docx and .pdf files using Knitr. It would be great to shift this process ...
46
votes
3
answers
16k
views
How to fast insert new 'pipe operator' in Rstudio?
I have been using the ctrl + shift + m shortcut to insert well known %>% pipe operator.
Since the release of R version 4.1.0 and adding a new |> to base, I wonder is the corresponding shortcut ...
46
votes
2
answers
83k
views
In R markdown in RStudio, how can I prevent the source code from running off a pdf page?
I currently have some code that looks like so:
```{r, tidy=TRUE}
plot(DT$age, DT$height, xlab = "Age of participant in Trials", ylab = "Height of participant in Trials")
```
Now, it was my ...
45
votes
2
answers
25k
views
How can I use spell check in Rmarkdown?
I want to write a report with Rmarkdown. However, I am a little worried about my spelling. I hope there is a package installed in my Rstudio which can automatically help me spell check.
So, is there ...
45
votes
1
answer
3k
views
Operator "[<-" in RStudio and R
By accident i've encountered strange behaviour of "[<-" operator. It behaves differently depending on order of calls and whether i'm using RStudio or just ordinary RGui. I will make myself clear ...
44
votes
9
answers
70k
views
How to get unsaved script tabs
I would like to know, if it is possible to get unsaved script tabs in R studio. I accidentally open and switch to new project, then my unsaved scripts disappeared. Can anyone help to get my unsaved ...
44
votes
5
answers
92k
views
Restart R within Rstudio
I'm trying to call a simple python script from within R using system2(). I've read some information I found vague that said if 'too much' memory is used, it won't work.
If I load a large dataset and ...
43
votes
2
answers
52k
views
How to hide code in RMarkdown, with option to see it
I'm writing an RMarkdown document in which I'd like to re-run some chunks (5 to 9).
There's no need to display these chunks again, so I considered using
```{r echo=FALSE}
to make the rerun chunks ...
43
votes
14
answers
79k
views
pandoc document conversion failed with error 43 : pdflatex: The memory dump file could not be found
RStudio : 0.98.994
OS: Microsoft Windows 7 Ultimate Edition, 64-bit Service Pack 1
MiKTeX: 2.9.4503
Hi,
I get the following error when I try to knit a PDF document.
pandoc.exe: Error producing PDF ...
42
votes
10
answers
28k
views
Check if R is running in RStudio
I am looking for a way to test if R is being run from RStudio. For some reason I could find the answer on google yesterday but not today, but I think it had to do with testing if a certain system ...
42
votes
9
answers
108k
views
How to preserve formatting from rstudio when copy/pasting to Word?
I want to reproduce my code in Word 2010. The scripts were written in rstudio, and I would like to preserve rstudio's formatting when pasting into Word. Principally, I like the font colors and ...
42
votes
5
answers
115k
views
How do you change the default directory in RStudio (or R)?
I consulted http://www.rstudio.com/ide/docs/using/workspaces and tried the setwd code and clicking on More --> Set as working directory options. However, the next time I closed and opened RStudio, it ...
42
votes
1
answer
30k
views
Renaming Objects in RStudio context sensitive within entire Project
I have an issue when developing an R project using RStudio. I create an object, and then realise later, that I want to give it another name. I then have to manually change the name, which in larger ...
42
votes
2
answers
99k
views
How to uninstall R and RStudio with all packages, settings and everything else?
I messed up something and there is a problem with tidyverse. Tried to find a solution but spend lots of time without result.
How to uninstall R and RStudio with all packages, settings and everything ...