This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variavel_numerica <- c(1,5,4,7) | |
variavel_caracteres <- c("Olá mundo") | |
logicos <- c(TRUE, FALSE, TRUE) | |
inteiros <- c(1L, 2L, 3L) | |
class(variavel_numerica) | |
class(variavel_caracteres) | |
class(logicos) | |
class(inteiros) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
valor.na <- NA | |
valor.null <- NULL | |
valor.infinito <- Inf; | |
valor.menos.infinito <- -Inf | |
valor.nan <- NaN | |
vetor.com.null <- c(10,10,10,NULL) | |
vetor.com.null | |
valor.nan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adição | |
adicao <- 5+5 | |
adicao | |
# Subtração | |
subtracao <- 5-5 | |
subtracao | |
# Multiplicação | |
multiplicao <- 5*5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vetor <- c(10,15,20) | |
vetor * 2 | |
# SAÍDA: 20 30 40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sexo <- c("Feminino", "Masculino","Feminino", "Masculino","Feminino", "Masculino","Feminino", "Masculino","Feminino", "Masculino") | |
fatorado <- as.factor(sexo); | |
fatorado | |
#SAÍDA: Levels: Feminino Masculino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v1 <- c(1, 2, 3); | |
v2 <- c(T, F, T); | |
v3 <- c("a", "b", "c"); | |
lista <- list(v1, v2, v3) | |
class(lista) | |
lista | |
#SAÍDA: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matriz <- matrix(ncol = 6, nrow = 5, data = 1:5) | |
matriz | |
#SAÍDA : | |
# 1 1 1 1 1 1 | |
# 2 2 2 2 2 2 | |
# 3 3 3 3 3 3 | |
# 4 4 4 4 4 4 | |
# 5 5 5 5 5 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrizA <- matrix(ncol = 5, nrow = 5, data = 1:5) | |
matrizB <- matrix(ncol = 5, nrow = 5, data = 1:5) | |
# Esta operação abaixo não é uma multiplicação de matrizes, é apenas uma multiplicação de valores. | |
matriz <- matrizA * matrizB | |
matriz | |
# 1 1 1 1 1 | |
# 4 4 4 4 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linhas <- 5 | |
colunas <- 10 | |
matrizA <- matrix(ncol = linhas, nrow = colunas, data = 1:2) | |
matrizB <- matrix(ncol = colunas, nrow = linhas, data = 1:2) | |
matrizA %*% matrizB | |
#SAÍDA: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrizA <- matrix(ncol = 2, nrow = 2, data = 1:4) | |
dim(matrizA) #dimensões da matriz | |
t(matrizA) #transposta | |
diag(matrizA) #identidade | |
solve(matrizA) #inversa, esta deve ser quadrada |