![]() #' This is very useful to explain what you are actually doing! #' Comments with an apostrophe "'" will be printed as regular text. #' Comments with a "+" sign are used to tell knitr what should be # Comments starting with "#+" control different knitr options. # Conventional comments are formatted as regular comments # The header above sets some metadata used in the knitr output Here is an example if anyone wants to start playing with this. If you don't want your code to be evaluated (you just want a simple copy-paste), you can add #+eval=FALSE at the beginning of your script and then the source code will be reproduced in the word document without being evaluated. docx document will be generated with the output of your script as well as the original source code. Just in case someone else looks for this question.Īnother way to have all the source code in a word document with a good-looking format using RStudio is to use the File/Compile Notebook option, choosing MS Word as the output format. This can then be pasted into MS Word with HTML format. When your script is correctly highlighted in Notepad++ go to the "Plugins > NppExport > Copy HTML to clipboard" menu to copy the open file. (Or copy and paste from RStudio to Notepad++, but make sure you set the file's language-from the "Language" menu-to R). From RStudio, save your script (with a ".R" extension) then open the script in Notepad++. ![]() ![]() But there is a copy-and-paste-and-copy-and-paste solution. If you are pasting from the script editor, then you're out of luck with a direct copy-and-paste solution. There should be an option for "HTML Format" that will do what you need (though you may need to resize the font to make everything fit properly depending on your page margins). If you are pasting from the console-please check "Paste special" again. It's not totally clear whether you are pasting from RStudio's script editor (which has some 4 or 5 colors) or from the R console (script + output) within RStudio (which only has 2 colors). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |