Get access to all lessons in this course.
-
Week 1: Getting Started with R
- Welcome to Getting Started with R
- Install R
- Install RStudio
- Projects
- Files in R
- Packages
- Import Data
- Objects and Functions
- Examine our Data
- Import Our Data Again
- Getting Help
- Wrapping Up
- Introductions thead!
- VSA R 2022 Week 1 Live Session
-
Week 2: Fundamentals of R (RMarkdown)
- Welcome to Fundamentals of R
- RMarkdown Overview
- YAML
- Text
- Code Chunks
- Wrapping Up
- Week 2 Project Assignment
- Week 2 Drop-in Session
- Week 2 Live Session
-
Week 3: Fundamentals of R (Data Wrangling and Analysis)
- Getting Started
- The Tidyverse
- select
- mutate
- filter
- summarize
- group_by
- count
- arrange
- Create a New Data Frame
- Crosstabs
- Wrapping Up
- Week 3 Project Assignment
- Week 3 Drop-in Session
- Week 3 Live Session
-
Week 4: Fundamentals of R (Data Visualization)
- An Important Workflow Tip
- The Grammar of Graphics
- Scatterplots
- Histograms
- Bar Charts
- color and fill
- scales
- Text and Labels
- Plot Labels
- Themes
- Facets
- Save Plots
- Wrapping Up
- You Did It!
- Week 4 Project Assignment
- Week 4 Drop-on Session
- Week 4 Live Session
-
Week 5: Catch-Up Week
- Week 5 Project Assignment
- Week 5 Drop-in Session
-
Week 6: Git + GitHub
- Welcome, Logistics, Course Materials, and Additional Resources
- What is Git? What is GitHub?
- Why Should You Learn to Use Git and GitHub?
- Update Everything
- Install Git
- Configure Git
- Create a Local Git Repository
- Commits
- Commit History
- GitHub Repositories
- Connect RStudio and GitHub
- Push an RStudio Project to a GitHub Repository
- Pull a GitHub Repository to an RStudio Project
- Keep RStudio and GitHub in Sync
- Week 6 Project Assignment
- Week 6 Drop-in Session
- Week 6 Live Session
-
Week 7: Going Deeper with R (Advanced Data Wrangling, Part 1)
- Overview
- Importing Data
- Tidy Data
- Reshaping Data
- Dealing with Missing Data
- Changing Variable Types
- Advanced Variable Creation
- Advanced Summarizing
- Binding Data Frames
- Week 7 Drop-in Session
- Week 7 Live Session
-
Week 8: Going Deeper with R (Advanced Data Wrangling, Part 2)
- Functions
- Merging Data
- Renaming Variables
- Quick Interlude to Reorganize our Code
- Exporting Data
- Week 8 Project Assignment
- Week 8 Drop-in Session
- Week 8 Live Session
-
Week 9: Going Deeper with R (Advanced Data Visualization, Part 1)
- Data Visualization Best Practices
- Tidy Data
- Pipe Data Into ggplot
- Reorder Plots to Highlight Findings
- Line Charts
- Use Color to Highlight Findings
- Declutter
- Use the scales Package for Nicely Formatted Values
- Use Direct Labeling
- Week 9 Project Assignment
- Week 9 Drop-in Session
- Week 9 Live Session
-
Week 10: Catch-Up Week
- Week 10 Drop-in Session
-
Week 11: Going Deeper with R (Advanced Data Visualization, Part 2)
- Use Axis Text Wisely
- Use Titles to Highlight Findings
- Use Color in Titles to Highlight Findings
- Use Annotations to Explain
- Tweak Spacing
- Customize Your Theme
- Customize Your Fonts
- Try New Plot Types
- Week 11 Project Assignment
- Week 11 Drop-in Session
- Week 11 Live Session
-
Week 12: Going Deeper with R (Advanced RMarkdown)
- Advanced Markdown Text Formatting
- Tables
- Advanced YAML
- Inline R Code
- Making Your Reports Shine: Word Edition
- Making Your Reports Shine: HTML Edition
- Making Your Reports Shine: PDF Edition
- Presentations
- Dashboards
- Other Formats
- You Did It!
- Week 12 Drop-in Session
- Week 12 Live Session
-
Week 13: Final Assignment
- VSA R Training Final Assignment
- VSA R Training Week 13 Live Session
-
Questions, Resources, Etc
- All VSA R Training Videos
- Working with file paths and RStudio Projects
- Styling RMarkdown docs
- Structuring large projects (and dealing with slow knitting of Rmd files)
- How to convert HTML files to PDF
- How to get lesson and lecture slides
- {lubridate} for working with dates and times
- Statistical Tests
VSA R Training (Fall 2022)
Import Data
This lesson is locked
This lesson is called Import Data, part of the VSA R Training (Fall 2022) course. This lesson is called Import Data, part of the VSA R Training (Fall 2022) 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
Create a new R script file and save it as
import.R
Add the line
library(tidyverse)
at the top of your R script file and run it to load the tidyverse package.Use the
read_csv()
function (notread.csv()
) to import thepenguins_data.csv
file
You need to be signed-in to comment on this post. Login.
S. Revi Sterling
March 17, 2021
> faketucky <- read.csv(data/faketucky.csv) Error in read.table(file = file, header = header, sep = sep, quote = quote, : object 'faketucky.csv' not found
Atlang Mompe
March 29, 2021
Hi David,
In your example you have double quotes around your syntax, but it wont work on my computer (using windows), unless I have single quotes, is that normal? This is the code that works for me: faketucky <-read_csv ('data/faketucky.csv')
Faythe Aiken
March 30, 2021
Hi David - I'm unable to load the read_csv function from tidyverse. When trying to install the tidyverse package, I get the following failure to download either the binary or source files. What's puzzling is I can download them directly in my browser but in R Studio. > install.packages("vctrs", type="binary") Installing package into ‘\pdcnt19/AikenF$/My Documents/R-local’ (as ‘lib’ is unspecified)
There is a binary version available (and will be installed) but the source version is later: binary source vctrs 0.3.6 0.3.7
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/vctrs_0.3.6.zip' Warning in install.packages : InternetOpenUrl failed: 'The operation timed out' Error in download.file(url, destfile, method, mode = "wb", ...) : cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/vctrs_0.3.6.zip' Warning in install.packages : download of package ‘vctrs’ failed > install.packages("vctrs", type="source") Installing package into ‘\pdcnt19/AikenF$/My Documents/R-local’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/src/contrib/vctrs_0.3.7.tar.gz' Warning in install.packages : InternetOpenUrl failed: 'The operation timed out' Error in download.file(url, destfile, method, mode = "wb", ...) : cannot open URL 'https://cran.rstudio.com/src/contrib/vctrs_0.3.7.tar.gz' Warning in install.packages : download of package ‘vctrs’ failed
Lisa Janz
March 31, 2021
I can't figure out why, but the keep throwing the following error code: Error: object 'faketucky' not found Here is what I have done:> library(tidyverse) -- Attaching packages ---------------- tidyverse 1.3.0 -- v ggplot2 3.3.3 v purrr 0.3.4 v tibble 3.1.0 v dplyr 1.0.5 v tidyr 1.1.3 v stringr 1.4.0 v readr 1.4.0 v forcats 0.5.1 -- Conflicts ------------------- tidyverse_conflicts() -- x dplyr::filter() masks stats::filter() x dplyr::lag() masks stats::lag() > library(skimr) > faketucky->read_csv("faketucky.csv") Error: object 'faketucky' not found > setwd("C:/Users/ArcticFox/Desktop/getting-started-master/data") > faketucky->read_csv("faketucky.csv") Error: object 'faketucky' not found
Lisa Janz
March 31, 2021
And it doesn't work if I put the arrow going in the right direction either. I have used R pretty regularly and tried several things with this, but for some reason, I really can't get it to open the file.
Lisa Janz
March 31, 2021
> library(tidyverse) -- Attaching packages ---------------- tidyverse 1.3.0 -- v ggplot2 3.3.3 v purrr 0.3.4 v tibble 3.1.0 v dplyr 1.0.5 v tidyr 1.1.3 v stringr 1.4.0 v readr 1.4.0 v forcats 0.5.1 -- Conflicts ------------------- tidyverse_conflicts() -- x dplyr::filter() masks stats::filter() x dplyr::lag() masks stats::lag() > faketucky<-read_csv("faketucky.csv") Error: 'faketucky.csv' does not exist in current working directory ('C:/Users/ArcticFox/Desktop/getting-started-master').
Josh Rodriguez
May 14, 2021
Hey David, It appears I am getting the common issue noted in the comments here. That "faketucky does not exist in the current working directory." I looked at your response as a way to resolve the matter but it doesn't appear that faketucky is in my Rproj by default. This is where my R session is attempting to pull the data from by default
Scott Clark
July 18, 2021
Hi David. Tidyverse was installed and loaded. I could see and use read.csv, but not read_csv. I noticed readr wasn't listed in the packages:
> library(tidyverse) -- Attaching packages ---------------------------------------------------- tidyverse 1.3.1 -- v ggplot2 3.3.5 v dplyr 1.0.7 v tibble 3.1.2 v stringr 1.4.0 v tidyr 1.1.3 v forcats 0.5.1 v purrr 0.3.4
I was able to install and load readr separately to get around this, but is there a reason why it might not have installed with the rest of tidyverse? Could I be missing any other packages that I might need later?
Christine Mahoney
August 22, 2021
Difficult having issues. I keep receiving Error: 'faketucky.csv' does not exist in current working directory ('/Users/christinemahoney/Desktop/getting-started-master').
Prince Baawuah
October 12, 2021
I mostly work with very very large datasets. Are there any packages and/or tips on how to efficiently import and work with very very large datasets quickly(e.g. if parallel processing?) on the desktop?
Lukas Harringer
March 10, 2022
Hi, when I run the read_csv function, the data appears in my Console not in the Environment section.
Michael Steinhoff
March 17, 2022
could not find function "read_csv". Looked back at error code from loading tidyverse and have this: ** Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j = 0.7.6 is required ** Seems like something is not up to date, but i'm not sure what
Jessica Brewer
October 5, 2022
What is meant by "the working directory"? The main folder in the Files environment?
Amy Williams
October 10, 2022
Hi, Im trying to import the data but I have a message saying the file is not in my current working directory ,library(tidyverse) > library(skimr) > #open up data file use code below > faketucky <-read_csv("data/faketucky.csv") Error: 'data/faketucky.csv' does not exist in current working directory
not sure how to change this?
Thank you
Hani Alnakhli
January 19, 2023
Hi David, I have got this text! Enter an item from the menu, or 0 to exit not pretty sure what was my mistake
Mike Horton
March 9, 2023
Hi, I'm not sure what is going wrong here, but I am getting this error message in response to my syntax - please note that I am putting a < and then a - in the syntax, but it convert this into an arrow when I type them within this question box faketucky <- read_csv(“data/faketucky.csv”) Error: unexpected input in "faketucky <- read_csv(“"
Any ideas? Thanks!
Mercy Abarike
March 26, 2023
I get this feedback anytime I try importing the faketucky data faketucky <-read_csv("data/faketucky.csv") Error: 'data/faketucky.csv' does not exist in current working directory ('C:/Users/Mrs.Mercy/OneDrive/Desktop/Nat 1').
ashwath gadapa
April 26, 2023
Hi David ,
I'm unable to load read_csv function . i have the below log for your reference
> install.packages("skimr") WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/Admin/AppData/Local/R/win-library/4.3’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/skimr_2.1.5.zip' Content type 'application/zip' length 1236705 bytes (1.2 MB) downloaded 1.2 MB
package ‘skimr’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in C:\Users\Admin\AppData\Local\Temp\Rtmpm8G3tz\downloaded_packages > library(skimr) > library(skimr) > faketucky faketucky <- read_csv("data/faektucky.csv") Error in read_csv("data/faektucky.csv") : could not find function "read_csv"
Tuhin CHATURVEDI
April 29, 2023
For Posit Cloud Users: Posit Cloud allows us to go to the file "faketucky.csv". When we left-click on the file, it gives us an option to "Import Dataset". When we choose "Import Dataset", it loads the (readr) package [via library(readr)] and then automatically imports faketucky.csv using the self-generated code [faketucky < - read_csv("~/getting-started-master/data/faketucky.csv")]. Very neat!
Gabriela Elizondo
July 1, 2023
Hi David, I cannot get it to work. I have tried restarting R, loading the packages and it keeps giving me warnings and errors. Restarting R session...
> install.packages("tidyverse") Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.3’ (as ‘lib’ is unspecified) trying URL 'http://rspm/default/linux/focal/latest/src/contrib/tidyverse_2.0.0.tar.gz' Content type 'application/x-gzip' length 425237 bytes (415 KB)
downloaded 415 KB
The downloaded source packages are in ‘/tmp/RtmpdYRVTq/downloaded_packages’ > faketucky load("/cloud/home/r2101164/getting-started-master/data/faketucky.csv") Error in load("/cloud/home/r2101164/getting-started-master/data/faketucky.csv") : bad restore file magic number (file may be corrupted) -- no data loaded In addition: Warning message: file ‘faketucky.csv’ has magic number 'stude' Use of save versions prior to 2 is deprecated > install.packages(“tidyverse”)
Gabriela Elizondo
July 1, 2023
Tuhin CHATURVEDI's comment worked! Thank you!
Maia Volk
August 26, 2023
Hi David,
I'm having an issue loading the tidyverse package. I keep getting this message:
Error: package or namespace load failed for ‘tidyverse’: .onAttach failed in attachNamespace() for 'tidyverse', details: call: NULL error: package or namespace load failed for ‘ggplot2’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘fansi’
Can you help me? Thank you!
David Keyes Founder
August 26, 2023
What happened is that, when you tried to install the
tidyverse
package, one of its dependency packages (packages that the tidyverse needs to run) did not install correctly. I'd manually try to install that package using this code:Try that and let me know if it helps.
Valerie Kaster
September 11, 2023
I am getting an error. I went back and started over to make sure I did all the steps and same response.
help please
David Keyes Founder
September 11, 2023
When did you start the course? I made some changes to it recently that may be confusing you because you may have watched old lessons previously.
Archana Joshi
September 13, 2023
My current working directory that R Studio shows is C:\users\username\Documents
When I created a new R script file - import and followed the above steps to read the penguins file, it gives me an error - 'penguins_data.csv' does not exist in current working directory ('C:/Users/Rajeev Joshi/Documents'). I saved the import.R in getting-started-main folder.
How do I change the current working directory to getting-started-main?
Please help
Libby Heeren Coach
September 15, 2023
Hi, Archana! As long as you're inside an R Project, your working directory will be the project, so make sure you're inside the getting-started-main project before typing the library and read_csv code into your import.R file (which is saved in the project folder).
I made a short video to demonstrate what it should look like.
Bhumika Bhattacharya
September 18, 2023
I have installed tidyverse packagebut when I am running the code read.csv("penguins_data.csv") it is showing this on the console:
Bhumika Bhattacharya
September 18, 2023
it is working for the tibble only