Problem set 1

Published

September 11, 2024

After finishing the homework, you are to turn in all the code to GitHub using git.

  1. Start an RStudio project. Pick a good name following a naming convention. Start a Quarto document called beginning.qmd.

  2. Create a directory called img and save a screen shot of your RStudio session for the project. Include your screenshot in the Quarto document.

  3. Next, in your Quarto document, define variables \(a=1, b=-1, c=-2\) and print out the solutions to \(f(x) = ax^2+bx+c=0\). Do not report complex solutions, only real numbers.

  4. Include a graph of \(f(x)\) versus \(x\) for \(x \in (-5,5)\).

x <- seq(-5, 5, length = 100)
# Hint: Use the plot function
  1. Create a directory called docs. Use the command quarto render to create a PDF and save it to the docs directory. Show us the command you typed:
# Your code here
  1. Use Unix to create a directory called data in the project home directory. Include the Unix command you used to create the directory.
# Your code here
  1. Use a terminal-based text editor to create a file coefs.txt in the data directory and save three coefficients, 1 -1 -2 for example. Show us the Unix commands you used to achieve this:
# Your code here
  1. Make a directory called code. Use Unix to copy the file beginning.qmd to a file called quadratic.qmd in the code directory. Show us the Unix commands you used.
# Your code here
  1. Edit the quadratic.qmd file to read in a, b, and c from the file coefs.txt. Make sure to use a relative path when reading the file. As before, print out the solutions to \(f(x) = ax^2+bx+c=0\). Do not report complex solutions, only real numbers.

  2. Change the path of the file you are reading to the full path you get when you type file.path(getwd(), "data/coefs.txt"). Confirm that the file still renders. Then move the entire pset-01-rmarkdown project to a directory called RtmpyDknq4. Does the file render? Change the path back to a relative path and see if it renders.