Package 'useR'

Title: Um Curso Introdutório de R
Description: Funções e conjuntos de dados utilizados utilizados para ensinar estatística básica".
Authors: Fabio Demarqui [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-9236-1986>)
Maintainer: Fabio Demarqui <[email protected]>
License: MIT + file LICENSE
Version: 0.0.2
Built: 2026-05-09 08:12:52 UTC
Source: https://github.com/fndemarqui/useR

Help Index


The 'useR' package.

Description

Datasets and functions used to teach statistics with R. _PACKAGE package


Testes de estrada de carros

Description

Este conjunto de dados contém um subconjunto dos dados referente à economia de combustível que a Agência de Proteção do Meio Ambiente (APMA) dos EUA disponibiliza em http://fueleconomy.gov. O conjunto de dados contém apenas modelos que tiveram um novo lançamento a cada ano entre 1999 e 2008 - isso foi usado como um proxy para a popularidade do carro.

Format

Data frame com 234 linhas e 11 variáveis:

montadora

nome da montadora

modelo

nome do modelo

cilindrada

cilindrada do motor, em litros

ano

ano de fabricação

cilindros

número de cilindros

transmicao

tipo de transmição

tracao

tipo de tracao

urb

consumo urbano, em milhas por galão

rod

consumo rodoviário, em milhas por galão

combustível

tipo de combustível

categoria

categoria do carro

Author(s)

Fábio N. Demarqui [email protected]

Source

R package ggplot2.

References

Henderson and Velleman (1981), Building multiple regression models interactively. Biometrics, 37, 391–411.


Cumulative distribution function

Description

This function plots the cumulative distribution function (c.d.f) of a random variable

Usage

cdf(
  x,
  Fx = NULL,
  type = c("discrete", "continuous"),
  dist = c("binom", "pois", "geom", "unif", "exp", "norm"),
  ...
)

Arguments

x

a numeric vector with the observed values of the random variable

Fx

if NULL (default), then Fx is computed using one of the implemented distributions (see description of the dist argument below); otherwise the user must pass the values of Fx

type

type of random variable; either discrete (default) or continuous; this argument is only necessary when Fx is passed by the user

dist

optional; name of the distribution (currently the binomial, poisson and geometric distributions for discrete random variables, or uniform, exponential and normal distribution for continuous random variables)

...

further arguments passed to or from other methods

Value

the desired plot of the cumulative distribution function

Examples

# binomial:
x <- 0:10
cdf(x, dist = "binom", size = 10, prob = 0.7)

# normal:
x <- rnorm(100, mean = 10, sd = 2)
cdf(x, dist = "norm", mean = 10, sd = 2)

Coefficient of Variation

Description

This function computes the coefficient of variation of the values in x. If na.rm is TRUE then missing values are removed before computation proceeds.

Usage

cv(x, percentual = TRUE, ...)

Arguments

x

a numeric vector or an R object but not a factor coercible to numeric by as.double(x).

percentual

logical; if TRUE (default), the coefficient of variation is returned in %.

...

further arguments passed to or from other methods.

Value

the coefficient of variation


Resultados da mega-sena

Description

Resultados da mega-sena

Usage

download_megasena(resultado = c("dezenas", "ganhadores"))

Arguments

resultado

tipo de resultado desejado (dezenas sorteadas ou número de número de ganhadores da sena, quina e quadra)

Value

tibble/data.frame com os resultados da mega-sena.


ENEM 2019 em Belo Horizonte

Description

Conjunto de dados com diversas variáveis relativas à prova do ENEM aplicada em 2019 na cidade de Belo Horizonte.

Format

Tibble com 87365 linhas e 14 variáveis:

idade

em anos

sexo

F - feminino, M - masculino

est_civil

estado civil: NI (não informado), solteiro, divorciado, casado ou viúvo

raca

branco, pardo, negro, amarelo, indígina ou ND (não determinado)

escola

escola de origem: não respondeu, pública, privada ou exterior

lingua_estr

lingua da prova de lingua estrangeira: 0 - inglês, 1 espanhol

nota_CN

nota obtida na prova de ciências naturais

nota_CH

nota obtida na prova de ciências humanas

nota_LC

nota obtida na prova de linguas e códigos

nota_MT

nota obtida na prova de matemática

nota_RD

nota obtida na prova de redação

ESC_pai

pai possui ensino superior completo? não sabe, sim, não

ESC_mae

mae possui ensino superior completo? não sabe, sim, não

renda_fam

renda familiar mensal: A - nenhuma renda; B - até R$ 998,00; C - R$ 998,01 até R$ 1.497,00; D - R$ 1.497,01 até R$ 1.996,00; E - R$ 1.996,01 até R$ 2.495,00; F - R$ 2.495,01 até R$ 2.994,00; G - R$ 2.994,01 até R$ 3.992,00; H - R$ 3.992,01 até R$ 4.990,00; I - R$ 4.990,01 até R$ 5.988,00; J - R$ 5.988,01 até R$ 6.986,00; K - R$ 6.986,01 até R$ 7.984,00; L - R$ 7.984,01 até R$ 8.982,00; M - R$ 8.982,01 até R$ 9.980,00; N - R$ 9.980,01 até R$ 11.976,00; O - R$ 11.976,01 até R$ 14.970,00; P - R$ 14.970,01 até R$ 19.960,00; Q - mais de R$ 19.960,00.

Author(s)

Fábio N. Demarqui [email protected]

Source

Instituto Nacional de Estudos e Pesquisas Educacionais Anísio Teixeira (https://www.gov.br/inep/pt-br/acesso-a-informacao/dados-abertos/microdados).


The Geometric Distribution (Version 2)

Description

The Geometric Distribution (Version 2)

Usage

dgeom2(x, prob, log = FALSE)

pgeom2(q, prob, lower.tail = TRUE, log.p = FALSE)

qgeom2(p, prob, lower.tail = TRUE, log.p = FALSE)

rgeom2(n, prob)

Arguments

x, q

vector of quantiles representing the total number of Bernoulli trials (failures + sucess).

prob

probability of success in each trial. 0 < prob <= 1.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P[Xx]P[X \le x]; otherwise, P[X>x]P[X > x].

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

Details

The geometric distribution with prob = p has density

f(x)=p(1p)x1,f(x) = p(1-p)^{x-1},

for x = 1, 2, 3, ..., and 0<p10 < p \leq 1.

If an element of x is not integer, the result of dgeom2 is zero, with a warning.

The quantile is defined as the smallest value x such that F(x)pF(x) \ge p, where F is the distribution function.

Value

dgeom2 gives the density, pgeom2 gives the distribution function, qgeom2 gives the quantile function, and rgeom2 generates random deviates.

Invalid prob will result in return value NaN, with a warning.

The length of the result is determined by n for rgeom2, and is the maximum of the lengths of the numerical arguments for the other functions.

The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.

rgeom2 returns a vector of type integer unless generated values exceed the maximum representable integer when double values are returned since R version 4.0.0.

See Also

Geometric for the original implementation of the geometric distribution.

NegBinomial2 for the negative binomial (Version 2) which generalizes the geometric distribution (Version 2).


Installation of missing packages

Description

Installation of missing packages

Usage

install_missing_packages(pkg)

Arguments

pkg

a vector containing the names of the packages to be installed.

Value

No return value, called for side effects


Checking if a package is installed

Description

Checking if a package is installed

Usage

is.installed(pkg)

Arguments

pkg

a vector containing the names of the packages to be checked.

Value

a data.frame with the information of the installed packages


The Negative Binomial Distribution (Version 2)

Description

The Negative Binomial Distribution (Version 2)

Usage

dnbinom2(x, size, prob, mu, log = FALSE)

pnbinom2(q, size, prob, mu, lower.tail = TRUE, log.p = FALSE)

qnbinom2(p, size, prob, mu, lower.tail = TRUE, log.p = FALSE)

rnbinom2(n, size, prob, mu)

Arguments

x

vector of (non-negative integer) quantiles.

size

total number of successful trials (failures + successes), or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.

prob

probability of success in each trial. 0 < prob <= 1.

mu

alternative parametrization via mean: see ‘Details’.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

q

vector of quantiles.

lower.tail

logical; if TRUE (default), probabilities are P[Xx]P[X \le x]; otherwise, P[X>x]P[X > x].

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

Details

The negative binomial distribution with size = r and prob = p has density

f(x)=Γ(x)/(Γ(r)(xr)!)pr(1p)xr,f(x) = \Gamma(x)/(\Gamma(r)(x-r)!)p^{r}(1-p)^{x-r},

for r>0r >0 and x = r, r+1, r+2, ...

This represents the total number of trials (failures and sucesses) which occur in a sequence of Bernoulli trials. The mean is μ=n/p\mu = n/p and variance (1p)/p2(1-p)/p^2.

If an element of x is not integer, the result of dnbinom is zero, with a warning.

The case size == 0 is the distribution concentrated at zero. This is the limiting distribution for size approaching zero, even if mu rather than prob is held constant. Notice though, that the mean of the limit distribution is 0, whatever the value of mumu.

The quantile is defined as the smallest value x such that F(x)pF(x) \ge p, where F is the distribution function.

Value

dnbinom2 gives the density, pnbinom2 gives the distribution function, qnbinom2 gives the quantile function, and rnbinom2 generates random deviates.

Invalid size or prob will result in return value NaN, with a warning.

The length of the result is determined by n for rnbinom2, and is the maximum of the lengths of the numerical arguments for the other functions.

The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.

rnbinom2 returns a vector of type integer unless generated values exceed the maximum representable integer when double values are returned since R version 4.0.0.


Hábito nutricional de um grupo de estudantes.

Description

Um grupo de alunos do curso de nutrição da UFF responderam um questionário sobre seus hábitos alimentares em um trabalho de classe passado pelo professor de estatística.

Format

Data.frame com 44 linhas e 9 variáveis:

sexo

M - masculino; F - feminino

idade

idade em anos

peso

peso em quilos

altura

altura e metros

alimentação

possui uma alimentação saudável? (sim; não)

frutas

número médio porções de frutas consumidas por dia

vegetais

número médio de porções de vegetais consumidas por dia

sedentarismo

leva uma vida sedentária? (sim; não)

tempo

tempo médio (em horas) semanal dedicado à prática de atividades físicas: até duas horas, entre 2 e 5 horas, entre 5 e 10 horas, mais de 10 horas

Author(s)

Fábio N. Demarqui [email protected]


Resistência à compressão.

Description

Exemplo 6.4 do livro (Montgomery and Runger 2015). Dados referentes à resistência à compressão (em psi) de 80 corpos de prova de liga de alumínio-lítio.

Format

Data.frame com 80 linhas e uma variável:

resistência

resistência à compressão (em psi) de 80 corpos de prova de liga de alumínio-lítio.

Author(s)

Fábio N. Demarqui [email protected]

References

Montgomery DC, Runger GC (2015). Estatística Aplicada e Probabilidade para Engenheiros, volume 5. LTC, Rio de Janeiro, RJ.


Function to run shiny apps

Description

This functions is used to run shiny apps implemented in the package.

Usage

run_app(app = "tcl_prop")

Arguments

app

name of the app


Cleaning global environment and R search path

Description

This function cleans up the global environment and unload all packages loaded in a previous R session.

Usage

start_clean_session()

Value

No return value, called for side effects