Skip to content

Markdown Methods and Navigating the File System

Markdown Methods and Navigating the File System

Markdown Methods:

R Notebooks is a format for writing reproducible, dynamic reports with R. You can use it to embed R code and results into slideshows, pdfs, html documents, Word files and more. Earlier in this module, we looked into the creation of a Notebook (you have probably been using this notebook to follow along). In this chapter, we are going to look into some of the conventional syntax for notebooks and markdowns. These additional elements of Notebooks will help you create more descriptive documentation of your work.

  • plain text : plain text will be printed as plain text
  • *italics* & _italics_ :enclosing text in a single pair of asterisk or underscore will render the text as italicized text
  • **bold** & __bold__: enclosing text in a two pairs of asterisk or underscore will render the text as bold text
  • superscript^2^ : enclosing text in a single pair of carets will render the text as a superscript
  • ~~strikethrough~~ : enclosing text in a two pairs of tilde will render the text to be stricken through
  • [link]( : prefixing a link with [link] and enclosing the link within parentheses will create a link
  • # Header : prefixing text with the pound sign will render the text as a header
    • for sub-headers, increase the number of # as the level of importance declines
  •  > block quote: Using the greater than sign will interpret the line as a block quote and indent the text slightly
  • *** A line of asterisk will be rendered as a line
  • $A = \pi*r^{2}$: enclosing an equation in a pair of dollar signs will render the text as an equation
  • * A single asterisk will be rendered as a bullet point or an unordered list
  • 1. : for a numbered or ordered list, simply type the numbering
    • for a sub-item, indent by one tab space and use a +. This is the same for both unordered and ordered list
This should be suitable for most of the formatting you might want to do in your markdown. For other cool markdown methods, refer to the cheatsheet.

Navigating the file system

The commands will help you navigate the file system. When defining the path to a file, understanding your current working environment or viewing and managing files, these are sure to come in handy.

  • dir():will read the content of the current working directory
  • getwd(): returns the filepath of your current working directory
    • when writing a program, you will need to know the location of a file to access it. These function will come in handy when you must check where a file is stored and access the file
  • ls() : lists the objects
  • rm(my_object1, my_object2, ...) : removes objects
  • functions to know some metadata about an object
      • str(object) : object type and structure
      • ls.str(pattern='') : lists objects and their structures
      • lsf.str : lists object type on all the objects in a session
      • class(object) : prints the object type
      • mode(object): prints the storage mode of an object
      • summary(object) : generic summary info for all kinds of objects
      • attributes(object) :Returns an object’s attribute list.
      • length(object) :Provides length of object.