Fuente de Datos

DIEGO PAOLO LOZANO GODOS - UNIVERSIDAD NACIONAL DE TRUJILLO
5 DE MAYO DEL 2018

Fuentes Comunes

Para txt y csv (Version Antigua)

datos <- read.table(file = “C:/Users/Mauricio/Desktop/datos_ejemplos.csv”, header = TRUE, col.names = c(“fecha”, “cliente”, “producto”, “precio”), stringsAsFactors = FALSE, sep = “,”, dec = “.”)

Para txt

data <- read.table(“PrecioVivienda.txt”, header= T)

Para Csv

data <- read.csv(“train.csv”,header = T) (data.table) datos <- fread(input = “C:/U

Fuentes Comunes

Para Grandes Volumenes de Datos

library(data.table)

datos <- fread(input = “C:/Users/Mauricio/Desktop/datos_ejemplos.csv”, header = TRUE, col.names = c(“fecha”, “cliente”, “producto”, “precio”), data.table = FALSE, sep = “,”, dec = “.”, showProgress = TRUE)

data = fread(“train.csv”, header=T)

EXCEL

library(read.xlsx) read.xlsx(file = “planilla_excel_ejemplo.xlsx”, sheetIndex = 1)

Otras Fuentes

JSON

library(jsonlite) archivo <- “r_ejemplo_json.json” con <- file(archivo, open=“r”) ejemplo_json <- readLines(con) close(con) datos <- fromJSON(ejemplo_json) fromJSON(ejemplo_json)

SPSS

library(foreign) datos=read.spss(“RIESGO CREDITICIO.sav”,use.value.labels=TRUE, max.value.labels=TRUE,to.data.frame=TRUE) str(datos)

Otras Fuentes

CONEXION DE R - SQL

library(RODBC) canal_bd <- odbcDriverConnect('driver={SQL Server}; server=DESKTOP-B73VN1H; database=RICOPAN; trusted_connection=true')

resultado <- sqlQuery(canal_bd, 'select * from RICOPAN.dbo.CLIENTE')
odbcClose(canal_bd) names(resultado)