# Información Sesion
Información Sesion
sessionInfo()
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
##
## locale:
## [1] LC_CTYPE=es_ES.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=es_ES.UTF-8 LC_COLLATE=es_ES.UTF-8
## [5] LC_MONETARY=es_ES.UTF-8 LC_MESSAGES=es_ES.UTF-8
## [7] LC_PAPER=es_ES.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## loaded via a namespace (and not attached):
## [1] compiler_4.0.2 magrittr_1.5 tools_4.0.2 htmltools_0.5.0
## [5] yaml_2.2.1 stringi_1.5.3 rmarkdown_2.4 knitr_1.30
## [9] stringr_1.4.0 xfun_0.18 digest_0.6.25 rlang_0.4.7
## [13] evaluate_0.14
cat("\014")
# Generamos función
clc <- 0
class(clc) <- 'limpiar'
print.limpiar <- function(rObject) cat("\014")
## [1] "/home/oscar/Documentos/Medium/crosstalk_R"
#devtools::install_github("rstudio/crosstalk")
#devtools::install_github("jcheng5/d3scatter")
#devtools::install_github("rstudio/leaflet")
packages <- c("dplyr", "DT", "crosstalk","d3scatter","leaflet")
newpack = packages[!(packages %in% installed.packages()[,"Package"])]
if(length(newpack)) install.packages(newpack)
a=lapply(packages, library, character.only=TRUE)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
beer <- read.csv("./beer_dataset_clean.csv")
head(beer)
## Style Size.L. OG FG ABV IBU Color BoilSize BoilTime
## 1 American IPA 10.41 1.0620 1.0090 6.95 19.91 5.46 12.30 60
## 2 American Pale Ale 5.00 14.0118 2.3984 6.24 42.07 8.12 10.00 60
## 3 American Pale Ale 22.00 1.0540 1.0130 5.39 21.63 9.64 26.00 60
## 4 American Pale Ale 10.00 1.0520 1.0100 5.62 67.70 11.72 17.50 60
## 5 Saison 20.82 1.0540 1.0070 6.08 12.90 3.14 24.61 90
## 6 American IPA 17.00 1.0510 1.0120 5.09 39.74 7.07 21.00 60
## BoilGravity Efficiency SugarScale BrewMethod
## 1 1.014 35 Specific Gravity extract
## 2 7.200 71 Plato BIAB
## 3 1.046 75 Specific Gravity All Grain
## 4 1.030 70 Specific Gravity BIAB
## 5 1.039 85 Specific Gravity BIAB
## 6 1.041 75 Specific Gravity All Grain
shared_beer <- SharedData$new(beer)
bscols(widths = c(3,NA,NA),
list(
filter_checkbox("Style", "Estilo", shared_beer, ~Style, inline = TRUE),
filter_slider("IBU", "Amargor", shared_beer, ~IBU, width = "100%"),
filter_select("ABV", "Alcohol", shared_beer, ~ABV)
),
d3scatter(shared_beer, ~ABV, ~IBU, ~factor(Style), width="100%", height=450),
d3scatter(shared_beer, ~Color, ~ABV, ~factor(Style), width="100%", height=450)
)
bscols(
d3scatter(shared_beer, ~Color, ~ABV, ~Style, width="100%", height=450),
d3scatter(shared_beer, ~Color, ~IBU, ~Style, width="100%", height=450)
)
row.names(beer) <- NULL
sd_beer_all <- SharedData$new(beer, group = "beer_subset")
sd_beer_auto <- SharedData$new(beer[beer$SugarScale == "Specific Gravity",],
group = "beer_subset")
sd_beer_manual <- SharedData$new(beer[beer$SugarScale == "Plato",],
group = "beer_subset")
bscols(widths = c(8, 4),
d3scatter(sd_beer_all, ~IBU, ~Color, ~factor(Style),
x_lim = ~range(IBU), y_lim = ~range(Color),
width = "100%", height = 500),
list(
d3scatter(sd_beer_auto, ~IBU, ~Color, ~factor(Style),
x_lim = range(beer$IBU), y_lim = range(beer$Color),
width = "100%", height = 250),
d3scatter(sd_beer_manual, ~IBU, ~Color, ~factor(Style),
x_lim = range(beer$IBU), y_lim = range(beer$Color),
width = "100%", height = 250)
)
)
###Carga de dataset
data <- read.csv("./datos_limpios_eolicos.csv")
head(data)
## Name Country City On_service
## 1 Dithmarschen Alemania Dithmarschen Unknown
## 2 Wesselburen Alemania Wesselburen Unknown
## 3 Côte de lâ\u0080\u0099Epinette Francia La Chaussee sur Marne 2002/11
## 4 Le Quarnon Francia Pogny 2005/01
## 5 Donzère Francia Donzère 1999/09
## 6 Tarcienne Belgica Walcourt 2005/12
## Energy_power On_service.1 Latitude Longitude Tower_length Province
## 1 2250 si 54.32000 9.189972 Unknown Schleswig-Holstein
## 2 1500 si 54.21997 8.929972 Unknown Schleswig-Holstein
## 3 1500 si 48.85528 4.528750 Unknown 51
## 4 4000 si 48.86225 4.520944 Unknown 51
## 5 3000 si 44.45000 4.750000 Unknown 26
## 6 9000 si 50.30281 4.504472 Unknown Namur
## CCAA Power_KW Diameter_mts Brand Model Towers
## 1 Schleswig-Holstein 0 0 Unknown 0
## 2 Schleswig-Holstein 0 0 Unknown Unknown 0
## 3 Grand Est 0 0 Unknown Unknown 0
## 4 Grand Est 2000 82 Repower MM82 2
## 5 Auvergne-Rhône-Alpes 600 43 Nordex N43/600 5
## 6 Wallonie 1500 77 Repower MD77 6
df <- data %>%
select(-On_service,-City,-On_service.1,-Latitude,-Longitude,-Province,-CCAA)
colnames(df) <- c("Name", "Country", "Energy", "Tower L", "Power", "Diameter", "Brand", "Model", "Num.Tow")
dim(df)
## [1] 14330 9
library(DT)
datatable(
df, options = list(search = list(regex = TRUE, caseInsensitive = FALSE, search = ' ', escape=FALSE,
options = list(sDom = '<"top">lrt<"bottom">ip')),
filter = list(position = 'top', selection='multiple', clear = FALSE),
pageLength = 10,
lengthMenu = c(10, 10, 10, 10, 10, 10, 10, 10, 10)
)
)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html
## Dataset con filtros por atributo
# individual column filters
datatable(df, options = list(searchHighlight = TRUE), filter = 'top')
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html
options(DT.options = list(pageLength = 5))
# global search
datatable(df, options = list(searchHighlight = TRUE,
search = list(search = 'da')))
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html
data1 <- data%>%
dplyr::select(Latitude, Longitude, Energy_power, Power_KW, Diameter_mts)%>%
rename(
lat = Latitude,
long = Longitude,
depth = Energy_power,
mag = Power_KW,
stations = Diameter_mts
)
## Assuming "long" and "lat" are longitude and latitude, respectively
sd <- SharedData$new(data1[sample(nrow(data1), 1000),]) # Wrap data frame in SharedData
filter_slider("mag", "Power KW", sd, column=~mag, step=0.1, width=450) # Create a filter input
# Use SharedData like a dataframe with Crosstalk-enabled widgets
bscols(
leaflet(sd) %>%
addTiles() %>%
addMarkers(),
datatable(sd,
extensions="Scroller", style="bootstrap",
class="compact", width="100%",
options=list(deferRender=TRUE, scrollY=300,
scroller=TRUE))
)
## Assuming "long" and "lat" are longitude and latitude, respectively