I think there might be multiple issues here.
For the Rmd file, the result of getwd() in the setup chunk may be surprising since root.dir was changed. However, the working directory of a code chunk is set before any of the code inside it is executed. Thus the change to root.dir won't be evident until later chunks are run. You can run the following Rmd file to confirm that the working directory is changed for the rest of the document.
---
output: word_document
---
```{r setup}
knitr::opts_knit$set(root.dir = "C:/Users/Laura/Documents/RStudio/dsc520")
getwd()
```
```{r check-wd}
getwd()
```
For the R console, you have to use setwd() to change the working directory. knitr::opts_knit() has no effect outside of an Rmd file.
Lastly, if you want to make it easier for others to run your code on their machine, you don't want to use absolute paths like C:/Users/Laura/Documents/RStudio/dsc520. If the Rmd file is saved in assignments/, but you want it to be executed from the root of the project, you can use the relative path .., i.e. knitr::opts_knit$set(root.dir = ".."). Another useful tool for dealing with working directories is the package here.