Skip to content

Instantly share code, notes, and snippets.

@LetticiaNicoli
Last active June 6, 2019 00:18
Show Gist options
  • Save LetticiaNicoli/f51d2e44bba6c23883da724dad10dcc5 to your computer and use it in GitHub Desktop.
Save LetticiaNicoli/f51d2e44bba6c23883da724dad10dcc5 to your computer and use it in GitHub Desktop.
R - Obtendo dados
#Obtendo dados com o R
pathName = "C:/Users/logonrmlocal/Documents/Aula/data";
#Download
dir.create(pathName)
file.url = 'http://www.bcb.gov.br/pec/Indeco/Port/IE1-04.xlsx'
file.local = file.path('./Aula/data', basename(file.url))
download.file(url = file.url, destfile = file.local , mode='wb')
#Function Download
funcDownload = function(link){
if(!file.exists(pathName)){
dir.create(pathName)
}
file.local = file.path('./Aula/data', basename(link))
download.file(url = link, destfile = file.local , mode='wb')
}
funcDownload("https://raw.githubusercontent.com/elthonf/fiap-mba-r/master/data/Copas.csv")
funcDownload("https://raw.githubusercontent.com/elthonf/fiap-mba-r/master/data/Copas-Partidas.csv")
funcDownload("https://raw.githubusercontent.com/elthonf/fiap-mba-r/master/data/Copas-Jogadores.csv")
#Read File
copasRead = read.table('Aula/data/Copas.csv')
library(readr)
Copas <- read_csv("Aula/data/Copas.csv")
View(Copas)
partidas = read.table('Aula/data/Copas-Partidas.csv',fill = TRUE)
#Fill corrige campos nao preenchidos
View(partidas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment