create_sample: Creates a sample organized for dpp manipulation.

Description Usage Arguments Value Author(s) Examples

Description

The resulting object contains the sample and a dictionary of data. If no weight column is provided, one will be created with value 1 (uniform weights).

Usage

1
create_sample(data, encoding = NULL, weight.colname = NULL)

Arguments

data

a data frame containing a sample (weighted list) of entities

encoding

a dictionary containing information about the variables of the sample

weight.colname

the name of the column containing the weights

Value

a sample

Author(s)

Samuel Thiriot <samuel.thiriot@res-ear.ch>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# to read a CSV file as a sample
f <- system.file("extdata", "logements.csv", package = "gosp.dpp")
m <- read.csv(f, sep=";", dec=",", check.names=FALSE)
df <- as.data.frame(m, check.names=FALSE)
dictionary <- list('surface'=list('small'=1, 'medium'=2, 'large'=3))
create_sample(data=df, encoding=dictionary, weight.colname="weight")

# to create a sample from random data
# ... create 100 entities being either male of female
df <- data.frame(gender=sample(1:2, size=100, replace=TRUE))
# ... describe the encoding of data
dictionary <- list("gender"=list("male"=1,"female"=2))
create_sample(data=df, encoding=dictionary)
# ... the weights columns was created automatically

samthiriot/gosp.dpp documentation built on May 18, 2019, 3:44 p.m.