Importing Data
摘要
Various methods are illustrated for importing data from local or internet text and .csv files, for situations when the data is unavailable in an R package. The base R functions read.table() and read.csv() as well as tidyverse package readr functions for importing data are illustrated by examples. Some data preprocessing tasks are described such as recoding data and identifying missing data. The chapter describes different methods for reshaping data from wide to long format using stack(), reshape(), melt() (reshape2 package) and pivot_longer() (tidyr package).