series_to_df {popbayes}R Documentation

Extract original/converted count series data from a list

Description

From the output of the function format_data() (or filter_series()), this function extracts data.frame containing converted counts (converted = TRUE) or original counts (converted = FALSE) for one, several, or all count series.

The resulting data.frame has no particular use in popbayes but it can be useful for users.

Usage

series_to_df(data, converted = TRUE)

Arguments

data

a named list. The output of format_data() or filter_series().

converted

a logical. If TRUE (default) extracts converted counts, otherwise returns original counts.

Value

A data.frame.

Examples

## Load Garamba raw dataset ----
file_path <- system.file("extdata", "garamba_survey.csv", 
                         package = "popbayes")
                         
garamba <- read.csv(file = file_path)

## Create temporary folder ----
temp_path <- tempdir()

## Format dataset ----
garamba_formatted <- popbayes::format_data(
  data              = garamba, 
  path              = temp_path,
  field_method      = "field_method",
  pref_field_method = "pref_field_method",
  conversion_A2G    = "conversion_A2G",
  rmax              = "rmax")

## Extract converted count data ----
converted_data <- popbayes::series_to_df(garamba_formatted, 
                                         converted = TRUE)

## Extract original count data ----
original_data <- popbayes::series_to_df(garamba_formatted, 
                                        converted = FALSE)

dim(converted_data)
dim(original_data)
dim(garamba)

[Package popbayes version 1.2.0 Index]