Skip to content
R for the Rest of Us: A Statistics-Free Introduction comes out June 25th. Or you can read the online version today. Check it out →
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

  1. Create and save an R script file

  2. Enter a mathematical expression on your R script file and run it

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Douglas Ndowo

Douglas Ndowo

March 21, 2024

Does this mean it’s possible to import a ready made code/Rscript file, maybe customize it to fit a particular dataset & operations?… 🤩I’m totally loving this

David Keyes

David Keyes Founder

March 21, 2024

Yes! And this is a major benefit of working in a code-based tool like R.

This "Files in R" and "Projects" portion are not loading

David Keyes

David Keyes Founder

April 22, 2024

Can you explain a bit more what you mean please?

Claire Hazbun

Claire Hazbun

May 14, 2024

Question about file locations. I know it's important to be mindful of where we're saving files when using programs like R. I'm wondering if you have any tips when setting up a system for file management. e.g. is is advantageous to create a folder on your computer for all R script files (and have subfolders like "R files for Getting Started with R" and "R files for Quant Methods 1" etc)? or maybe it makes more sense to have your R script files in the various folders that contain other non-R documents related to each project you're working on? does it matter?

Libby Heeren

Libby Heeren Coach

May 14, 2024

How you evolve to use files and folders over time will greatly depend on your use cases and who you need to collaborate with, but we strongly advocate for working in RStudio Projects (see the lesson before this one). A project is essentially a folder on your computer that contains a .Rproj file. When you work inside that project in RStudio, you'll have all the files and data you need for that project in one place. This gets easier to understand with time and practice, but let me give you some resources! Also, it's good to note that project folders are a terminus - there should generally not be any more project folders (folders that contain .Rproj files) inside of an RStudio Project folder.

Here is the Projects section in the R for Data Science book: https://r4ds.hadley.nz/workflow-scripts#projects

Here is a blog post I like about how to set up a project folder for beginners. Your choice of what you call folders is up to you, but this gives a good intro and inspiration: https://martinctc.github.io/blog/rstudio-projects-and-working-directories-a-beginner%27s-guide/

As a personal example, I have a folder on my computer called GitHub that contains two folders, Personal and Clients. In my Personal folder, I have all my personal RStudio Project folders, like my website, and fun side projects. In my Client folder, I have a folder for each client, and inside the client folders there are RStudio Project folders.