Unable to view plots on GitHub using md file - r

I created a R markdown file on R Studio enter image description here and used the Knit function to create an html file. Eventually, .md file and html files were created in my working directory. Also, a figures folder/directory was created automatically. And hence, I pushed all the changes made to my GitHub repository.
Now, my problem here is when I open the .md (markdown) file on GitHub, it doesn't view the plots
enter image description here

You have to push images to the GitHub repo. Images cannot be viewed because they are missing.

Related

Markdown File not formatted propertly, preview pane is fine though (GitHub)

I've uploaded one Rmarkdown file to Github (as a .md file). At first, it was OK, but when i checked it a few days ago it was just out of format, just like it is now:
But when i go to Edit>Preview on GitHub, it just shows as I expect it to behave (and as it was at the first time i uploaded this project and as my RmarkDown file is):
Any tips on how to solve it?
Thanks in advance!

chunk code plot from rmd file not shown in the post of blogdown

When I use the blogdown and hugo academic create a website, one example post created by rmd file (2015-07-23-r-rmarkdown) has chunk code, but the plot of this chunk code did not show in the post see here. I can see the chunk code created figures in the figure_html folder though
besides, when insert image from addin in rstudio, it automatically provides a path: static/blog/2020-11-09-creating-a-website/index_files/1.JPG, however the image does not show in the post. When I use a path static/blog/2020-11-09-creating-a-website/1.JPG, it works. What could be wrong with the index_files folder?

How to show image from folder in google colab

How can I show the pictures from folder figures in google colab inline in a markdown cell?
I have the following structure of notebooks on my local drive.
figures
- pic1.png
- pic2.png
- ...
Notebook1.ipynb
Notebook2.ipynb
etc.
After opening a Notebook in google colab and uploading the figures folder, I checked that the folder with pictures is actually uploaded. It is.
I then tried the following in a markdown cell:
![Pic1](figures/pic1.png)
This apparently doesn't work in google colab.
How did Jake VanderPlas do this here? Apparently he didn't even upload the pictures into a folder "figures" but still uses the following line in markdown
![Broadcasting Visual](figures/02.05-broadcasting.png) in the above link (scroll down to see a picture on numpy arrays).
Any help is appreciated!
Thanks!
GitHib image references are resolved relative to the repo.
For notebooks stored in Drive, you'll need to embed the image in the notebook. Here's an example:
https://colab.research.google.com/drive/1jWHKR6rhhyZtUulttBD6Pxd_AJhgtVaV
The key bit is the Image display helper, applied to a local file–
from IPython.display import Image
Image('220px-TensorFlowLogo.svg.png')
Here is another way to show it.
##markdown Fig.1. Pic1 demo
import matplotlib.pyplot as plt
pic_name = '/content/drive/MyDrive/pic1.png'
image=plt.imread(pic_name)
fig=plt.figure(figsize=(20,30))
_=plt.imshow(image)
_=plt.axis('off')
Markdown tag shows text, which allows code hiding from the report (if that is your end goal).
Once you upload your local image to your Google Colab filesystem (click the folder icon on the upper left of your notebook that says "files", then upload it), you can use the IPython code to display it. You get the path link by right-clicking on the image after you uploaded it that says "copy path". Put the whole link in quotes.
from IPython import display
display.Image("/content/my-image.png")

Here() function doesn't change its directory after pushing the source code to github

I am writing a Rmd file, where it contains some knitted images. The Rmd file shows stuffs just as expected when looking at them on my own computer, but it cannot show the inserted images when uploaded to my github.
To knit the inserted images, I used here() function:
knitr::include_graphics(c(here("data/images/experiments_areaId2ad4/plots", "scatter_old.png"), here("data/images/experiments_areaId2ad4/plots", "scatter_new.png")))
On the github, the images cannot be shown, and as most html, there are tiny placeholders at the positions of each of the images. When I clicked on one of the place holder, it led me to a webpage that was 404.
I looked at the URL, it is like:
https://github.com/[my_github_account]/[my_github_repo]/blob/master/Users/[myname]/Desktop/[my_local_path]/[my_github_repo]/my_reports/data/images/experiments_areaId2ad4/plots/scatter_new.png
Obviously it has copied my local path from my computer to the github, so that the paths of these images are definitely not valid anymore.
However, I still want to use the here() function, so that when my collaborators pull my github updates, they can still interact with my projects without having to worry about screwing up directory.
Does anyone have a suggestion?
Thanks!

Hyperlink that can lead to a pdf in Jupyter notebook

I'm working with Jupyter notebook and have a question in mind:
If I want to markdown an HTML file or any website, I can just simply do
[name-of-the-website](address-here)
and it will create a link to the page that I want to reference
My question is
Are there any markdown code for PDF reference
IS the code the same with HTML reference (whenver I click into the markdown link, It will create a new tab which can download the file to the computer)
P/s: I'm not talking about coverting the notebook into PDF file
I have found out an answer:
Go to the file PDF that you want to download, for example I want to download this PDF file
Ideas:
Because there should be a HTML link to download the document, if one can find this link, then can proceed to normal markdown HTML file in Jupyter Notebook
Steps:
On the browser, right-click that PDF download link, and then choose Inspect Element (Q) (on Firefox or any browser in use)
It is then open the console that will shown the download HTML file like shown:
href="http://www.montefiore.ulg.ac.be/services/stochastic/pubs/2009/DMWG09/dumont-visapp09-shortpaper.pdf"
One can proceed with normal markdown in Jupyter Notebook
This works for me:
ref.
This is a relative path to the file.

Resources