5

I have a R notebook in Kaggle that I would like to convert to pdf or html. All the solutions I have found in the forums seem to be python oriented.

Is there any way to get that? Is there any third-party tool to convert it to the format of my choice?

Alfonso_MA
  • 537
  • 5
  • 26

1 Answers1

2

Updated answer (I just realized you were looking for not just PDF, but PDF OR HTML):

You should be able to just click File>Save Version and have your notebook render, so I suspect that some of your settings are wrong if you're not able to do that.

  1. Go through this checklist to make sure it's setup correctly. In the editor, make sure your settings are as follows:
  • Editor menu bar>File>Editor Type: select Script
  • Editor menu bar>File>Language: select 'RMarkdown'
  1. Make sure your YAML includes the output format. It should look like below, with the critical line being output: html_notebook
---
title: "Untitled"
author: "Garrett"
date: "July 10, 2014"
output: html_notebook
---
  1. Click on the menu bar>File>Save Version. This will render your report and save the output.

  2. In the window that pops-up showing that your workbook has being created, click on the three dots and select 'Open in Viewer' when it says it was Successful in creating it.

  3. In the 'Report' view for this report, right-click on something from your report and select 'View Frame Source'. This will open up the HTML source code for your report. (I'm using Chrome on windows - not sure if other browsers have same options).

  4. With the source window open, remove view-source: from the start of the URL and you'll see just the HTML output of your notebook. Right click the page to print to PDF or save to HTML.

Note: There are some settings in the HTML/javascript that prevent scrolling of the window, but that's not an area I'm familiar with so can't help with that

Roger-123
  • 2,232
  • 1
  • 13
  • 33
  • Thanks for the detailed answer but I dont see any YAML configuration (2). I dont see the 'report' view either (5). I used cntrl+F in both cases – Alfonso_MA Jan 04 '22 at 17:29
  • @Alfonso_MA are you using the R markdown notebook or the jupyter notebook? – Roger-123 Jan 04 '22 at 18:45
  • Are not they the same thing? I just clicked "+ New Notebook" button from "Code" menu. Then File->Language->R – Alfonso_MA Jan 04 '22 at 21:27
  • check the settings that I described in the answer – Roger-123 Jan 05 '22 at 00:41
  • Thanks for the effort with this. I see now. I am using jupyter notebook, not RMarkdown. Jupyter notebook is what I need and what my question is about. I am able to visualize the HTML output of my notebook like your step 6, but I can not scroll there and when I save it several .js .css files are created. Not a single html file. – Alfonso_MA Jan 05 '22 at 13:10