Description Usage Arguments Value Author(s) Examples
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).
1 | create_sample(data, encoding = NULL, weight.colname = NULL)
|
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 |
a sample
Samuel Thiriot <samuel.thiriot@res-ear.ch>
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.