Question: Putting R codes on MS word document
3
gravatar for babasaraki
15 days ago by
babasaraki40
babasaraki40 wrote:

Hello everyone,

Any idea on how I can paste R codes into a word document, please? I used DESeq2 and some other packages in R for RNA-Seq and enrichment analyses. I want to put some of the R codes into a word document as it appears in R console. So, I am wondering how to do that.

I appreciate your usual support.

Thank you

sequencing rna-seq R • 244 views
ADD COMMENTlink modified 11 days ago by Tom K20 • written 15 days ago by babasaraki40

Just change the font to a monospaced font like courier, and paste the code?

ADD REPLYlink written 15 days ago by Joe14k

Thank you Dr. Joe, will give it a try.

ADD REPLYlink written 11 days ago by babasaraki40

Code in a Word document looks unprofessional, in my opinion. You may consider instead creating a R markdown file and then knitting to PDF? Edit: or, at least, do what jrj.healey suggests and use a different font so that the code stands out.

ADD REPLYlink modified 15 days ago • written 15 days ago by Kevin Blighe48k
1

Thank you so much Professor Kevin for the more enlightening on this. Will check onto it and I do appreciate your usual support. I learnt from your wealth of knowledge and experience.

ADD REPLYlink modified 11 days ago • written 11 days ago by babasaraki40
6
gravatar for Philipp Bayer
15 days ago by
Philipp Bayer6.5k
Australia/Perth/UWA
Philipp Bayer6.5k wrote:

You can write your whole analysis in Markdown including your code blocks, and then render it into Word and back using redoc: https://github.com/noamross/redoc

ADD COMMENTlink written 15 days ago by Philipp Bayer6.5k

Another important clues here. Thank you so much Sir.

ADD REPLYlink written 11 days ago by babasaraki40
4
gravatar for Friederike
14 days ago by
Friederike5.1k
United States
Friederike5.1k wrote:

RStudio also supports the generation of Word documents; all you'd have to do is to copy and paste the code into an Rmarkdown document after installing RStudio and then using the knit button option for generating a Word document.

https://rmarkdown.rstudio.com/

ADD COMMENTlink written 14 days ago by Friederike5.1k

Thank you Professor Friederike for your usual support whenever I made question. I gladly appreciated.

ADD REPLYlink written 11 days ago by babasaraki40
3
gravatar for zx8754
13 days ago by
zx87548.2k
London
zx87548.2k wrote:

If reproducibility is not an issue and we just want to present the codes with pretty formatting, then we could convert formatted code into an image, for example see Carbon website:

ADD COMMENTlink written 13 days ago by zx87548.2k

Thank you Dr for sharing. Will have a look and learn from it.

ADD REPLYlink written 11 days ago by babasaraki40
2
gravatar for Tom K
11 days ago by
Tom K20
Japan/Yokohama/RIKEN IMS
Tom K20 wrote:

R has a history() command that will return the commands you’ve run to the console or a text file. I recommend working in RStudio where you can write a “script” and run lines from it so what you did is saved as you go.

It’s your thesis or paper so up to you but I’d consider digital supplementary data if you have a lot of code (GitHub repo or CD). If anyone wants to reproduce the code then it will be easier for them as well. Of course, check with your supervisor and collaborators to make sure they’re okay with releasing this. An R package to run any new functions you’ve made would also be helpful but this is more effort so isn’t always expected.

Make sure to list the versions of the packages you used as well from sessionInfo() and cite appropriately. Setting up the right packages is just as important for reproducibility.

ADD COMMENTlink written 11 days ago by Tom K20

Thank you Dr. Tom for this insightful suggestion and comments

ADD REPLYlink written 4 days ago by babasaraki40
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 945 users visited in the last hour