This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(TSstudio) | |
# Loading the data | |
data(USgas) | |
# Creating lags | |
df <- ts_to_prophet(USgas) | |
# Will use the seasonal lag (12) of the series | |
df$y_12 <- dplyr::lag(df$y, n = 12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=================================================================================================================== | |
# Author: Aloysius Ong | |
# Dataset: #tidytuesday - Astronauts | |
# Purpose: Visualization | |
#=================================================================================================================== | |
astronauts <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-07-14/astronauts.csv') | |
library(plotly) | |
library(dplyr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ts.obj <- tsibble::tourism | |
int <- vctrs::vec_data(base::attributes(ts.obj)$interval) | |
s <- NULL | |
for(i in names(int)){ | |
if(int[[i]] == 1){ | |
s <- i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet dd | |
devtools::document() | |
snippet m | |
`%>%` <- magrittr::`%>%` | |
snippet l | |
lubridate:: | |
snippet > | |
%>% | |
snippet t | |
TSstudio:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the file name | |
file_name <- "https://raw.githubusercontent.com/VIS-SIG/Wonderful-Wednesdays/master/data/2020/2020-12-09/Reexcision.csv" | |
# Read the unparsed table | |
x <- readLines(con <- file(file_name)) | |
# Parse the table names | |
z <- unlist(strsplit(x[1], ";", fixed = TRUE)) | |
z <- unlist(strsplit(x[1], '\"')) | |
x_names <- z[which(z !=";" & z != "")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://plotly.com/r/bar-charts/ | |
library(plotly) | |
Animals <- c("giraffes", "orangutans", "monkeys") | |
SF_Zoo <- c(20, 14, 0) | |
LA_Zoo <- c(12, 18, 29) | |
data <- data.frame(Animals, SF_Zoo, LA_Zoo) | |
fig <- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') | |
fig <- fig %>% add_trace(y = ~LA_Zoo, name = 'LA Zoo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(i in 1:21){ | |
if(i == 1){ | |
#if first year | |
y <- 350 | |
x <- 0 | |
} else { | |
# else increasing every year by 20% | |
y <- y * 1.2 | |
} | |
x <- x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("https://cran.r-project.org/src/contrib/Archive/MissMech/MissMech_1.0.2.tar.gz", repos=NULL, type="source") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://shiny.rstudio.com/reference/shiny/0.14/bookmarkButton.html | |
# Changes - using navbarPage instead of tabsetPanel | |
ui <- function(request) { | |
fluidPage( | |
navbarPage(title = "Bookmark Multi Tabs Example", | |
id = "navbar", | |
position = "static-top", | |
theme = shinythemes::shinytheme("yeti"), | |
tabPanel("One", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pulling Covid19 Isreal data | |
# Source - https://data.gov.il/dataset/covid-19/resource/d07c0771-01a8-43b2-96cc-c6154e7fa9bd | |
# Set the query's number of rows limit | |
limit <- 1000000 | |
# Method 2 | |
# Using httr to pull the data and jsonlite to parse the data | |
q <- httr::GET( |