Giter VIP home page Giter VIP logo

tongfen's Introduction

tongfen

Build Status

tongfen logo TongFen (้€šๅˆ†) means to convert two fractions to the least common denominator, typically in preparation for further manipulation like addition or subtraction. In English, that's a mouthful and sounds complicated. But in Chinese there is a word for this, TongFen, which makes this process appear very simple.

When working with geospatial datasets we often want to compare data that is given on different regions. For example census data and election data. Or data from two different censuses. To properly compare this data we first need to convert it to a common geography. The process to do this is quite analogous to the process of TongFen for fractions, so we appropriate this term to give it a simple name. Using the tongfen package, preparing data on disparate geographies for comparison by converting them to a common geography is as easy as typing tongfen.

Reference

TongFen home page and reference guide

Installing the package

The package can be installed from GitHub.

devtools::install_github("mountainmath/tongfen")
library(tongfen)

Caching correspondence files

The get_tongfen_census_ct and get_tongfen_census_ct_from_da methods make use of the StatCan correspondence files. To speed up this process it is useful to permanently cache these files instead of having to download them repeatedly. If caching is desired, set either

  • options("tongfen.cache_path"="<your local cache path>")
  • Sys.setenv("tongfen.cache_path"="<your local cache path>")
  • options("custom_data_path"="<your local cache path>")

in your .Rprofile or .Renviron file.

Introduction

The package offers several functions

  1. tongfen_estimate makes no assumption on the underlying geographies and returns estimates of the data on the geography of the first dataset.
  2. tongfen_ct works on Canadian census tracts from different censuses and returns the data on a common geography.
  3. tongfen_cancensus works on any census geography obtained through the cancensus package. It utilizes the Statistics Canada correspondence files and gives the most accurate estimate of data across censuses.
  4. get_tongfen_census_ct get Canadian census variables from any of the 2001, 2006, 2011 and 2016 censuses on a common geography based on CTs
  5. get_tongfen_census_ct_from_da get Canadian census variables from any of the 2001, 2006, 2011 and 2016 censuses on a common geography based on CTs, build up from a DA level correspondence. This gives a more accurate, but coarser, match compared to using get_tongfen_census_ct and will use the official DA correspondence files.
  6. get_tongfen_census_ct get Canadian census variables from any of the 2001, 2006, 2011 and 2016 censuses on a common geography based on DAs using the official DA correspondence files.

Not all data can be aggregated in this form, and some data requires different aggregation functions than others. For example, in census data we encounter variables representing simple counts, for example population, that must be added up when joining geographic regions. Averages or percentages require a weighted sum, medians cannot be aggregated but may be approximated.

In the case of the data originating from the cancensus package the aggregation will be done automatically whenever possible, in other cases the user needs to specify how data should be aggregated.

tongfen's People

Contributors

mountainmath avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.