read_fb_mobility_files: Read all the .csv files in a folder and format the data.

View source: R/read_and_format_files.R

read_fb_mobility_filesR Documentation

Read all the .csv files in a folder and format the data.

Description

This function reads all the .csv files in a particular folder. These files consistently contain identical columns, with variations only in location, day, and time. As a result, we can uniformly apply specific formatting to columns across these files.

Usage

read_fb_mobility_files(path_to_csvs, colnames, coltypes, keep_format = NULL)

Arguments

path_to_csvs

Path to the folder where the .csv files are stored

colnames

Columns to include in the results (as character). For more information go to readr::read_csv()

coltypes

Column specifications (as strings). See vignette("readr", package = "readr") for more details. documentation.

keep_format

Vector of column names, besides date_time, day and quadkey, that you don't want to convert to a number.

Value

A data.frame with the information of all the files read.

See Also

format_fb_data

read_csv

Examples


files <- read_fb_mobility_files(
  path_to_csvs = paste0(system.file("extdata",
    package = "quadkeyr"
  ), "/"),
  colnames = c( # The columns not listed here will be omitted
    "lat",
    "lon",
    "quadkey",
    "date_time",
    "n_crisis",
    "percent_change",
    "day",
    "hour"
  ),
  coltypes = list(
    lat = "d",
    lon = "d",
    quadkey = "c",
    date_time = "T",
    n_crisis = "c",
    percent_change = "c",
    day = "D",
    hour = "i"
  )
)

head(files)

quadkeyr documentation built on April 3, 2025, 8:52 p.m.