Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Linguagem R

Breve apresentação sobre linguagem de programação R

Estrutura/InstruçõesApresentação
Linguagem de Programação R É uma linguagem e um ambiente de desenvolvimento integrado, para cálculos estatísticos e gráficos.
Atribuição a variáveis Não é necessário declará-las: x <- 5 y = 7 ou assing("y",7)
Lista objetos (variáveis) criadas ls()
Para limpar o console Ctrl+L
Para sair q()
Salvar os objetos save("meusObjetos.RData")
Carregar objetos de um arquivo load("meusObjetos.RData")
Para carregar um arquivo de texto em um objeto medidas<-scan(file = "analise.txt")
Para ler do teclado notas<-scan()
Criar um vetor a = C(1,2,3)
concatenar/combinar a = c(1,2,3) b = (4,5,6) c = c(a,b)
Funções sobre vetores Intervalo: range Comprimento: length somatório: sum, cumsum produtório: prod, cumprod média: mean variância: var Máximo e mínimo: max, min , range
Ordenação sort(vetor,decreasing = TRUE) order rank
Ordenação inversa de vetores rev(vetor,decreasing = TRUE)
Para gerar um intervalo Usa-se dois pontos v = c(1:100)
Outros tipos de Objetos Matrizes fatores listas data frames funções
Declaração de tipos numérico complexo lógico caractere bruto
Criação de matrizes dim(mat) = c(15,10)
Criação de listas list(nome="x",mulher="y",num.animais=2,idade.animais=c(0,1))
Demonstrações de Graficos Exemplos demo(graphics) demo(persp) demo(image) demo(smooth)
operadores logicos ==, !=, <, >, <=, >=
Exemplo de recursividade fibonacci = function(n){ if(x<2)return(n) else return(fibonacci(x - 1)+fibonacci(x-2))
Acessando elementos do vetor A[2] D[-4] D[2:4]
Modificando elementos do vetor A[2] <- 5
Criando vetores a partir de sequências S1 <- seq(10)
Somatório Soma_D = sum(D)
Média ('Mean') Media_D = mean(D)
Mediana ('Median') Mediana_D = median(D)
Desvio padrão ('Standard deviation') DP_D = sd(D)
Plotando gráficos comuns boxplot(N) boxplot(data.frame(N))
Para carregar um script source('nome_do_script.R')
Dando nomes aos campos notas <- c(7.5, 8, 5.7) names(notas) <- c('Joao', 'Pedro')
O pacote R Diretório de trabalho Menu Pacotes Linhas de comando: setas para voltar Tipos de objetos: vector, matrix, array, factor, data.frame, list, function
Informações gerais: Use ponto “.” para casas decimais. Exceto em raras ocasiões, use sempre letras minúsculas. Feche o parêntese assim que abri-lo.
Fazer conjuntos de dados data.frame()
Paradigma multi-paradigma: sequencialização, orientado a objetos, imperativo, dinâmico, processual
Tipagem da linguagem Tipagem dinâmica
Ajuda do R help(comando)- Ajuda rápida sobre um comando help.start() - Inicia a ajuda no browser
Carregando Dados e Bibliotecas require(nome_pacote) – Carregar um pacote library (nome_pacote) – Carregar um pacote data(nome_dos_dados) – Carregar um conjunto de dados
Roda os comandos de um arquivo source(“arquivo“)
Lê os comandos de um arquivo read.table(“arquivo“)
Algumas Funções Matemáticas sin cos tan – Funções trigonométricas sinh cosh tanh – Funções hiperbólicas exp log - Exponencial e logarítmo natural log10 – Logarítmo base 10
Para fazer comentários usa-se # # exemplo 01
Criar função function(função)
Informar e alterar o diretório de trabalho getwd e setwd
Força do R Gráficos estátisticos
remove objetos rm()
Mostra os 25 últimos comandos history
Para introduzir um script no interpretador source("script.r") # rodará o script.r
Condicional IF-ELSE if (condição) f bloco de comandos g else f bloco de comandos g SWITCH switch(condição, caso1, caso2, caso3) IFELSE ifelse(condição, yes, no)
Repetição FOR for (var in seq) f bloco de comandos g WHILE while (condição) f bloco de comandos g
Funções eleva3<-function(a){ return(a*a*a); } eleva3(3)
Lendo Dados dataset <- read.table ("datafile.dat", header=TRUE) Para obter os vetores dataset\$tamanho_lote dataset\$homens_hora
Created by: fimiranda
Popular Engineering sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards