This course will involve moving files around on your computer and downloading files.
If you are new to this - check out the videos on the resource page of the website.
This course will involve moving files around on your computer and downloading files.
If you are new to this - check out the videos on the resource page of the website.
R Projects are a super helpful feature of RStudio. They help you:
Stay organized. R Projects help in organizing your work into self-contained directories (folders), where all related scripts, data, and outputs are stored together. This organization simplifies file management and makes it easier to locate and manage files associated with your analysis or project.
Find the right files. When you open an R Project, RStudio automatically sets the working directory to the project’s directory. This is where RStudio “looks” for files. Because it’s always the Project folder, it can help avoid common issues with file paths.
Be more reproducible. You can share the entire project directory with others, and they can replicate your environment and analysis without much hassle.
“The chance of the setwd()
command having the desired effect – making the file paths work – for anyone besides its author is 0%. It’s also unlikely to work for the author one or two years or computers from now. The project is not self-contained and portable.”
Let’s go over how to create and use an R Project!
Let’s make an R Project so we can stay organized in the next steps. Click the new R Project button at the top left of RStudio:
In the New Project Wizard, click “New Directory”:
Click “New Project”:
Type in a name for your new folder.
Store it somewhere easy to find, such as your Desktop:
You now have a new R Project folder on your Desktop!
Make sure you add any scripts or data files to this folder as you go through your Intro to R lessons, or work on a new project. This will make sure R is able to “find” your files.
You can see what project you have open in the top right corner.
delimiters are symbols that separate cells in a simple-text file.
Youth Tobacco Survey (YTS) dataset:
“The YTS was developed to provide states with comprehensive data on both middle school and high school students regarding tobacco use, exposure to environmental tobacco smoke, smoking cessation, school curriculum, minors’ ability to purchase or otherwise obtain tobacco products, knowledge and attitudes about tobacco, and familiarity with pro-tobacco and anti-tobacco media messages.”
>
File>
Import Dataset>
From Text (readr
)>
paste the url (http://jhudatascience.org/intro_to_r/data/Youth_Tobacco_Survey_YTS_Data.csv)>
click “Update” and “Import”Saves data in memory, not to hard drive
You see a preview of the data on the top left pane.
You see a new object called Youth_Tobacco_Survey_YTS_Data
in your environment pane (top right). The table button opens the data for you to view.
R ran some code in the console (bottom left).