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(cryptoQuotes) | |
# | |
x <- data(ATOMUSDT) #sample data, USDT denominated ATOMS | |
# Start here to learn what is available. 5 available functions and 6 add functions in the library | |
# add functions highlight visuals | |
# Etherium ETH, Litecoin LTC, Bitcoin Cash BCH | |
# See if you can use Litecoin or Ripple(XRP). ETH is ok below for Medium article. | |
availableTickers(source = "bitmart", futures = TRUE) | |
availableIntervals(source = "binance", futures = TRUE) |
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(gt) | |
library(readxl) | |
table <- read_xlsx("Table_trial.xlsx") | |
table_gt <- gt(table) | |
table_gt <- | |
table_gt |> | |
tab_header( | |
title = "Sales during campaign", |
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
# November 13th, 2023 | |
library(quantmod) | |
startdate <- "2015-01-05" | |
gmprices <- getSymbols('GM', from=startdate, auto.assign = F) | |
head(gmprices,10) | |
gmreturn <- ROC(gmprices, type="discrete") | |
print(gmreturn) | |
# explore Delt function -- can I use GM column of open and close | |
chart_Series(gmreturn) | |
# |
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
# November 4th, 2023 | |
# | |
# dbinom(k,n,p) | |
# k - value at which probability must be determined | |
# n - number of trials | |
# p - probability of success on each trial | |
# | |
# Discrete probability distribution -- Probability of a die side(x) being equal to 3 based on 20 tries | |
die_side3 <- dbinom(x=3, size= 20, prob=1/6) | |
# [1] 0.2378866 |
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(markovchain) | |
# library includes data called rain | |
# Up to date as of November 3rd | |
# define transition matrix using random normal probabilities | |
Weather<- c("Sunny", "Rain") | |
Weatherchange <- matrix(c(0.9,0.1,0.5,0.5), nrow=2, byrow= TRUE, dimnames = list(Weather, Weather)) | |
Weatherchange | |
# Matrix is a Discrete Time Markov Chain | |
WeatherZone <- new("markovchain", |
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(ggplot2) | |
library(GGally) | |
# pairs(df) dataframe used in the plot | |
cars <- gt::gtcars | |
carsspecs <- data.frame(cars$hp,cars$trq, cars$mpg_c, cars$mpg_h) | |
carsspecs <- carsspecs[-40,] | |
pairs(carsspecs) | |
# diagonal boxes are for variables | |
# no statistical summaries; ggpairs from GGally provides that via correlations and a distribution of data |
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(Hmisc) # for cut2 | |
# Note: The dataset gtcars is from the gt library | |
carset <- gt::gtcars | |
cutpoints <- cut2(carset$mpg_c, g=3, onlycuts=TRUE) # shows only the cut points | |
bins <- cut2(carset$mpg_c, g=3) | |
car_bins<- data.frame(carset$mfr, carset$model, bins) # shows which vehicle is in which bin | |
bins_cap <- cut2(carset$mpg_c, g=3,include.lowest = T, right = T) | |
car_bins<- data.frame(carset$mfr, carset$model, bins_cap) |
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
# Posted: Sept 3rd, 2023 | |
# | |
# searchConsoleR download data from Google Search Console | |
library(searchConsoleR) | |
# factoextra provides the dendrogram function fviz_dend | |
library(factoextra) | |
# | |
# for plotting side by side | |
library(gridExtra) |
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(Hmisc) | |
carset <- gt::gtcars | |
mileage <- cut2(carset$mpg_c, c(0,15,20,25,30,35)) | |
mileage_min <- cut2(carset$mpg_c, m=10) | |
mileage_quant <- cut2(carset$mpg_c, g=2) | |
table(cut2(carset$mpg_c, m=10)) | |
table(cut2(carset$mpg_c, g=2)) |
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
# Note: The dataset gtcars is from the gt library | |
carset <- gt::gtcars | |
mileage <- cut(carset$mpg_c, breaks = c(0,15,20,25,30,35)) | |
mileage_label <- cut(carset$mpg_c,breaks = c(0,15,20,25,30,35),labels = c("extremely low", "low", "midpack", "high", "extremely high")) | |
# Note: The number of labels must match the number of bins | |
price <- cut(carset$msrp, breaks = c(0,75000,100000,200000,Inf), ordered_result=T, labels = c("premium", "luxury", "ultra luxury", "exclusive")) |
NewerOlder