- 🔭 I’m currently working on a [personal project][website]!
- 🌱 I’m currently learning Data Science and Analytics 🤣
- 👯 I’m looking to collaborate with other content creators
- 🥅 2020 Goals: Give impact to society
- ⚡ Fun fact: I love blogging, reading books, and drawing
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
name: Latest Medium story workflow | |
on: | |
schedule: | |
# Runs every hour | |
- cron: '0 * * * *' | |
workflow_dispatch: | |
jobs: | |
update-readme-with-blog: | |
name: Update this repo's README with latest Medium post |
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
# Function to conduct simulation | |
generate_beta = function(ti, rho, repetition) { | |
# Vector intercept and slope | |
vector_intercept_auto = rep(x = 0, len = repetition) | |
vector_slope_auto = rep(x = 0, len = repetition) | |
vector_intercept_non = rep(x = 0, len = repetition) | |
vector_slope_non = rep(x = 0, len = repetition) | |
j = 1 | |
while (j < (repetition + 1)) { |
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 package | |
install.packages('tidyr') | |
# Load the package | |
library(tidyr) | |
# Data melting | |
long = df %>% | |
gather(Coefficient, Value, -c(Rho)) | |
# Create a new column indicating whether it is intercept or slope | |
long$Status = ifelse(substring(long$Coefficient, 1, 9) == 'intercept', 'Intercept', 'Slope') |
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 package | |
install.packages('dplyr') | |
# Load the package | |
library(dplyr) | |
# Create a data aggregation | |
statDf = df %>% | |
group_by(Rho) %>% | |
summarize( | |
# Without autocorrelation |
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 package | |
install.packages('ggplot2') | |
# Load the package | |
library(ggplot2) | |
# Without autocorrelation - intercept | |
df_InterceptNonAutocorrelation = long %>% | |
filter(Coefficient == 'interceptNonAutocorrelation') | |
unique(df_InterceptNonAutocorrelation$Rho) | |
ggplot(data = df_InterceptNonAutocorrelation)+ |
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
# Modules for web scraping | |
import requests | |
from bs4 import BeautifulSoup | |
# Module for data manipulation | |
import pandas as pd | |
# Module for regular expression | |
import re | |
# Module for file management | |
import os | |
# Module for timing |
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
def get_url(): | |
# URL | |
url = 'https://www.kompas.com/covid-19' | |
page = requests.get(url) | |
# Wrangling HTML with BeautifulSoup | |
soup = BeautifulSoup(page.content,'html.parser') | |
return(soup) |
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
# Create dictionary for date manipulation | |
dict_month = {'Januari':'01','Februari':'02','Maret':'03','April':'04','Mei':'05','Juni':'06','Juli':'07','Agustus':'08','September':'09','Oktober':'10','November':'11','Desember':'12'} | |
# Function to get the current date | |
def get_current_date(**kwargs): | |
date_scrape = soup.find('span',class_='covid__date').text | |
date_scrape = re.findall(r'Update terakhir: (\S+.+WIB)',date_scrape)[0].replace(', ',',') | |
date = date_scrape.split(',')[0] | |
time = date_scrape.split(',')[1] | |
# Date manipulation | |
date_format = re.findall(r'\w+',date)[0] |
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
# Function to get the daily aggregated data | |
def get_daily_summary(**kwargs): | |
soup = get_url() | |
date,time = get_current_date() | |
# Get summary | |
# Regular expression pattern | |
pattern_summary = re.compile(r'\d[^\s]+') | |
for job_elem in soup.find_all('div',class_='covid__box'): | |
# Each job_elem is a new BeautifulSoup object. | |
terkonfirmasi_elem = job_elem.find('div',class_='covid__box2 -cases') |
OlderNewer