R Markdown

These pages are in R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When in RStudio you click the Knit button and a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

For more information - contact

Notes on Website creation

Assuming R and RStudio are already installed and R Markdown is being used for files.

Steps

  1. Create Github account
  2. Create Github Repo (folder) and make it public
  3. Go to settings - Git Hub pages - Source - and make it “Master branch”
  4. Upload existing R files to Repo (include a _site.YML and index.rmd, see following pages)
  5. Create a .nojekyll file (to stop Github from trying to make a wesite)
  6. Create a index.html redirect in Repo master folder to redirect to _Site folder that RStudio is about to make (see following page re direct HTML)
  7. Download Git to computer
  8. In Git CMD (depreciated)
  9. git config –global user.email “
  10. git config –global user.name “Your Name”
  11. In RStudio Go to tools global options and check it is pointing to the git.exe (mine is at C:/Program Files/Git/bin/git.exe)”
  12. View SSH RSA Key while there - copy to GitHub - your_user_ID - Edit Profile (at top of page not side) - Personal Settings - SSH and GPG Keys
  13. Back in Rstudio - open a new project with version control
  14. Provide the URL for Git Hub repo - this should make a new folder on your PC with the Git Hub Repo name and download all the files back to your PC
  15. Use Rstudio to Build the website
  16. I havent had much joy pushing the website to Github using Rstudio so
  17. After “Build” website in RStudio go back to the Windows Start Menu - Git CMD (Deprecated) to cd.. and cd into right directory then
git add -A
git commit -m “new website”
git push

And your new website should be up and running at
https://Github_user_name.github.io/Github_repo_name/_site/
ie for captif-nz https://captif-nz.github.io/LTPPNZ/_site/

And remember you need that redirect index.html in github repo
and a .nojekyll file made (with nothing actually in it)

Updating Website in RStudio

  • Pull first from the Git tab in RStudio
  • Make and save changes to RMD files then
  • Tick and commit in RStudio Git tab
  • Give commit a name and push from the commit box in Rstudio
  • Test the new look by “knitting”” the new page (except the index)
  • Build a new website if figures or pictures are on a updated page
  • If you dont need to build you can commit and push the html created
  • If pushing a new website, use step 17 above

Note.
- “Kniting” HTML isn’t the same as “Building” a website.
- Knitting includes pictures in the HTML, making it slow to load
- Building strips out the pictures and links to them - making it fast

index.html Redirect file

You will need a redirect file called index.html that gets loaded directly to the Githun master repo. This just makes the link to the _site folder the RStudio creates you website in.


<html>    
    
<head>    
    
<title>Redirecting to LTPP Data site  
</title>    
    
<meta http-equiv="refresh" content="1; URL=https://captif-nz.github.io/LTPPNZ/_site">    
    
<meta name="keywords" content="automatic redirection">    
    
</head>    

index.Rmd

You will also need a file called index.RMD file to act as a home page (It can contain anything) when you build the website in Rstudio - if you use the _Site.yml file format on the next page. Unfortunately if you knit this file you will over write the index.html file for the repo-master folder from the previous page. And it must be called index as the github looks for index in the folder - tried calling it something else and wasn’t successful.

##_Site.yml file

You will need create a text file in R Studio called “_Site.yml” in the R Project that looks a bit like this below. It is the structure of your site. That index file is not the same as the one mentioned above as a redirect - this a RMD file called index that is built for the webiste as its home page

name: "LTPP-website"  
navbar:  
  title: "LTPP Website"  
  left:  
    - text: "Home"  
      href: index.html  
    - text: "About"  
      href: about.html  
    - text: "LTTP Summary"  
      href: LTTP-Summary.html  
    - text: "Rutting Summary"  
      href: Rutting-Summary.html  
    - text: "Roughness Summary"  
      href: RoughnessSummary.html  
    - text: "Texture Summary"  
      href: TextureSummary.html  
    - text: "Ratings Summary"  
      href: Ratings.html
    - text: "Table Summary"  
      href: Table-Summary.html