I am still pretty new to R, but couldn't seem to find solution to my question.
It's quite simple:
I have a .rmd file written and ready to run, but instead of openning it from R or Rstudio, Is there a way I can knit it automatically without opening that file?
Please kindly guide me how should I do this, screenshot would be much appreciated!!
Thanks in advance!!
Added: So I took nrussell's advice and tried run that on my windows command line, but I am seeing "The filename, directory name, or volumn label syntax is incorrect". Thoughts? Thank you all for your comments!
did a cd RMD's path , then used #nrussell's code. and it worked.
Somehow, I couldn't use specified RMD file path such as C:\XXX\XXXX.rmd, but if I cd to there first, it worked.
Related
Beginner to R! Bit of a bizarre question, but is anyone familiar with the compareGroups package in R? There's a function to export files, but I have no idea where the file ends up in - can't seem to find it doing a computer search. (I use RStudio). The CRAN guide wasn't particularly helpful.
The functions I tried were export2csv() and export2word()
Thank you!
Found a solution. Oddly the formula doesn't follow instructions in the package's manual. In case anyone else gets the same problem, export2word(createTable(compareGroups(x ~ y1 + y2, data=dataset), file="filename.doc")
If you run
getwd()
you should get back the directory path that RStudio is using for your current project at that moment. If you do not specify a special destination for the export, I believe it should output it in that directory. You can also run
list.files()
to list the files in your current working project directory
I got some example codes from a course that start with
install.packages('maps')
install.packages('geosphere')
library(maps)
library(geosphere)
setwd("C:\\mydata")
...
Everything was fine until the command of setting working directory. Because I installed RStudio and R in D drive, I have also tried "C://", "C:/", "C:\", "D:\", "D:\", "D://", and "D:/". However, the console kept saying "Error in setwd( ): cannot change working directory".
This is probably a studpid question. But I'm a beginner in R, so could somebody be so kind to help me out? Thank you very much!
ctrl+R no longer works for executing script lines.
This is not a hardware/keyboard problem.
I have also restarted my PC.
I have tried on a different PC.
I have recently switched from using R to using RStudio. I thought this may have something to do with it, so I opened and resaved the script in RStudio, to no effect.
Furthermore, I have created an R-Project folder and have copied the files, including the script in question, into it. Then I started R-Studio and opened the project.
I would like to post my sessionInfo(), but do not know how to do that without executing the command.
Keep in mind that I only use R for stats purposes. I don't know much about informatics or other types of programming etc., so please try to keep it simple for me. Thanks!
In addition to the solution offered above, in Rstudio, Ctrl + Enter does not work if the chunk is broken in .Rmd files.
For example, if you press CTRL + Enter on the following line (2+2), it won't work:
```{r}
2+2
``
The chunk should end three Backtick characters, not two.
The problem was that the script file (for some reason unkown to me) did not have the correct extension (.R). When I added that to the script file extension, it worked fine again.
I am running R in batch mode using Rwui to display visual contents.
In the last section of this document:
http://sysbio.mrc-bsu.cam.ac.uk/Rwui/tutorial/Technical_Report.pdf, it is said that the "The R script must not set the working directory" -
I don't understand what they do mean by that. I have checked the help but it's still obscure for me. Could someone briefly explain me what this sentence means?
I checked my R script and it seems to create a directory. setwd("a path").
I would take it to mean that your script should not set a working directory. You probably need to remove the setwd() command and instead read in your files using the full path as the filename
I need to suppress my output when I run my R scripts in RStudio. There are a lot of comments in my scripts, and the comments are printed when I run the file.
I realize that others have asked how to do this from the command prompt - How to suppress output. I'm not interested in that.
I just want to know how to suppress the output in RStudio. The only exception to this should be print statements. Thanks in advance.
Use source instead of source with echo in R Studio.
Same in MAC.
Ctrl+Shift+S will do the trick. In mac, it will be Shift+Command+S.