| 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 |
Datasets and functions used to teach statistics with R. _PACKAGE package
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.
Data frame com 234 linhas e 11 variáveis:
nome da montadora
nome do modelo
cilindrada do motor, em litros
ano de fabricação
número de cilindros
tipo de transmição
tipo de tracao
consumo urbano, em milhas por galão
consumo rodoviário, em milhas por galão
tipo de combustível
categoria do carro
Fábio N. Demarqui [email protected]
R package ggplot2.
Henderson and Velleman (1981), Building multiple regression models interactively. Biometrics, 37, 391–411.
This function plots the cumulative distribution function (c.d.f) of a random variable
cdf( x, Fx = NULL, type = c("discrete", "continuous"), dist = c("binom", "pois", "geom", "unif", "exp", "norm"), ... )cdf( x, Fx = NULL, type = c("discrete", "continuous"), dist = c("binom", "pois", "geom", "unif", "exp", "norm"), ... )
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 |
the desired plot of the cumulative distribution function
# 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)# 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)
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.
cv(x, percentual = TRUE, ...)cv(x, percentual = TRUE, ...)
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. |
the coefficient of variation
Resultados da mega-sena
download_megasena(resultado = c("dezenas", "ganhadores"))download_megasena(resultado = c("dezenas", "ganhadores"))
resultado |
tipo de resultado desejado (dezenas sorteadas ou número de número de ganhadores da sena, quina e quadra) |
tibble/data.frame com os resultados da mega-sena.
Conjunto de dados com diversas variáveis relativas à prova do ENEM aplicada em 2019 na cidade de Belo Horizonte.
Tibble com 87365 linhas e 14 variáveis:
em anos
F - feminino, M - masculino
estado civil: NI (não informado), solteiro, divorciado, casado ou viúvo
branco, pardo, negro, amarelo, indígina ou ND (não determinado)
escola de origem: não respondeu, pública, privada ou exterior
lingua da prova de lingua estrangeira: 0 - inglês, 1 espanhol
nota obtida na prova de ciências naturais
nota obtida na prova de ciências humanas
nota obtida na prova de linguas e códigos
nota obtida na prova de matemática
nota obtida na prova de redação
pai possui ensino superior completo? não sabe, sim, não
mae possui ensino superior completo? não sabe, sim, não
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.
Fábio N. Demarqui [email protected]
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)
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)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)
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 |
vector of probabilities. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required. |
The geometric distribution with prob = p has density
for x = 1, 2, 3, ..., and .
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 , where F is the distribution function.
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.
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
install_missing_packages(pkg)install_missing_packages(pkg)
pkg |
a vector containing the names of the packages to be installed. |
No return value, called for side effects
Checking if a package is installed
is.installed(pkg)is.installed(pkg)
pkg |
a vector containing the names of the packages to be checked. |
a data.frame with the information of the installed packages
The Negative Binomial Distribution (Version 2)
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)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)
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 |
vector of probabilities. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required. |
The negative binomial distribution with size = r and prob = p has density
for 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 and variance .
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 .
The quantile is defined as the smallest value x such that , where F is the distribution function.
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.
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.
Data.frame com 44 linhas e 9 variáveis:
M - masculino; F - feminino
idade em anos
peso em quilos
altura e metros
possui uma alimentação saudável? (sim; não)
número médio porções de frutas consumidas por dia
número médio de porções de vegetais consumidas por dia
leva uma vida sedentária? (sim; não)
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
Fábio N. Demarqui [email protected]
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.
Data.frame com 80 linhas e uma variável:
resistência à compressão (em psi) de 80 corpos de prova de liga de alumínio-lítio.
Fábio N. Demarqui [email protected]
Montgomery DC, Runger GC (2015). Estatística Aplicada e Probabilidade para Engenheiros, volume 5. LTC, Rio de Janeiro, RJ.
This functions is used to run shiny apps implemented in the package.
run_app(app = "tcl_prop")run_app(app = "tcl_prop")
app |
name of the app |
This function cleans up the global environment and unload all packages loaded in a previous R session.
start_clean_session()start_clean_session()
No return value, called for side effects