Giter VIP home page Giter VIP logo

cointoss's Introduction

Overview

"cointoss" is a minimal R package that provides functions to simulate tossing a coin.

  • coin() creates a coin object (of class "coin")
  • toss() tosses a coin object, producing a "toss" object.
  • plot() method for a "toss" object to plot frequencies of heads.
  • summary() method for a "toss" object.

Motivation

This package has been developed to illustrate some of the concepts behind the creation of an R package.

Installation

Install the development version from GitHub via the package "devtools":

# development version from GitHub:
#install.packages("devtools") 

# install "cointoss" (without vignettes)
devtools::install_github("gastonstat/cointoss")

# install "cointoss" (with vignettes)
devtools::install_github("gastonstat/cointoss", build_vignettes = TRUE)

Usage

library(cointoss)

# default coin
coin1 <- coin()
coin1
#> object "coin"
#> 
#> "heads", p = 0.5 
#> "tails", p = 0.5

# 1 toss of coin1
toss(coin1)
#> object "toss"
#> 
#> coin: "heads", "tails" 
#> total tosses: 1 
#> num of heads: 1 
#> num of tails: 0

# 10 tosses of coin1
toss10 <- toss(coin1, times = 10)
toss10
#> object "toss"
#> 
#> coin: "heads", "tails" 
#> total tosses: 10 
#> num of heads: 1 
#> num of tails: 9

# summary
summary(toss10)
#> summary "toss"
#> 
#>    side count prop
#> 1 heads     1  0.1
#> 2 tails     9  0.9


# 100 tosses
toss100 <- toss(coin1, times = 100)

# summary
summary(toss100)
#> summary "toss"
#> 
#>    side count prop
#> 1 heads    52 0.52
#> 2 tails    48 0.48

cointoss's People

Contributors

gastonstat avatar

Watchers

James Cloos 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.