This file contains hidden or 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
| # 預先切過的頭尾 | |
| # 當然也可以是完全還沒切過的樣子,例如 cbind(f1 = 1, f2 = 100) | |
| mat.in <- | |
| cbind( | |
| f1 = c(3, 23, 47, 78), | |
| f2 = c(9, 26, 55, 88) | |
| ) | |
| # 想要再切的頭尾 | |
| # 可以包括已經被切掉的部份 |
This file contains hidden or 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(tidyverse) | |
| ID_sprint <- | |
| tibble(ID_start = c(179, 248, 367, 475), | |
| ID_end = c(231, 308, 419, 741)) %>% | |
| mutate(clipID = 1:nrow(.)) | |
| ID_turn <- | |
| tibble(ID_turn_start = c(188, 293, 294, 295, 296, 297, 298, 299, 415)) %>% | |
| mutate(ID_turn_end = ID_turn_start + 2) | |
| # ID_turn_start ID_turn_end | |
| # <dbl> <dbl> |
This file contains hidden or 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(rvest) | |
| url <- "https://kuochang.tw/quote" | |
| res <- read_html(url) | |
| onion.quotations <- | |
| res |> | |
| html_elements("div.quoteCard") |> | |
| html_elements("span.line") |> | |
| html_text() |> | |
| trimws() |> | |
| (\(x) {gsub("[\t\n\r ,。]+", ",", x)})() |
This file contains hidden or 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(tidyverse) | |
| set.seed(1234) | |
| d <- | |
| tibble( | |
| Time = letters[1:5] %>% rep(3), | |
| Species = LETTERS[1:3] %>% rep(each = 5), | |
| LS_2 = rpois(15, 1), | |
| LS_3 = rpois(15, 2), | |
| LS_4 = rpois(15, 3) | |
| ) |
This file contains hidden or 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
| # 兩個獨立常態母體,4個參數 mu1 mu2 sigma1 sigma2 未知。各自隨機抽n1和n2個樣本,想知道(mu2 - mu1) / sigma1的抽樣分布。 | |
| library(magrittr) | |
| library(data.table) | |
| library(ggpubr) | |
| # 單次模擬的function | |
| sim <- | |
| function(mu1 = 10, | |
| mu2 = 10, |
This file contains hidden or 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(rbenchmark) | |
| library(Matrix) | |
| ncol <- 2e3 | |
| nrow <- 1e3 | |
| x <- matrix(rbinom(ncol * nrow, 1, 0.1), nrow = nrow, ncol = ncol) | |
| benchmark( | |
| which(x != 0, arr.ind = T), # method 0 | |
| which(Matrix(x, sparse = T) != 0, arr.ind = T), # method 1 |
This file contains hidden or 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
| \documentclass[]{article} | |
| \usepackage{booktabs} | |
| \begin{document} | |
| \begin{table}[!t] | |
| \centering | |
| \caption{Table to test captions and labels.} | |
| \begin{tabular}{p{1.2cm}lllll} % 1.2cm調到"Output:"放得下就行 | |
| \toprule | |
| Input: & \multicolumn{5}{l}{Tap weight vector}\\ |
This file contains hidden or 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
| Sys.setlocale(locale = "cht") # for windows os | |
| library(magrittr) | |
| library(ggpubr) | |
| library(data.table) | |
| p.sensitive <- c(0.8, 0.9, 0.999999) | |
| p.specific <- c(0.9, 0.99, 0.999, 0.9999) | |
| p.prevalence.rate <- | |
| c( | |
| seq(0.000001, 0.000009, 0.0000001), |
This file contains hidden or 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(rsconnect) | |
| library(shinyjs) | |
| ui <- shinyUI(fluidPage( | |
| titlePanel("index predictive plot and predictive table"), | |
| mainPanel( | |
| textInput("index1", label = "code") , | |
| textOutput("yahooop"), | |
| actionButton("goButton", "Go!"), | |
This file contains hidden or 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(tseries) | |
| library(quantmod) | |
| library(forecast) | |
| library(car) | |
| library(haven) | |
| index3 <- getSymbols("^TWII", auto.assign = FALSE) | |
| index.open <- na.omit(data.frame(index3[, 1])) | |
| index.close <- na.omit(data.frame(index3[, 4])) | |
| index.open.test <- data.frame(index.open[1:(nrow(index.open) - 365), ]) |
NewerOlder