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(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 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 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 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 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 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 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 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), ]) |
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
# Discussion Figure 2 - Pressure audiograms for Elasmobranchs | |
setwd("H:/1. Shark Project/9. Data analysis/Behavioral Audiogram Analysis") | |
#getwd() | |
library(ggplot2) | |
library(ggpubr) | |
library(magrittr) | |
d <- read.table("Elasmo_audiogramms.txt",header=T,na.strings=c("NA","NaN",""),sep="\t") |
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
FBlikeNumber <- | |
function(url) { | |
require(magrittr) | |
require(rvest) | |
x <- read_html(url, encoding = "UTF-8") %>% as.character | |
re <- regexpr("[,0-9]+(?= 人說這讚)", x, perl = T) | |
substr(x, re, re + attr(re, "match.length")) %>% | |
gsub(",", "", .) %>% | |
as.integer | |
} |
NewerOlder