MENU

Fun & Interesting

R tools in readr for reading in fixed width files and other formats (CC249)

Riffomonas Project 2,727 lượt xem 2 years ago
Video Not Working? Fix It Now

The readr R package numerous tools for reading in various types of text files including fixed width files (fwf), tab separated values (tsv) files, and comma separated values (csv) files. In this episode Pat shows how to read in fwf files and some useful tools that are shared across readr functions for making it easier to read in one or many files. He also discusses various arguments in the tar program for extracting files from compressed archives to specific directories. The overall goal of this project is to highlight reproducible research practices using a number of tools. The specific output from this project will be a map-based visual that shows the level of drought across the globe.

You can find my blog post for this episode at https://www.riffomonas.org/code_club/2022-09-19-read_fwf.

#readr #read_fwf #tar #R #Rstats

Support Riffomonas by becoming a Patreon member!
https://www.patreon.com/riffomonas

Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights.

If you're interested in taking an upcoming 3 day R workshop be sure to check out our schedule at https://riffomonas.org/workshops/

You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: https://www.riffomonas.org/minimalR/
General data: https://www.riffomonas.org/generalR/

0:00 Introduction
1:34 Using tar to decompress a tar.gz file
5:53 Figuring out how to read in a file
10:28 Reading in fixed width data with read_fwf
16:58 How to specify NA values with readr functions
17:36 How to specify column types
19:09 How to read in specific columns
20:06 How to read in multiple files at once
21:55 Cleaning and outputting data

Comment