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
## Setup | |
```r | |
library(knitr) | |
knitr::opts_chunk$set(echo = TRUE) | |
## Installing dev versions of plotly with new data.table group2NA() | |
library(devtools) | |
library(withr) | |
library(ggplot2,lib.loc = "/home/Matthew14786/dev/") |
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(shiny) | |
library(BatchGetSymbols) | |
ui <- fluidPage( | |
textInput('stock','stock',"GE"), | |
sliderInput('length', 'length', min = 1, max = 100, value = 50), | |
dataTableOutput('my_table') | |
) | |
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(data.table) | |
dta <- data.table(gr = LETTERS[1:3], | |
a = 1, | |
b = 1) | |
add <- function(x, y, group) if(group == "B") x + y else x - y | |
dta[,.BY, by = .(gr)] |
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(arrow) | |
## Open source Apache Spark downloaded from this archive: | |
## https://archive.apache.org/dist/spark/spark-3.0.1/spark-3.0.1-bin-hadoop2.7.tgz | |
library(SparkR, lib.loc = "~/DatabricksTesting/spark-3.0.1-bin-hadoop2.7/R/lib/") | |
## $java -version | |
## openjdk version "1.8.0_212" | |
## OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.16.04.1-b03) | |
## OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode) |
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
## /home/matthew14786/DatabricksTesting/Python-3.7.5/python | |
## installed (no explicit import) pyarrow version 3.0.0 | |
import numpy as np ## numpy version 1.20.1 | |
import pandas as pd ## pandas version 1.2.3 | |
import pyspark ## pypark version 7.3.9 | |
from pyspark.sql import SQLContext | |
from pyspark.sql.types import IntegerType | |
from pyspark.sql.types import LongType |
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
import numpy as np ## numpy version | |
import pandas as pd ## pandas version | |
import pyspark ## pypark version | |
from pyspark.sql import SQLContext | |
from pyspark.sql.types import IntegerType | |
from pyspark.sql.types import LongType | |
## Define dataframe row count | |
L = 5*365*86400 |
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(data.table) | |
library(fastmatch) | |
#' Add rows to a data table in a memory efficient, by-referencesque manner | |
#' | |
#' This mimics the by-reference functionality `DT[, new_col := value]`, but | |
#' for rows instead. The rows in question are assigned at the end of the data | |
#' table. If the data table is keyed it is automatically reordered after the | |
#' operation. If not this function will preserve order of existing rows, but | |
#' will not preserve sortedness. |
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(circular) | |
## Helper function to generate a circular object in degrees, 0-360 | |
circularDeg <- function(x) circular(x,template = "geographics",units = "degrees", modulo = "2pi") | |
theta <- circularDeg(seq(from = 0, to = 360,by = 1)) | |
m1 <- circularDeg(180) | |
k1 <- 2.1 | |
w1 <- 65 | |
dvm1 <- dvonmises(theta, mu = m1, kappa = k1) |