Giter VIP home page Giter VIP logo

2657-r-functions's Introduction

2657-R-Functions

Selected functions I've written for use with R. Full documentation available in the "docs" folder (or as a PDF).

All functions can be downloaded from the "scripts" folder.

Alternatively, if you have the "RCurl" package installed, you can use:

library(RCurl)
baseURL = c("https://raw.github.com/mrdwab/2657-R-Functions/master/")
source(textConnection(getURL(paste0(baseURL, "scripts/---script-name---.R"))))

All scripts mentioned in the snippets section are found in a single snippets.R script.

Functions include:

  1. concat.split.R

    Use to split cells which contain concatenated data into separate columns. Works with string and numeric data. For numeric data, the splitted output can retain original values or be recoded as "1" and "NA" to facilitate frequency calculations. Can also split data into a list within a data.frame.

  2. df.sorter.R

    Sort a data.frame by rows, columns, or both. Can also be used to subset data.

  3. multi.freq.table.R

    Takes columns from a data.frame containing Boolean multiple-response data and tabulates the output.

  4. RandomNames.R

    Uses data from the Genealogy Data: Frequently Occurring Surnames from Census 1990--Names Files web page to generate a data.frame with random names.

  5. row.extractor.R

    Use to extract rows which contan a specified column's min, median, or max values, or to extract rows with specified quantiles.

  6. sample.size.R

    Used to determine the desired sample size of a given population, or the confidence interval for a given population and sample.

  7. stratified.R

    Used to sample from a data.frame according to a grouping (or stratification) variable.

  8. stringseed.sampling.R

    The stringseed.sampling() function is designed as a batch sampling function that allows the user to specify any alphanumeric input as the seed per sample in the batch.

  9. table2df.R

    The table2df() function takes an object of class table, ftable, or xtabs and converts it to a data.frame or a list of data.frames.

Extras

The snippets.R script includes several small "utility" functions. In cases where they are functions I've found online, I've mentioned the source in the head of the function.

Snippets include:

  1. load.scripts.and.data

    Loads all scripts and data files from a specified set of directories matching a specified pattern.

  2. unlist.dfs

    Takes a list of data.frames and assigns them as individual data.frames in the current workspace.

  3. dfcols.list

    Takes a data.frame and converts it to a list where each list item represents one of the columns from the original data.frame.

  4. mv

    Renames objects in the workspace in one step, instead of having to copy the object and remove the original object.

  5. tidyHTML

    Reformats a web page using HTML Tidy (the online service) and uses the XML package to parse the resulting file. Can optionally save the reformatted page.

  6. round2

    Rounds numbers according to the rule you might have learned in school, not according to "round to even" (which is less biased and is used by R).

  7. CBIND

    Binds (by columns) data.frames with differing number of rows, filling the extra rows with NA values.

  8. randomNamesOnline

    Like the RandomNames() function, but uses an online service (http://random-name-generator.info/) to generate the names.

  9. stringseed.basic

    Like the stringseed.sampling() function, but uses a much more basic approach to generating the seed. Also known as TDASample.R.

2657-r-functions's People

Contributors

mrdwab avatar

Watchers

James Cloos avatar Prabin Shakya 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.