Primero la Sección de Librerías de Funciones:
# rownames(installed.packages())
list.of.packages <- c(
"arm" ,
"broom" ,
"corrplot" ,
"cowplot" ,
"datasets" ,
"datasets" ,
"dplyr" ,
"eeptools" ,
"estimatr" ,
"FinCal" ,
"formatR" ,
"ggfortify" ,
"ggpubr" ,
"haven" ,
"Hmisc" ,
"infer" ,
"knitr" ,
"lmtest" ,
"margins" ,
"nycflights13" ,
"psych" ,
"readxl" ,
"reshape2" ,
"rms" ,
"skimr" ,
"stargazer" ,
"stringr" ,
"survival" ,
"tableone" ,
"tidyr" ,
"tidyverse" ,
"TTR" ,
"wooldridge" ,
"xlsx"
)
has <- list.of.packages %in% rownames(installed.packages())
if(any(!has)) install.packages(list.of.packages[!has])
Llamada a LIBRERIAS:
# library(arm)
# library(broom)
# library(corrplot)
# library(cowplot)
# library(datasets)
library(dplyr)
# library(eeptools)
# library(estimatr)
library(FinCal)
# library(formatR)
# library(ggfortify)
# library(ggpubr)
library(ggplot2)
# library(haven) #para la lectura de archivos DTA de Stata
# library(Hmisc)
# library(infer)
# library(knitr)
# library(lmtest)
# library(margins)
# library(nycflights13)
# library(psych)
library(readxl)
library(reshape2) #para hacer ReShape (Pivot Tables)
# library(rms)
# library(skimr)
# library(stargazer)
# library(stringr)
# library(survival)
# library(tableone)
library(tidyr) #para hacer ReShape (Pivot Tables)
library(tidyverse)
library(TTR) #para las graficas de series de tiempo
# library(wooldridge)
library(xlsx) #para exportar a Excel file
A partir de aquí la Sección de Importación de Datasets:
getwd() #get to show me the current Working Directory
[1] "/cloud/project"
### Cargando BBDD: n5ay5qadfe7e1nnsv5s01oe1x62mq51j.csv ####
# Version de BBDD: 2021.09.24 v1
# RUTA: https://ibm.box.com/shared/static/
# code to download the dataset
#download.file("https://ibm.box.com/shared/static/n5ay5qadfe7e1nnsv5s01oe1x62mq51j.csv", destfile="movies-db.csv")
# CSV file, Download datasets
download.file("https://ibm.box.com/shared/static/n5ay5qadfe7e1nnsv5s01oe1x62mq51j.csv",
destfile="movies-db.csv")
trying URL 'https://ibm.box.com/shared/static/n5ay5qadfe7e1nnsv5s01oe1x62mq51j.csv'
Content type 'text/csv' length 1424 bytes
==================================================
downloaded 1424 bytes
# XLS file, Download datasets
download.file("https://ibm.box.com/shared/static/nx0ohd9sq0iz3p871zg8ehc1m39ibpx6.xls",
destfile="movies-db.xls")
trying URL 'https://ibm.box.com/shared/static/nx0ohd9sq0iz3p871zg8ehc1m39ibpx6.xls'
Content type 'application/vnd.ms-excel' length 15360 bytes (15 KB)
==================================================
downloaded 15 KB
movies_data <- read.csv("movies-db.csv", header=TRUE, sep=",")
#movies_data
(
my_data <- movies_data
)
NA
NA
REVISION RAPIDA DEL DATAFRAME:
#View(movies_data)
summary(movies_data) # Summary Estadístico.
name year length_min genre average_rating cost_millions foreign
Length:30 Min. :1936 Min. : 81.00 Length:30 Min. :5.200 Min. : 0.400 Min. :0.0
Class :character 1st Qu.:1988 1st Qu.: 99.25 Class :character 1st Qu.:7.925 1st Qu.: 3.525 1st Qu.:0.0
Mode :character Median :1998 Median :110.50 Mode :character Median :8.300 Median : 13.000 Median :0.0
Mean :1996 Mean :116.80 Mean :8.103 Mean : 22.300 Mean :0.4
3rd Qu.:2008 3rd Qu.:124.25 3rd Qu.:8.500 3rd Qu.: 25.000 3rd Qu.:1.0
Max. :2015 Max. :179.00 Max. :9.300 Max. :165.000 Max. :1.0
age_restriction
Min. : 0.00
1st Qu.:12.00
Median :14.00
Mean :12.93
3rd Qu.:16.00
Max. :18.00
head(movies_data) # Primeros 6.
names(movies_data) # Names de columnas.
[1] "name" "year" "length_min" "genre" "average_rating" "cost_millions" "foreign"
[8] "age_restriction"
print(is.data.frame(movies_data))
[1] TRUE
#attach(movies_data) #only if there is only 1 dataset
# CONTENIDO DE TABLA:
# movies_data es la tabla con datos de películas.
A partir de aquí inicia el Cuerpo del Script:
21.09.25.R.Lab08-importingData
Función str (structure)
```{r CUERPO}
Error: attempt to use zero-length variable name