VSA R Training (Fall 2022) (2024)

This lesson is locked

Get access to all lessons in this course.

This lesson is called The Tidyverse, part of the Fundamentals of R (v1) course. This lesson is called The Tidyverse, part of the Fundamentals of R (v1) 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

First, download the course project using the following code:

install.packages("usethis")library(usethis)use_course("http://bit.ly/fundamentals-of-r-course")

Then, do the following:

  1. Open the data-wrangling-and-analysis-exercises.Rmd file

  2. Load packages

  3. Import NHANES data and use theclean_names function on it.

Learn More

To see the most downloaded R packages, check out the trends page of the RDocumentation website. Note that because tidyverse is a collection of packages, you will see it show up among the most downloaded packages as well as individual packages that are part of it (e.g. ggplot2).

To learn about the clean_names function, check out the janitor package docs. Note that there are many options for how you can format your variable names. I like snake_case myself so use that (it's also the default).

To see a great set of slides on Tidyverse basics, check out these from Alison Hill.

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

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

VSA R Training (Fall 2022) (1)

Hatem Kotb

March 20, 2021

I've followed the same code but I'm getting an error message as shown below. Any idea why? Thanks! :)

-- Column specification --------------------------------------------------------------------------------------cols(.default = col_character(),ID = col_double(),Age = col_double(),Weight = col_double(),Height = col_double(),BMI = col_double(),DaysPhysHlthBad = col_double(),DaysMentHlthBad = col_double(),SleepHrsNight = col_double(),PhysActiveDays = col_double(),TVHrsDay = col_logical())i Use spec() for the full column specifications.

4859 parsing failures.row col expected actual file5001 TVHrsDay 1/0/T/F/TRUE/FALSE 2_hr './data/nhanes.csv'5002 TVHrsDay 1/0/T/F/TRUE/FALSE More_4_hr './data/nhanes.csv'5003 TVHrsDay 1/0/T/F/TRUE/FALSE 4_hr './data/nhanes.csv'5004 TVHrsDay 1/0/T/F/TRUE/FALSE 4_hr './data/nhanes.csv'5005 TVHrsDay 1/0/T/F/TRUE/FALSE 1_hr './data/nhanes.csv'.... ........ .................. ......... ...................See problems(...) for more details

VSA R Training (Fall 2022) (2)

Hatem Kotb

March 20, 2021

Seems like it's a warning message rather, not an error message. Would still like to understand more how to fix/navigate it. Thanks! :)

VSA R Training (Fall 2022) (3)

Oindrila Bhattacharyya

March 25, 2021

While trying to download the janitor package, I am getting an error message "Error in library(janitor) : there is no package called ‘janitor’ "Can you please tell me what to do now?

Just a word of advice from beginner. I just watched: https://vimeo.com/320973807 02:47. this is essential slide and explanation for me. I could not compute which of the forthcoming functions work on rows and which on columns.

VSA R Training (Fall 2022) (5)

Erin Guthrie

March 31, 2021

For a number of attempts, I kept getting this error:Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j library(tidyverse) Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘cellranger’

After some googling, I just installed "cellranger" separately and that seemed to resolve the issue. Is this common or do I have something set up incorrectly?

VSA R Training (Fall 2022) (6)

Naomi Nichols

April 13, 2021

Should I be worried about all of this red text? :Warning: 4859 parsing failures.row col expected actual file5001 TVHrsDay 1/0/T/F/TRUE/FALSE 2_hr 'data/nhanes.csv'5002 TVHrsDay 1/0/T/F/TRUE/FALSE More_4_hr 'data/nhanes.csv'5003 TVHrsDay 1/0/T/F/TRUE/FALSE 4_hr 'data/nhanes.csv'5004 TVHrsDay 1/0/T/F/TRUE/FALSE 4_hr 'data/nhanes.csv'5005 TVHrsDay 1/0/T/F/TRUE/FALSE 1_hr 'data/nhanes.csv'.... ........ .................. ......... .................See problems(...) for more details.

VSA R Training (Fall 2022) (7)

Juan Clavijo

September 27, 2021

Hello!I'm getting this error message: Error in library(janitor) : there is no package called ‘janitor’

Not sure what to do about it to be able to use clean names.

Thanks!Juan

VSA R Training (Fall 2022) (8)

David Keyes Founder

September 27, 2021

For anyone who needs it, you can use this URL in place of the bit.ly one to access the course materials as a zip file: https://codeload.github.com/rfortherestofus/fundamentals/zip/refs/heads/master

VSA R Training (Fall 2022) (9)

David Keyes Founder

September 28, 2021

You can definitely do that, though I think there are some caveats to consider. I recorded a video to explain my thinking and show you how I'd do things. The code I show in the video is here.

VSA R Training (Fall 2022) (10)

Israel Johnson

October 4, 2021

After executing the 2nd code chunk instructions the following message was generated:Column specificationDelimiter: ","chr (13): SurveyYr, Gender, AgeDecade, Race1, Education, MaritalStatus, HHIncome, HomeOwn, Work, HealthGen, ...dbl (9): ID, Age, Weight, Height, BMI, DaysPhysHlthBad, DaysMentHlthBad, SleepHrsNight, PhysActiveDays

i Use spec() to retrieve the full column specification for this data.i Specify the column types or set show_col_types = FALSE to quiet this message.

Should I be worried about these last two rows?

VSA R Training (Fall 2022) (11)

Dana Loll

March 31, 2022

Hi there! Getting this code when loading janitor.The following objects are masked from ‘package:stats’:

chisq.test, fisher.test

I know that this may be ok for our purposes now but I love chi square & fisher's tests! Any way to keep them? Or are they done in another package?

VSA R Training (Fall 2022) (12)

Carolyn Ford

April 2, 2022

Whenever I try these "usethis" commands, I always get this feedback:

Error in curl::curl_download(url = url, destfile = destfile, quiet = quiet, : Recv failure: Connection was reset

VSA R Training (Fall 2022) (13)

Carolyn Ford

April 2, 2022

Never mind - ended up using the codeload from github.

VSA R Training (Fall 2022) (14)

Tatiana Bustos

July 27, 2022

Hi there

I keep getting errors about the janitor package. I dont see it listed in the tab for packages either. Any other suggestions?

> library(janitor)Error in library(janitor) : there is no package called ‘janitor’> library (janitor)Error in library(janitor) : there is no package called ‘janitor’> install.packages (janitor)Error in install.packages : object 'janitor' not found> install.packages(janitor)Error in install.packages : object 'janitor' not found

VSA R Training (Fall 2022) (15)

Kirstin O'Dell

September 30, 2022

I keep getting this error message:Error in read.csv("data/nhanes.csv") %>% clean_names() :could not find function "%>%"

I have the following libraries loaded with the code below. What am I missing?

library(tidyverse)library(janitor)library(skimr)
nhanes %  clean_names()

VSA R Training (Fall 2022) (16)

Ellen Wilson

January 24, 2023

This all worked for me when I did the sample exercise. I am now trying to work with some SurveyMonkey data I have from an actual survey I am working on, and having some difficulty. First of all, the variable names are insanely long (all the words of every question). I don't know if there is a better way to deal with it, but I was thinking that I would just rename all of them (e.g., rename " x2_what_grade_are_you_in" to "grade"). This is tedious, but maybe necessary? Making it more tedious, though, is the fact that even though I ran clean_names, the autocomplete function doesn't seem to be working. Any thoughts on what the problem could be? Typing out all the words in every one of these very long variable names would be a huge pain... Thanks for any guidance!

VSA R Training (Fall 2022) (17)

Chelsea Ruder

March 24, 2023

Where do I find the data-wrangling-and-analysis-exercises.Rmd file ??

VSA R Training (Fall 2022) (18)

Amanda Braley

March 25, 2023

Hmmm I have an error getting started:> library(usethis)Warning: package ‘usethis’ was built under R version 4.2.3Error: package or namespace load failed for ‘usethis’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):namespace ‘rlang’ 1.0.6 is already loaded, but >= 1.1.0 is required

VSA R Training (Fall 2022) (19)

Andrew Paquin

March 26, 2023

When I try to do the last step, I get this message"Error in read_csv("data/nhanes.csv") %>% clean_names() :could not find function "%>%"Not sure what I'm doing wrong. I'm having a lot of trouble with RStudio tonight.

VSA R Training (Fall 2022) (20)

Zain Asaf

April 1, 2023

Hi David,Previously I was able to get half-way through the select exercise assignments. However, notwwhen I run the code from the start, run the clean_name function- I use the following codeLnhanes%clean_names()But I get the following error message: Use spec() to retrieve the full column specification for this data.i Specify the column types or set show_col_types = FALSE to quiet this message.>

Use spec() to retrieve the full column specification for this data.i Specify the column types or set show_col_types = FALSE to quiet this message.

VSA R Training (Fall 2022) (21)

Abdulkadir Lokhandvala

April 7, 2023

Hi David/Charlie - I am continuously getting below error and not able to progress in my course materials.Warning: package ‘tidyverse’ was built under R version 4.2.3Error: package or namespace load failed for ‘tidyverse’:.onAttach failed in attachNamespace() for 'tidyverse', details:call: NULLerror: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):namespace ‘rlang’ 1.0.6 is already loaded, but >= 1.1.0 is required

VSA R Training (Fall 2022) (22)

Innocent Ouko

June 3, 2023

Hello,I have been trying to practice lesson but on a single file and this is the error message I got after trying to knit the entire document, which, as a result, makes no output:

Error: The name of the input file cannot contain the special shell characters: [ ()|:&;#?*'] (attempted to copy to a version without those characters 'Fundamentals-of-R.Rmd' however that file already exists)Execution halted

VSA R Training (Fall 2022) (2024)

References

Top Articles
Latest Posts
Article information

Author: Kerri Lueilwitz

Last Updated:

Views: 5473

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Kerri Lueilwitz

Birthday: 1992-10-31

Address: Suite 878 3699 Chantelle Roads, Colebury, NC 68599

Phone: +6111989609516

Job: Chief Farming Manager

Hobby: Mycology, Stone skipping, Dowsing, Whittling, Taxidermy, Sand art, Roller skating

Introduction: My name is Kerri Lueilwitz, I am a courageous, gentle, quaint, thankful, outstanding, brave, vast person who loves writing and wants to share my knowledge and understanding with you.