blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
327
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
91
| license_type
stringclasses 2
values | repo_name
stringlengths 5
134
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 46
values | visit_date
timestamp[us]date 2016-08-02 22:44:29
2023-09-06 08:39:28
| revision_date
timestamp[us]date 1977-08-08 00:00:00
2023-09-05 12:13:49
| committer_date
timestamp[us]date 1977-08-08 00:00:00
2023-09-05 12:13:49
| github_id
int64 19.4k
671M
⌀ | star_events_count
int64 0
40k
| fork_events_count
int64 0
32.4k
| gha_license_id
stringclasses 14
values | gha_event_created_at
timestamp[us]date 2012-06-21 16:39:19
2023-09-14 21:52:42
⌀ | gha_created_at
timestamp[us]date 2008-05-25 01:21:32
2023-06-28 13:19:12
⌀ | gha_language
stringclasses 60
values | src_encoding
stringclasses 24
values | language
stringclasses 1
value | is_vendor
bool 2
classes | is_generated
bool 2
classes | length_bytes
int64 7
9.18M
| extension
stringclasses 20
values | filename
stringlengths 1
141
| content
stringlengths 7
9.18M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f853836c66fb6bf2500836043dfb2bd5b292e6c7
|
ffdea92d4315e4363dd4ae673a1a6adf82a761b5
|
/data/genthat_extracted_code/QFRM/examples/HolderExtendibleBS.Rd.R
|
fa9c576b8b2dbab5a1e972abd18520ce43c9982c
|
[] |
no_license
|
surayaaramli/typeRrh
|
d257ac8905c49123f4ccd4e377ee3dfc84d1636c
|
66e6996f31961bc8b9aafe1a6a6098327b66bf71
|
refs/heads/master
| 2023-05-05T04:05:31.617869
| 2019-04-25T22:10:06
| 2019-04-25T22:10:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 517
|
r
|
HolderExtendibleBS.Rd.R
|
library(QFRM)
### Name: HolderExtendibleBS
### Title: Holder Extendible option valuation via Black-Scholes (BS) model
### Aliases: HolderExtendibleBS
### ** Examples
(o = HolderExtendibleBS())$PxBS
o = Opt(Style='HolderExtendible',Right='Call', S0=100, ttm=0.5, K=100)
o = OptPx(o,r=0.08,q=0,vol=0.25)
(o = HolderExtendibleBS(o,k=105,t1=0.5,t2=0.75,A=1))$PxBS
o = Opt("HolderExtendible","Put", S0=100, ttm=0.5, K=100)
o = OptPx(o,r=0.08,q=0,vol=0.25)
(o = HolderExtendibleBS(o,k=90,t1=0.5,t2=0.75,A=1))$PxBS
|
f4cceaf856273f415b7848c95a1696180baf2c5d
|
452ec71b7cae302f0710163e0617ad6382d9e1c3
|
/man/GL_test_stat.Rd
|
b896b634032ee98213126a54001c77fd5839a666
|
[] |
no_license
|
umich-biostatistics/corrsurv
|
05247bd29ff362ebacd6c9e6101641e2d29cb7f8
|
444c88c7be8493ad62167d8fb140a3de9578909d
|
refs/heads/master
| 2020-08-26T19:56:01.580397
| 2020-01-10T21:00:31
| 2020-01-10T21:00:31
| 217,128,847
| 0
| 0
| null | 2020-01-10T21:00:32
| 2019-10-23T18:40:38
|
R
|
UTF-8
|
R
| false
| true
| 778
|
rd
|
GL_test_stat.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/TM.R
\name{GL_test_stat}
\alias{GL_test_stat}
\title{Calculate test statistic for Ghosh and Lin method}
\usage{
GL_test_stat(p_GL, time, data1_format, data2_format)
}
\arguments{
\item{p_GL}{p parameter}
\item{time}{time to event}
\item{data1_format}{Formatted data set 1}
\item{data2_format}{Formatted data set 2}
}
\value{
A \code{list} object which contains
\itemize{
\item{test_stat_p - P-value for test statistic}
}
}
\description{
Calculate test statistic for Ghosh and Lin method
}
\references{
Tayob, N. and Murray, S., 2014. Nonparametric tests of treatment
effect based on combined endpoints for mortality and recurrent events. Biostatistics,
16(1), pp.73-83.
}
\author{
Nabihah Tayob
}
|
ad19ac174fa705aa0ff78e89ff77835dd01c5c61
|
1c0be95fb6ebfd304d2f524403c032cd4e2cce0b
|
/Discriminant Analysis/distinguish.bayes.R
|
fe7c8c054c9bf8cc399c0676df9cc159a5ea5e0e
|
[] |
no_license
|
luweihao/duoyuan
|
f42300edc5f29679f6a5ee90df68632a653b595a
|
9e9b59b7a26bbc99234de6c842cf07ac3ca74140
|
refs/heads/master
| 2021-03-16T08:44:19.964636
| 2018-01-29T16:38:12
| 2018-01-29T16:38:12
| 119,410,092
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,428
|
r
|
distinguish.bayes.R
|
distinguish.bayes=function(TrnX, TrnG, p=rep(1, length(levels(TrnG))), TstX = NULL, var.equal = FALSE)
{
flag=0
if (is.null(TstX) == TRUE){
TstX=TrnX
flag=1
}
if (is.vector(TstX) == TRUE) TstX=t(as.matrix(TstX))
if (is.matrix(TstX) != TRUE)
TstX=as.matrix(TstX)
if (is.matrix(TrnX) != TRUE) TrnX=as.matrix(TrnX)
nx=nrow(TstX)
blong=matrix(rep(0, nx), nrow=1, dimnames=list("blong", 1:nx))
g=length(levels(TrnG))
mu=matrix(0, nrow=g, ncol=ncol(TrnX))
for (i in 1:g)
{
mu[i,]=colMeans(TrnX[TrnG==i,])
}
D=matrix(0, nrow=g, ncol=nx)
if (var.equal == TRUE)
{
for (i in 1:g)
{
d2=mahalanobis(TstX, mu[i,], var(TrnX))
D[i,]=d2 - 2*log(p[i])
}
}else{
for (i in 1:g)
{
S=var(TrnX[TrnG==i,])
d2= mahalanobis(TstX, mu[i,], S)
D[i,]=d2 - 2*log(p[i])+log(det(S))
}
}
for (j in 1:nx)
{
dmin=Inf
for (i in 1:g)
if (D[i,j]<dmin)
{
dmin=D[i,j]; blong[j]=i
}
}
if(flag){
table1 <- as.data.frame( t(rbind(TrnG, blong)) )
tab1=xtabs(~ TrnG+blong, data = table1)
print(tab1)
tab2=prop.table(tab1)
print(tab2, digits = 3)
wrong <- which((as.numeric(TrnG)-as.numeric(blong))!=0)
cat("The index of wrong data are:", wrong, "\n")
#return(table1)
}else{return(blong)}
}
|
9fe614a8d4b898c7e265a8344869180aab0d9b46
|
9555bdc33d1c2f5b497de5cd4fcd91329bcae3d7
|
/289R_HW4_20170924.R
|
c44b8c9536263ff31d9ea2fe450952b0742cc7bb
|
[] |
no_license
|
lovefreedomval/201708
|
4f0291ec001288c6d43c368a63e21bf468186f84
|
ddf1976d4cda979deb54cc34c1b91e220e00d09b
|
refs/heads/master
| 2021-01-19T19:02:10.216490
| 2019-04-07T14:43:54
| 2019-04-07T14:43:54
| 101,182,167
| 0
| 0
| null | null | null | null |
BIG5
|
R
| false
| false
| 542
|
r
|
289R_HW4_20170924.R
|
# 公正的骰子,必須出現三次六點才可以停止 - 請問總共要投幾次? - 投擲的歷史紀錄為何?
dice_flips <- c() # 投擲紀錄
dice_vector =c(1:6) # 定義骰子的內容/結果
i <- 1
while (sum(dice_flips==6) < 3){ # 什麼條件下要一直執行
dice_flips[i] <- sample(dice_vector, size = 1) # 用sample函數骰骰子, 並把每次結果紀錄給dice_flips
i <- i + 1 # while迴圈往後交棒=指定下一次
}
dice_flips # 印出投擲紀錄
length(dice_flips) # 總共投了幾次
|
8af4b19e9236be7a2a0e1510b37367ee8584e072
|
fbbf4719a5fac80d1c540231c0003aef6aa444c2
|
/unix_shell/2nd_script.R
|
b9610f83ebb3347f4abdaefa16eb3f634771cc78
|
[] |
no_license
|
elenamdo/Software-Carpentry-Workshop-2018
|
c8fd456a9e7024ae6d135c7f3413193cffe0030a
|
5d82bd3694788a1b7d95c41e6500ea4366a60d75
|
refs/heads/master
| 2020-03-29T14:41:13.812178
| 2018-09-23T22:01:34
| 2018-09-23T22:01:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 802
|
r
|
2nd_script.R
|
#2nd script
#This script computes the average GDP for a country using
#clear away old variables
rm(list = ls())
#location of the data
filename <- 'Data/gapminder.txt'
#read the data file
gapminder <- read.table(filename, header = TRUE)
getAverageGdpPerCapita <- function(country, gapminder){
# select countryw here you want to parse out GDP
selectedCountryData <- gapminder[gapminder$country == country, "gdpPercap"]
mean(selectedCountryData)
}
gdpUSA <- getAverageGdpPerCapita("United_States", gapminder)
gdpUSA
gdpCanada <- getAverageGdpPerCapita("Canada", gapminder)
gdpMexico <- getAverageGdpPerCapita("Mexico", gapminder)
print(paste("GDP per capita of USA is:", gdpUSA))
print(paste("GDP per capita of Canada is:", gdpCanada))
print(paste("GDP per capita of Mexico is:", gdpMexico))
|
6950c100c1a5ebdfd260b5e4a5681fb05c5854a1
|
c6da4424c172b71477fe5c8420d0ab69d3b277cf
|
/man/RPChoose.Rd
|
476662d2ab93a8b838966bbd61d6e4e728b1b0a9
|
[] |
no_license
|
cobrbra/RPEnsemble
|
68702aaf1bca8bf605407f93cabfec6ee0f1feef
|
d1161d8e9352a98eb0cbb1a224db91f420edd66f
|
refs/heads/main
| 2023-08-26T13:17:08.488723
| 2021-10-09T12:03:53
| 2021-10-09T12:03:53
| 337,134,340
| 0
| 0
| null | 2021-02-08T16:18:04
| 2021-02-08T16:18:03
| null |
UTF-8
|
R
| false
| true
| 2,315
|
rd
|
RPChoose.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RPChoose.R
\name{RPChoose}
\alias{RPChoose}
\title{Chooses projection and produces predictions}
\usage{
RPChoose(
XTrain,
YTrain,
XTest,
d,
B2 = 10,
base = "LDA",
k = c(3, 5),
projmethod = "Haar",
estmethod = "training",
...
)
}
\arguments{
\item{XTrain}{An n by p matrix containing the training data feature vectors.}
\item{YTrain}{A vector of length n of the classes (either 1 or 2) of the training data.}
\item{XTest}{An n.test by p matrix of the test data.}
\item{d}{The lower dimension of the image space of the projections.}
\item{B2}{The block size.}
\item{base}{The base classifier: one of "knn","LDA","QDA" or "other".}
\item{k}{The options for k if base is "knn".}
\item{projmethod}{Either "Haar", "Gaussian" or "axis".}
\item{estmethod}{Method for estimating the test errors to choose the projection: either training error "training" or leave-one-out "loo".}
\item{...}{Optional further arguments if base = "other".}
}
\value{
Returns a vector of length n + n.test: the first n entries are the estimated classes of the training set, the last n.test are the estimated classes of the test set.
}
\description{
Chooses a the best projection from a set of size B2 based on a test error estimate, then classifies the training and test sets using the chosen projection.
}
\details{
Randomly projects the the data B2 times. Chooses the projection yielding the smallest estimate of the test error. Classifies the training set (via the same method as estmethod) and test set using the chosen projection.
}
\note{
Resubstitution method unsuitable for the k-nearest neighbour classifier.
}
\examples{
set.seed(100)
Train <- RPModel(1, 50, 100, 0.5)
Test <- RPModel(1, 100, 100, 0.5)
Choose.out5 <- RPChoose(XTrain = Train$data$x, YTrain = Train$data$y, XTest = Test$data$x,
d = 2, B2 = 5, base = "QDA", projmethod = "Haar", estmethod = "loo")
Choose.out10 <- RPChoose(XTrain = Train$data$x, YTrain = Train$data$y, XTest = Test$data$x,
d = 2, B2 = 10, base = "QDA", projmethod = "Haar", estmethod = "loo")
sum(Choose.out5[1:50] != Train$data$y)
sum(Choose.out10[1:50] != Train$data$y)
sum(Choose.out5[51:150] != Test$y)
sum(Choose.out10[51:150] != Test$y)
}
|
38ce6798df197382f49f967677d4e6fbfd642111
|
0775b1dc2ff15385e26d01bf80b482b5c69d7bf4
|
/cachematrix.R
|
848d7c1418fa8af945bdcad331164e81b426ad3a
|
[] |
no_license
|
jbirnbaum92/ProgrammingAssignment2
|
25536a59b654f2501c84f553cece45d4553f1517
|
390e28373367d208fb5125a36c69b31aac8c9a77
|
refs/heads/master
| 2021-01-18T05:27:40.355170
| 2016-02-19T18:13:23
| 2016-02-19T18:13:23
| 52,067,627
| 0
| 0
| null | 2016-02-19T06:48:38
| 2016-02-19T06:48:38
| null |
UTF-8
|
R
| false
| false
| 1,115
|
r
|
cachematrix.R
|
## Matrix inversion is a costly computation an there is benefit to caching it rather than computing repeatedly.
## The First function creates an object that can cache its inverse.
## The second computes the inverse returned by the function above. If the inverse has been calculated already, it will simply be
## recovered from the cache.
## This function creates a special matrix object to cache its inverse
makeCacheMatrix <- function(x = matrix()) {
inv <- NULL
set <- function(y) {
x <<- y
inv <<- NULL
}
get <- function() x
setInverse <- function(inverse) inv <<- inverse
getInverse <- function() inv
list(set = set, get = get,
setInverse = setInverse,
getInverse = getInverse)
}
## This function computes the inverse or returns the inverse from the cache if already computed.
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
inv <- x$getInverse()
if (!is.null(inv)) {
message("getting cached data")
return(inv)
}
mat <- x$get()
inv <- solve(mat, ...)
x$setInverse(inv)
inv
}
|
3f400ee3e902b90081454d27a048c2ea0e848f4b
|
3bba09703406414cc64349f5bdefeaf133034932
|
/Code/Old_Code/16a_LUR_BC_Averaged v1.R
|
3cd663e93861903e627ac3e17a206c44fb157adc
|
[] |
no_license
|
smartenies/ECHO_Aim1_BC_ST_Model
|
cb79815ea7d6b3e8d3680b60b90f08ae2c5067f8
|
c69da5a28ad4c4ff16d69df5d5c5a097d4c6e826
|
refs/heads/main
| 2023-02-17T22:39:49.307080
| 2021-01-19T20:23:54
| 2021-01-19T20:23:54
| 319,451,947
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 12,969
|
r
|
16a_LUR_BC_Averaged v1.R
|
#' =============================================================================
#' Project: ECHO LUR
#' Date Created: Febrary 17, 2020
#' Author: Sheena Martenies
#' Contact: Sheena.Martenies@colostate.edu
#'
#' Description:
#' Preliminary LUR for BC
#' Averaging all data at the sampling locations-- essentially taking time out
#' of the equation. What do long-term spatial trends in the data look like? Can
#' we reasonably predict them using the variables we have?
#'
#' Updated 3/10/20:
#' We need to have a strategy for choosing our predictors before fitting the
#' spatiotemporal model (based on Josh Keller's work with the MESA Air study).
#' He used partial least squares regression in his work, which is the ultimate
#' plan for this study. However, given a March 16 deadline to submit an extended
#' abstract, I'm going to use LASSO for now and base the selection of predictors
#' on the "averaged" model
#' =============================================================================
library(sf)
library(raster)
library(ggplot2)
library(ggmap)
library(ggsn)
library(ggthemes)
library(GGally)
library(ggcorrplot)
library(stringr)
library(tidyverse)
library(lubridate)
library(readxl)
library(viridis)
#' For ggplots
simple_theme <- theme(
#aspect.ratio = 1,
text = element_text(family="Arial",size = 12, color = 'black'),
panel.spacing.y = unit(0,"cm"),
panel.spacing.x = unit(0.25, "lines"),
panel.grid.minor = element_line(color = "transparent"),
panel.grid.major = element_line(color = "transparent"),
panel.border=element_rect(fill = NA),
panel.background=element_blank(),
axis.ticks = element_line(colour = "black"),
axis.text = element_text(color = "black", size=10),
# legend.position = c(0.1,0.1),
plot.margin=grid::unit(c(0,0,0,0), "mm"),
legend.key = element_blank()
)
options(scipen = 9999) #avoid scientific notation
albers <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
ll_nad83 <- "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"
ll_wgs84 <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
# Function that returns Root Mean Squared Error
rmse <- function(error)
{
sqrt(mean(error^2))
}
# Function that returns Mean Absolute Error
mae <- function(error)
{
mean(abs(error))
}
#' -----------------------------------------------------------------------------
#' Read in the dataset--
#' Aggregate to the "annual" level at each location (using lon/lat as the ID)
#' -----------------------------------------------------------------------------
data_name <- "Combined_Filter_Data_AEA.csv"
lur_data <- read_csv(here::here("Data", data_name)) %>%
filter(!is.na(lon)) %>%
filter(indoor == 0) %>%
filter(bc_ug_m3_dem > 0)
#' Select a "calibrated" version of the data
#' For now, go with Deming regression-- accounts for variability in the
#' monitor and the UPAS data
lur_data <- lur_data %>%
rename("pm_ug_m3_raw" = "pm_ug_m3") %>%
rename("pm_ug_m3" = "pm_ug_m3_dem") %>%
rename("bc_ug_m3_raw" = "bc_ug_m3") %>%
rename("bc_ug_m3" = "bc_ug_m3_dem")
#' Add a unique site ID
lur_data <- mutate(lur_data, site_id_lonlat = paste(lon, lat, sep = "_"))
ids <- select(lur_data, site_id_lonlat) %>%
distinct() %>%
mutate(site_id = seq_along(site_id_lonlat))
lur_data <- left_join(lur_data, ids, by = "site_id_lonlat")
#' Study-wide data for each sampling location
#' Not considering temperature or wildfire smoke right now
site_sp <- select(lur_data, site_id,
elevation_50:impervious_2500,open_50:aadt_2500) %>%
distinct()
site_st <- select(lur_data, site_id, bc_ug_m3, nn_pm, nn_no2, nn_bc, nn_temp,
area_pm, area_no2, area_temp, idw_pm, idw_no2, idw_temp) %>%
filter(!is.na(bc_ug_m3)) %>%
group_by(site_id) %>%
summarize(bc_ug_m3 = mean(bc_ug_m3, na.rm = T),
nn_pm = mean(nn_pm, na.rm=T),
nn_no2 = mean(nn_no2, na.rm=T),
nn_temp = mean(nn_temp, na.rm=T),
nn_bc = mean(nn_bc, na.rm=T),
area_pm = mean(area_pm, na.rm=T),
area_no2 = mean(area_no2, na.rm=T),
area_temp = mean(area_temp, na.rm=T),
idw_pm = mean(idw_pm, na.rm=T),
idw_no2 = mean(idw_no2, na.rm=T),
idw_temp = mean(idw_temp, na.rm=T))
site_data <- left_join(site_sp, site_st, by = "site_id")
head(site_data)
#' -----------------------------------------------------------------------------
#' Check distribution of BC
#' -----------------------------------------------------------------------------
#' BC and log_transformed BC
ggplot(site_data) +
ggtitle("BC") +
geom_histogram(aes(x = bc_ug_m3)) +
simple_theme
ggplot(site_data) +
ggtitle("BC") +
geom_qq(aes(sample = bc_ug_m3)) +
geom_qq_line(aes(sample = bc_ug_m3)) +
simple_theme
ggplot(site_data) +
ggtitle("Log-transformed BC") +
geom_histogram(aes(x = log(bc_ug_m3))) +
simple_theme
ggplot(site_data) +
ggtitle("Log-transformed BC") +
geom_qq(aes(sample = log(bc_ug_m3))) +
geom_qq_line(aes(sample = log(bc_ug_m3))) +
simple_theme
#' -----------------------------------------------------------------------------
#' Look at some preliminary models using only selected spatial predictors
#' -----------------------------------------------------------------------------
bc_lur_data <- site_data %>%
select(site_id, bc_ug_m3, elevation_50:aadt_2500)
glimpse(bc_lur_data)
summary(bc_lur_data)
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
#' Narrow the list of candidate predictors
#'
#' Update 12.04.19: Going to go with the methods used by the DEEDS team
#' - Remove variables with a %diff (highest to lowest) of <10%
#' - Remove variables with a CV of <0.1
#' - Remove variables if they have a correlation > 0.95 with another variable
#'
#' Notes:
#' - Technically temp and BC don't meet the criteria, but we want to force these
#' in the model to make sure that we can hindcast properly
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
#' How many predictors are we starting with?
#' 92
ncol(select(bc_lur_data, -c(bc_ug_m3)))
#' Looking at the continuous predictors now
names(bc_lur_data)
bc_continuous <- select(bc_lur_data, elevation_50:aadt_2500)
#' Calculate CV and percent diff
bc_continuous_cv <- gather(bc_continuous) %>%
group_by(key) %>%
summarize(mean = mean(value, na.rm=T),
sd = sd(value, na.rm=T),
max = max(value, na.rm=T),
min = min(value, na.rm=T)) %>%
mutate(pct_diff = (max - min) / max,
cv = sd / mean)
as.data.frame(bc_continuous_cv)
#' Which variables don't meet the 10% variability criterion?
#' Although technically nearest_3_neighbors BC doesnt make the cut,
#' going to keep them in to force them into the model
bc_continuous_drop <- filter(bc_continuous_cv, pct_diff < 0.10 | cv < 0.10)
bc_continuous_drop
drop_vars2 <- bc_continuous_drop$key[1:6]
drop_vars2
#' Calculate correlations
bc_continuous_cor <- cor(bc_continuous, use = "complete")
ggcorrplot(bc_continuous_cor, type = "upper", method = "square",
ggtheme = simple_theme, lab = T, lab_col = "white",
show.diag = T)
#' Which variables don't meet the r < 0.95 criterion?
#' Use pop density; drop pop count
#' Drop tree cover 50 to tree cover 500
#' Drop AADT in 100 m
bc_continuous_cor[bc_continuous_cor < 0.95] <- ""
View(bc_continuous_cor)
drop_vars2 <- c(drop_vars2, "tree_cover_50", "tree_cover_100", "tree_cover_250", "tree_cover_500",
"pop_ct_50", "pop_ct_100", "pop_ct_250", "pop_ct_500", "pop_ct_1000", "pop_ct_2500",
"aadt_50")
drop_vars2
#' Now how many predictors do we have?
#' 77 candidate predictors
bc_lur_data2 <- bc_lur_data %>%
select(-c(drop_vars2))
names(bc_lur_data2)
ncol(select(bc_lur_data2, -bc_ug_m3))
summary(bc_lur_data2)
#' Fit some linear regression models
#' Just AADT
bc_lm1 <- lm(log(bc_ug_m3) ~ aadt_250, data = bc_lur_data2)
summary(bc_lm1)
par(mfrow=c(2,2))
plot(bc_lm1, main = "Just AADT within 250 m: log-transformed outcome")
par(mfrow=c(1,1))
hist(bc_lm1$residuals)
#' AADT + high intensity dev
bc_lm2 <- lm(log(bc_ug_m3) ~ aadt_250 + high_int_2500, data = bc_lur_data2)
summary(bc_lm2)
par(mfrow=c(2,2))
plot(bc_lm2, main = "AADT (250m) and High Intensity Dev (2500): log-transformed outcome")
par(mfrow=c(1,1))
hist(bc_lm2$residuals)
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
#' METHOD 1: Use LASSO (caret package)
#'
#' LASSO: Least Absolute Shrinkage and Selection Operator
#' Coefficients CAN shrink to 0 in this one
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
library(caret)
bc_lur_data4 <- select(bc_lur_data, bc_ug_m3, start_predictors)
lambda <- 10^seq(-3, 3, length = 100)
tc_l = trainControl("cv", number = 10)
tg_l = expand.grid(alpha = 1, lambda = lambda)
log_bc_lasso2 <- train(log(bc_ug_m3) ~ ., data = bc_lur_data4,
method = "glmnet", trControl = tc_l, tuneGrid = tg_l)
log_bc_lasso2$resample
plot(log_bc_lasso2)
#' The plot above suggests that the lambda search window is too wide
lambda2 <- 10^seq(-2, 1, length = 100)
tc_l = trainControl("cv", number = 10)
tg_l2 = expand.grid(alpha = 1, lambda = lambda2)
log_bc_lasso3 <- train(log(bc_ug_m3) ~ ., data = bc_lur_data4,
method = "glmnet", trControl = tc_l, tuneGrid = tg_l2)
log_bc_lasso3$resample
plot(log_bc_lasso3)
#' The plot above suggests that the lambda search window is still a little too wide
lambda3 <- 10^seq(-2, -0.5, length = 100)
tc_l = trainControl("cv", number = 10)
tg_l3 = expand.grid(alpha = 1, lambda = lambda3)
log_bc_lasso4 <- train(log(bc_ug_m3) ~ ., data = bc_lur_data4,
method = "glmnet", trControl = tc_l, tuneGrid = tg_l3)
log_bc_lasso4$resample
plot(log_bc_lasso4)
getTrainPerf(log_bc_lasso4)
plot(log_bc_lasso4$finalModel)
arrange(log_bc_lasso4$results, RMSE) %>% head
log_bc_lasso4$bestTune
log_bc_lasso_coef4 <- coef(log_bc_lasso4$finalModel, log_bc_lasso4$bestTune$lambda)
log_bc_lasso_coef4
varImp(log_bc_lasso4)
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
#' METHOD 3: Use LASSO (CAST package) with leave-location-out CV
#'
#' CAST package in R to faciliate model building and validation
#' A good tutorial here: https://cran.r-project.org/web/packages/CAST/vignettes/CAST-intro.html
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
library(CAST)
bc_lur_data5 <- select(bc_lur_data, site_id, bc_ug_m3, start_predictors)
sp_indices <- CreateSpacetimeFolds(bc_lur_data5, spacevar = "site_id",
k = length(unique(bc_lur_data5$site_id)))
sp_indices
lambda3 <- 10^seq(-2, -0.5, length = 100)
tg_l3 = expand.grid(alpha = 1, lambda = lambda3)
log_bc_lasso5 <- train(log(bc_ug_m3) ~ ., data = bc_lur_data4,
method = "glmnet", tuneGrid = tg_l3,
trControl = trainControl(method = "cv",
index = sp_indices$index))
plot(log_bc_lasso5)
varImp(log_bc_lasso5)
getTrainPerf(log_bc_lasso5)
plot(log_bc_lasso5$finalModel)
arrange(log_bc_lasso5$results, RMSE) %>% head
log_bc_lasso5$bestTune
log_bc_lasso_coef5 <- coef(log_bc_lasso5$finalModel, log_bc_lasso5$bestTune$lambda)
log_bc_lasso_coef5
varImp(log_bc_lasso5)
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
#' METHOD 3: Build a random forest model (CAST package) with leave-location-out CV
#'
#' CAST package in R to faciliate model building and validation
#' A good tutorial here: https://cran.r-project.org/web/packages/CAST/vignettes/CAST-intro.html
#' -----------------------------------------------------------------------------
#' -----------------------------------------------------------------------------
predictors <- names(select(bc_lur_data5, -c("bc_ug_m3", "site_id")))
predictors
log_bc_rf <- train(bc_lur_data5[,predictors], log(bc_lur_data5$bc_ug_m3),
method = "rf", tuneLength = 1, importance = T,
trControl = trainControl(method = "cv",
index = sp_indices$index))
log_bc_rf
plot(varImp(log_bc_rf))
|
0e7714b9cf43e1e94f08ce1ff2872f960716e3d8
|
14abfaec6c704d8ea1799fa8f2dfe834d66953b1
|
/One-off analyses - Copy/prescreen research questions.R
|
e3e6264a8071647ee7c803529e9376c29d7134e4
|
[] |
no_license
|
jrliebster/getting-and-cleaning-data
|
d7d119125750006f74c52ff81f396fb91dd8ade5
|
b30aa5f7a1287bd5dece503885cd0f74ff126aa0
|
refs/heads/master
| 2021-01-22T18:06:47.183111
| 2017-08-23T20:47:59
| 2017-08-23T20:47:59
| 100,740,016
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,162
|
r
|
prescreen research questions.R
|
#load packages
library(pacman)
p_load(readr, dplyr, janitor, tidyr, ggplot2)
prescreen_ratings <- read_csv("prescreen data with research questions.csv")
prescreen_ratings[prescreen_ratings=="Strongly Agree"] <- 6
prescreen_ratings[prescreen_ratings=="Agree"] <- 5
prescreen_ratings[prescreen_ratings=="Somewhat Agree"] <- 4
prescreen_ratings[prescreen_ratings=="Somewhat Disagree"] <- 3
prescreen_ratings[prescreen_ratings=="Disagree"] <- 2
prescreen_ratings[prescreen_ratings=="Strongly Disagree"] <- 1
prescreen_ratings <- prescreen_ratings %>%
mutate_at(vars(starts_with("RRApplicantDemonstrate")),funs(as.numeric)) %>%
filter(!is.na(RRApplicantDemonstratesTenacity250),
!is.na(RRApplicantDemonstratedGoodFitForSubjectArea251),
!is.na(RRApplicantDemonstratesPassionForSubjectArea252))
tenacity <- count(prescreen_ratings, RRApplicantDemonstratesTenacity250)
subject_fit <- count(prescreen_ratings, RRApplicantDemonstratedGoodFitForSubjectArea251)
passion <- count(prescreen_ratings, RRApplicantDemonstratesPassionForSubjectArea252)
write_csv(prescreen_ratings, "prescreen ratings with research clean.csv")
|
6bed4241fd8f36188ae790ff098f9301331b1fe5
|
834a593c957282895297c90344f6d9b3062b77d9
|
/Robustness Checks/Data_Generation.R
|
3b9b34d56bada39a5b7079a8cb4158dab67cdb1a
|
[] |
no_license
|
haroonatcha/CCEnrollmentPrediction
|
27442685d255f1e2299edc34059f62d87b78ceda
|
be0846b9fdf04e24297c1bd4cc19806a9e263a3c
|
refs/heads/main
| 2023-06-17T14:02:35.403103
| 2021-07-02T20:21:00
| 2021-07-02T20:21:00
| 372,040,081
| 0
| 0
| null | 2021-07-12T05:43:45
| 2021-05-29T18:04:48
|
HTML
|
UTF-8
|
R
| false
| false
| 19,919
|
r
|
Data_Generation.R
|
library('truncnorm')
library('rlist')
library('forecast')
library('scales')
library('ggplot2')
library('reshape2')
#everything in this file is just a combination of the data generation and
#modeling files up to the final section which shows how I generated the
#aggregate fit values
# Initialize variables ----------------------------------------------------
set.seed(1000)
#values for GDP. Random walk process
periods <- 100
GDP <- rnorm(1, mean = 0, sd = 1)
for(i in 2:periods) {
GDP[i] <- GDP[i - 1] + rnorm(1, mean = 0, sd = 1)
}
GDP <- GDP + abs(min(GDP))
#creating a data frame with semester binaries
semester_variables <- data.frame(cbind(GDP,
rep_len(c(1, 0, 0),
length.out = periods),
rep_len(c(0, 1, 0),
length.out = periods),
rep_len(c(0, 0, 1),
length.out = periods)))
colnames(semester_variables) <- c('GDP', 'Spring', 'Summer', 'Fall')
#initial values for new student aggregate model
B_GDP <- 2
mean_new_students <- 150
sd_new_students <- 25
B_spring <- 3
B_summer <- 0
B_fall <- 6
#initial values for t = 0 individual student creation
proportion_female <- 0.5
initial_students <- 900
#parameters for assigning credit load
mean_credits <- 9
sd_credits <- 6
#values for 'return' variable calculation
B_Gender <- 0.1
B_Credits <- 0.02
C_constant <- 0.9
# Diagnosis and robustness checks -----------------------------------------
#enrollment seems steady over time so it looks like
#the coefficients and constants specified are ok.
#trying to keep it around a thousand
plot(aggregate(temp$likelihood_of_return,
by = list(temp$semester),
FUN = length))
#credit load per semester also seems robust over time
#There's some variation but nothing that's concerning
aggregate(temp$Credits,
by = list(temp$semester),
FUN = sum)
#our initial specification of the cumulative credit load
#seems too high. However, it looks like we hit an equilibrium
#really fast. It seems that the penalty coefficient of
#credits -> likelihood of return is doing its job. Even so,
#we'll probably want to be careful and throw out the first
#few observations when fitting models
aggregate(temp$Cumulative_credits,
by = list(temp$semester),
FUN = mean)
# Create aggregate output file --------------------------------------------
metrics <- data.frame(matrix(NA,
nrow = 0,
ncol = 4))
colnames(metrics) <- c('Model', 'MAE', 'MAPE', 'RMSE')
for(k in 1:100) {
# Aggregate prediction ----------------------------------------------------
#general linear model for enrollment which has linear relationship with GDP,
# semester fixed effects, and noise
new_student_count <- semester_variables$GDP * B_GDP +
semester_variables$Spring * B_spring +
semester_variables$Summer * B_summer +
semester_variables$Fall * B_fall +
rnorm(nrow(semester_variables),
mean = 0,
sd = 1)
#un-standardizing the calculation so we can get sensible numbers
new_student_count <- round(new_student_count * sd_new_students + mean_new_students)
# Create new students at t = 0 --------------------------------------------
#create t = 0, initial data frame
enrolled_students <- data.frame(matrix(c(1:initial_students,
#randomly assign gender
sample(c(0, 1),
size = initial_students,
replace = TRUE,
#probability of gender can be changed if needed
prob = c(proportion_female, 1 - proportion_female)),
#sample credits taken in the GIVEN SEMESTER. This part
#tells us how many credits the student took NOW. The
#next part tells us cumulative credits
round(rtruncnorm(n = initial_students,
a = 1,
b = 21,
mean = mean_credits,
sd = sd_credits)),
#sample credit load from a uniform distribution
#truncated at lower bound = 1 and upper at 80 to capture the
#range of all reasonable credit loads.
round(runif(n = initial_students,
min = 1,
max = 80))),
nrow = 900,
ncol = 4,
byrow = FALSE))
colnames(enrolled_students) <- c('SID', 'Gender', 'Credits', 'Cumulative_credits')
#variables save as character; fixing them here
enrolled_students$Gender <- as.numeric(enrolled_students$Gender)
enrolled_students$Credits <- as.numeric(enrolled_students$Credits)
# Predict likelihood of returning -----------------------------------------
#linear model predicting likelihood of return.
#model includes gender, cumulative credits, and noise
temp <- enrolled_students$Gender * B_Gender -
(enrolled_students$Cumulative_credits * B_Credits)^2 +
enrolled_students$Cumulative_credits * B_Credits +
C_constant +
rnorm(nrow(enrolled_students),
mean = 0,
sd = 0.1)
#likelihood to probability
enrolled_students$likelihood_of_return <- 1 / (1 + exp(1)^-(temp))
#generate realized 'return' values by sampling (0/1) using probability
#generated above
for(i in 1:nrow(enrolled_students)) {
enrolled_students$returned[i] <- sample(0:1,
size = 1,
replace = TRUE,
#I know this says 'likelihood of return', but since I
#did 0/1, it's reversed for the sake of probability
prob = c(1 - enrolled_students$likelihood_of_return[i],
enrolled_students$likelihood_of_return[i]))
}
enrolled_students$semester <- 1
enrolled <- list()
#put all new students into a list as t = 0
enrolled[[1]] <- enrolled_students
remove(enrolled_students)
# Generate t != 0 datasets ------------------------------------------------
#generating the list of students enrolled in semester = t
#this includes returning students from t - 1 and new students
for(i in 2:periods) {
#here I'm generating new students in the same way that I generated the
#original cohort of students at t = 0
temp <- data.frame(matrix(c((max(enrolled[[i - 1]]) + 1):(max(enrolled[[i - 1]]) + new_student_count[i]),
#randomly assign gender
sample(c(0, 1),
size = new_student_count[i],
replace = TRUE,
#probability of gender can be changed if needed
prob = c(proportion_female, 1 - proportion_female)),
#sample credit load from a truncated normal distribution
#truncated at lower bound = 1 and upper at 21 to capture the
#range of all reasonable cumulative credits. Since these are NEW
#students, their upper bound is limited to 21 instead of 80.
round(rtruncnorm(n = new_student_count[i],
a = 1,
b = 21,
mean = mean_credits,
sd = sd_credits)),
#since they're new students, their cumulative credits are 0
rep(0, new_student_count[i])),
nrow = new_student_count[i],
ncol = 4,
byrow = FALSE))
colnames(temp) <- c('SID', 'Gender', 'Credits', 'Cumulative_credits')
temp$Gender <- as.numeric(temp$Gender)
temp$Credits <- as.numeric(temp$Credits)
temp$Cumulative_credits <- as.numeric(temp$Cumulative_credits)
#initiate likelihood of return variable for new students
temp$likelihood_of_return <- NA
#add semester index
temp$semester <- NA
temp$returned <- NA
#sample credit distribution for returning students
temp2 <- enrolled[[i - 1]][which(enrolled[[i - 1]]$returned == 1),]
temp2$Credits <- round(rtruncnorm(n = nrow(temp2),
a = 1,
b = 21,
mean = mean_credits,
sd = sd_credits))
#bind together all new students at t = 1 and
# returning students from t - 1
enrolled[[i]] <- rbind(temp, temp2)
#add the credit load from t - 1 to get cumulative credits
enrolled[[i]]$Cumulative_credits <- enrolled[[i]]$Credits + enrolled[[i]]$Cumulative_credits
#calculate likelihood of return in t + 1
enrolled[[i]]$likelihood_of_return <- enrolled[[i]]$Gender * B_Gender -
(enrolled[[i]]$Cumulative_credits * B_Credits)^2 +
enrolled[[i]]$Cumulative_credits * B_Credits +
C_constant +
rnorm(nrow(enrolled[[i]]),
mean = 0,
sd = 0.1)
#coerc to probability
enrolled[[i]]$likelihood_of_return <- enrolled[[i]]$likelihood_of_return <- 1 /
(1 + exp(1)^-(enrolled[[i]]$likelihood_of_return))
for(j in 1:nrow(enrolled[[i]])){
enrolled[[i]]$returned[j] <- sample(0:1,
size = 1,
replace = TRUE,
prob = c(1 - enrolled[[i]]$likelihood_of_return[j],
enrolled[[i]]$likelihood_of_return[j]))
}
#add semester index
enrolled[[i]]$semester <- i
remove(temp)
remove(temp2)
}
#bring everything into a single dataframe
temp <- list.rbind(enrolled)
#Appending total headcount to semester dataframe created
#at the beginning
semester_variables$Total_enrollment <- aggregate(temp$SID,
by = list(temp$semester),
FUN = length)[,2]
#Appending total credits taken in given semester
semester_variables$Total_credits_taken <- aggregate(temp$Credits,
by = list(temp$semester),
FUN = sum)[,2]
remove(enrolled)
#iterate model building and save robustness checks
data <- semester_variables
student_data <- temp
remove(temp)
for(i in 2:nrow(data)) {
data$lag[i] <- data$Total_enrollment[i - 1]
}
# Aggregate-only model ----------------------------------------------------
#fit models to 1:t-1 data and predict t
for(i in 5:nrow(data)) {
#fit simple lm model with semester and GDP terms
lm <- lm(Total_enrollment ~ GDP + Spring + Summer + Fall,
data = data[1:(i - 1),])
#linear t + 1 prediction
data$lm_prediction[i] <- predict(lm,
data[i,!names(data) %in% 'Total_enrollment'])
#fit lagged linear model
lm_lagged <- lm(Total_enrollment ~ GDP + lag +Spring + Summer + Fall,
data = data[1:(i - 1),])
#linear with lat t + 1 prediction
data$lm_lagged_prediction[i] <- predict(lm_lagged,
data[i,!names(data) %in% 'Total_enrollment'])
#find optimal arima model to 1:t-1 data
arima <- auto.arima(data$Total_enrollment[1:(i - 1)],
allowdrift = FALSE)
#arima t + 1 prediction
data$arima_prediction[i] <- predict(arima,
n.ahead = 1)$pred[1]
#get rid of temporary objects
remove(lm)
remove(arima)
}
#calculate residuals for each type of model
data$lm_residuals <- data$Total_enrollment - data$lm_prediction
data$lm_lagged_residuals <- data$Total_enrollment - data$lm_lagged_prediction
data$arima_residuals <- data$Total_enrollment - data$arima_prediction
#calculate absolute percent error for each type of model
data$lm_ape <- abs(data$lm_residuals) / data$Total_enrollment
data$lm_lagged_ape <- abs(data$lm_lagged_residuals) / data$Total_enrollment
data$arima_ape <- abs(data$arima_residuals) / data$Total_enrollment
# Stacked model -----------------------------------------------------------
#set number of iterations
semesters <- length(unique(student_data$semester))
#create data frame to hold predictions
stacked_model_predictions <- data.frame(matrix(nrow = semesters,
ncol = 3))
colnames(stacked_model_predictions) <- c('Retained_prediction', 'New_prediction', 'Combined_prediction')
for(i in 4:(semesters - 1)) {
#train dataset = all observations where semester <= i
train <- student_data[which(student_data$semester <= i),]
#fit stacked model 1 (no polynomial term) to training data
individual_model <- glm(returned ~ Gender + Cumulative_credits,
data = train,
family = 'binomial')
#fit stacked model 2 (polynomial term)
individual_model_1 <- glm(returned ~ Gender + poly(Cumulative_credits, 2) + Cumulative_credits,
data = train,
family = 'binomial')
#prediction = t + 1
test <- student_data[which(student_data$semester == i + 1),]
#predicted # of students returning is mean likelihood of return * number of students
#in given semester
stacked_model_predictions$Retained_prediction[i + 1] <- mean(predict(individual_model,
test, type = 'response')) * nrow(test)
#predict as above but with higher order model
stacked_model_predictions$Retained_prediction_1[i + 1] <- mean(predict(individual_model_1,
test, type = 'response')) * nrow(test)
#build linear model
#lm <- lm(new_student_count[1:i] ~ GDP + Spring + Summer,
# data = data[1:i,])
#predict linear model
#stacked_model_predictions$New_prediction[i + 1] <- predict(lm,
# data[i + 1,])
#build arima model for new students only. As above, time through i
arima <- auto.arima(new_student_count[1:i],
allowdrift = FALSE,
seasonal = TRUE,
max.p = 3,
max.q = 3,
max.d = 1)
#predict number of new students in t + 1
stacked_model_predictions$New_prediction[i + 1] <- predict(arima,
n.ahead = 1)$pred[1]
#remove temporary objects
remove(train)
remove(test)
remove(individual_model)
remove(individual_model_1)
remove(arima)
}
#'stacked' model predicts # of predicted return + # of predicted new
stacked_model_predictions$Combined_prediction <- stacked_model_predictions$Retained_prediction +
stacked_model_predictions$New_prediction
stacked_model_predictions$Combined_prediction_1 <- stacked_model_predictions$Retained_prediction_1 +
stacked_model_predictions$New_prediction
#add variable to overall dataset
data$stacked_predictions <- stacked_model_predictions$Combined_prediction
data$stacked_predictions_1 <- stacked_model_predictions$Combined_prediction_1
#calculate residual
data$stacked_residuals <- data$Total_enrollment - data$stacked_predictions
data$stacked_residuals_1 <- data$Total_enrollment - data$stacked_predictions_1
#calculate absolute percent error
data$stacked_ape <- abs(data$stacked_residuals) / data$Total_enrollment
data$stacked_ape_1 <- abs(data$stacked_residuals_1) / data$Total_enrollment
# Predictive accuracy diagnostics -----------------------------------------
#create diagnostics and create DF
diagnostics <- data.frame(cbind(c('Linear Model', 'Linear w/ lag', 'ARIMA', 'Stacked Model', 'Stacked Model w/ Polynomial'),
#MAE
c(mean(abs(data$lm_residuals), na.rm = TRUE),
mean(abs(data$lm_lagged_residuals), na.rm = TRUE),
mean(abs(data$arima_residuals), na.rm = TRUE),
mean(abs(data$stacked_residuals), na.rm = TRUE),
mean(abs(data$stacked_residuals_1), na.rm = TRUE)),
#MAPE
c(mean(data$lm_ape, na.rm = TRUE),
mean(data$lm_lagged_ape, na.rm = TRUE),
mean(data$arima_ape, na.rm = TRUE),
mean(data$stacked_ape, na.rm = TRUE),
mean(data$stacked_ape_1, na.rm = TRUE)),
#RMSE
c(sqrt(mean(data$lm_residuals^2, na.rm = TRUE)),
sqrt(mean(data$lm_lagged_residuals^2, na.rm = TRUE)),
sqrt(mean(data$arima_residuals^2, na.rm = TRUE)),
sqrt(mean(data$stacked_residuals^2, na.rm = TRUE)),
sqrt(mean(data$stacked_residuals_1^2, na.rm = TRUE)))))
#rename columns and coerce to numeric
colnames(diagnostics) <- c('Model', 'MAE', 'MAPE', 'RMSE')
metrics <- rbind(metrics, diagnostics)
remove(diagnostics)
print(k)
}
# Aggregate fit values ----------------------------------------------------
temp <- metrics[76:575,]
for(i in 2:4) {
temp[,i] <- as.numeric(temp[,i])
}
#round MAE and RMSE, coerce MAPE to %
temp[,2] <- round(temp[,2], 2)
#temp[,3] <- percent(temp[,3], 0.01)
temp[,4] <- round(temp[,4], 2)
temp <- temp[complete.cases(temp),]
for(i in 2:ncol(temp)) {
print(aggregate(temp[,i],
by = list(temp$Model),
FUN = mean))
}
write.csv(temp,
file = 'aggregate_metrics.csv')
for(i in 2:ncol(metrics)) {
print(mean(metrics[,i]))
}
temp$index <- 1:nrow(temp)
viz <- melt(temp,
id.vars = c('index', 'Model'))
ggplot(data = viz) +
geom_histogram(aes(x = value)) +
facet_grid(rows = vars(viz$Model),
cols = vars(viz$variable),
scales = 'free_x')
|
336d861bb7d301b48eaa500d611c4cb5349eef99
|
d0c80b1c3fa3b584152a399581c3b0792811be6d
|
/man/possol.Rd
|
fd73de02d48c29d927a78d71a5aefeeef327af50
|
[] |
no_license
|
belasi01/asd
|
4dbeb7d2da9bbb3398a8bae6ee1d3e22ec34067d
|
16118ee6b49419ad0c26774f69158a2dc8b95347
|
refs/heads/master
| 2021-08-06T10:08:13.324759
| 2021-06-22T16:16:37
| 2021-06-22T16:16:37
| 72,467,268
| 1
| 2
| null | 2020-05-27T18:14:33
| 2016-10-31T18:43:12
|
HTML
|
UTF-8
|
R
| false
| true
| 711
|
rd
|
possol.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/possol.R
\name{possol}
\alias{possol}
\title{Compute the Sun position from the location and time on Earth}
\usage{
possol(month, jday, tu, xlon, xlat)
}
\arguments{
\item{month}{is an integer for the month number (1 to 12)}
\item{jday}{is the number of the day in the month}
\item{tu}{is the time in decimal in UTC}
\item{xlon}{is the longitude in decimal degree}
\item{xlat}{is the latitude in decimal degree}
}
\value{
It returns a vector of two numeric for the sun zenith angle and the azimuthal angle of the sun.
}
\description{
Compute the Sun position from the location and time on Earth
}
\author{
Bernard Gentilly, LOV
}
|
79d366da85b183db7ccc1b3c5086e42fcbea2a8a
|
c1d43bdf6a75b9485dcb74a93c8466741d13452e
|
/Statistica/Repartitii de va.R
|
ee3a15a5235960d46bb68c5de7b12c9df3f7d213
|
[] |
no_license
|
theodormoroianu/SecondYearCourses
|
bc981e9beb08e3c52945b6aa8f54a5cba7a35545
|
9dc399319172432b989c6f525fa51344ac8d13d1
|
refs/heads/main
| 2023-06-05T14:23:33.370022
| 2021-06-24T20:11:27
| 2021-06-24T20:11:27
| 300,949,174
| 10
| 5
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,254
|
r
|
Repartitii de va.R
|
#Repartitii de v.a.
#1.d+nume_repartitie=functie de masa(caz discret)/functia de densitate(caz continuu)
#dgeom(x,p)
#dbinom(x,n,p)
dbinom(3,5,0.4)
#P(X=3)
#dexp(x,lambda)
dexp(3,1)
#NU mai e o probabilitate
#2. p+nume_repartitie=functia de repartitie
# pbinom(x,n,p)
#P(X<=x)
pbinom(3,5,0.4)
#3. r+nume_repartitie=genereaza valori din acel tip de repartitie
# rbinom(nr,n,p)
rbinom(3,5,0.4)
#Reprezentari grafice de functii
#Functia densitate de probabilitate a repartitiei normale
t <- seq(-6,6,0.001)
plot(t,dnorm(t,0,1))
plot(t,dexp(t,2),ylim=c(0,0.))
#ATENTIE: IN R parametrii normalei sunt media si abaterea medie standard
y <- rnorm(100,0,1)
poz <- y[y>0]
prob_nr_poz <- length(poz)/10^2
neg <- y[y<0]
prob_nr_neg <- length(neg)/10^2
y <- rnorm(1000000,0,1)
length(y[(y>-3)&(y<3)])
lines(t,dnorm(t,0,1))
plot(t,dnorm(t,0,1),col="magenta",xlim=c(-8,8),ylim=c(0,1))
lines(t,dnorm(t,0,4), col=2)
lines(t,dnorm(t,0,0.5), col=3)
lines(t,dnorm(t,0,2), col=5)
lines(t,dnorm(t,0,0.5),col=1)
z <- rnorm(1000,2,1)
length(z[z< -2])
plot(t,dnorm(t,0,1),col="magenta",ylim=c(0,1.8))
for (i in c(0.25,0.5,0.3,0.9,1.3,2)) lines(t,dnorm(t,0,i), col=i*20)
|
3c89eee8e83277a7492e987060d201400937055c
|
d5cc7f10f54e30f84a7b1c9de22fd07de14a4e8c
|
/Evaluacion_01/Scripts/smith-waterman.R
|
3d83474b4ac6b633a7f65864482f24f3543deb36
|
[] |
no_license
|
KariVillagran/Bioinformatica
|
af174123b144abf407bf10477b5bdf197ce322af
|
94c9f2dd54ef6bf5fddfeeb34ce1bb63f7645fd4
|
refs/heads/master
| 2021-01-11T00:36:58.422315
| 2016-12-20T19:26:21
| 2016-12-20T19:26:21
| 70,535,612
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 2,793
|
r
|
smith-waterman.R
|
install.packages("stringr")
library(stringr)
# Algoritmo Smith-Waterman
smith <- function (s1,s2)
{
matriz = matrix(nrow=nchar(s2)+1,ncol=nchar(s1) + 1)
s1 <- paste("",s1)
s2 <- paste("",s2)
colnames(matriz) <- c(unlist(strsplit(s1, "")))
rownames(matriz) <- c(unlist(strsplit(s2, "")))
matriz <- inicializar_matriz(matriz)
matriz <- fill_table(matriz)
vectorScore <- score(matriz)
scoreResult <- paste("El score obtenido es de : ",vectorScore[1])
print(scoreResult)
#print(matriz)
vectorString <- reconstructionString(matriz,vectorScore[2],vectorScore[3])
print(vectorString[1])
print(vectorString[2])
}
score <- function(matriz)
{
maxValue <- 0
iMAxPos <- 0
jMAxPos <- 0
for(i in 2:nrow(matriz))
{
for(j in 2:ncol(matriz))
{
maxValue<- pmax(maxValue,matriz[i,j])
if(maxValue == pmax(maxValue,matriz[i,j]))
{
iMAxPos <- i
jMAxPos <- j
}
}
}
return(c(maxValue,iMAxPos,jMAxPos))
}
fill_table <- function(matriz)
{
match <- 1
gap <- -2
mmatch <- -1
puntaje <- 0
for(i in 2:nrow(matriz))
{
for(j in 2:ncol(matriz))
{
if(rownames(matriz)[i]==colnames(matriz)[j])
{
puntaje <- highScore(matriz[i-1,j]+gap,matriz[i,j-1]+gap,matriz[i-1,j-1]+match)
}
else
{
puntaje <- highScore(matriz[i-1,j]+gap,matriz[i,j-1]+gap,matriz[i-1,j-1]+mmatch)
}
matriz[i,j] <- puntaje
}
}
return(matriz)
}
inicializar_matriz <- function (matriz)
{
for(i in 1:nrow(matriz))
{
matriz[i,1] <- 0
}
for(j in 1:ncol(matriz))
{
matriz[1,j] <- 0
}
return(matriz)
}
highScore <- function (v1,v2,v3)
{
return(pmax(0,v1,v2,v3))
}
reconstructionString <- function(matriz, imax, jmax)
{
s1 <- ""
s2 <- ""
while((imax > 1 && jmax > 1) && matriz[imax,jmax] > 0 )
{
if(rownames(matriz)[imax]==colnames(matriz)[jmax])
{
s1 <- paste(colnames(matriz)[jmax],s1,sep="")
s2 <- paste(rownames(matriz)[imax],s2,sep="")
imax <- imax-1
jmax <- jmax-1
}
else
{
if(matriz[imax-1,jmax] > matriz[imax,jmax-1])
{
s2 <- paste(rownames(matriz)[imax],s2,sep="")
s1 <- paste("-",s1,sep="")
imax <- imax-1
}
else
{
s2 <- paste("-",s2,sep="")
s1 <- paste(colnames(matriz)[jmax],s1,sep="")
jmax <- jmax-1
}
}
}
return(c(s1,s2))
}
smith('AAAA','AAAA')
smith('GAATTCCTACTACGAAGAATTCCTACTACGAAACTACGAAAATTCCTACTACGA',
'GAATTCCTACTACGGAATTCCCCTCCCATAATTCCTACTACGA')
matriz = matrix(nrow = nchar("hola") + 1 , ncol = nchar("hola")+1)
s1 <- paste("","hola")
s2 <- paste("","hola")
rownames(matriz) <- c(unlist(strsplit(s1, "")))
colnames(matriz) <- c(unlist(strsplit(s2, "")))
matriz
|
bb5b7295f3ee66cbae9755eac5bf77af6d4f52fb
|
83ced69bbb0e163f85287138690794a863ef9956
|
/cachematrix.R
|
52eb521bc06db41456bffae9a320168e592f411a
|
[] |
no_license
|
GerhardStimie/ProgrammingAssignment2
|
5c6b416fe791087cb946a3ddead586226b0bbc2b
|
082051c7bc27914ec6135ac3ba6b90435ada1101
|
refs/heads/master
| 2020-04-02T21:18:47.517849
| 2018-10-27T10:45:10
| 2018-10-27T10:45:10
| 154,794,393
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 4,719
|
r
|
cachematrix.R
|
## Assignment 2 submission
##
## This source file contains 2 functions that:
## 1. Create a list of functions to calculate the inverse of a passed matrix
## 2. Store the resulting inverse matrix in cache
## 3. Return the cached matrix upon request if the inverse has been calculated before
## There are 2 functions in this source file:
##
## makeCachematrix
##
## accepts an optional source matrix ("input_mtx") to be inverted as input.
## as input.
## outputs a list of functions as follows:
## set Used to set the matrix to be converted. If this function
## is called directly, it will overwrite any matrix that
## was passed in the original call to makeCachematrix
## get When called this function (that takes no input)
## returns the matrix to be inverted as stored in the
## "input_mtx" parameter (either as it was passed in
## the original call to "makeCachematrix" or as overwritten
## by the matrix passed in "new_mtx"in a call to the
## "set" function)
## setinv Calculates the inverse of the "input_mtx" matrix and
## caches the resultin matrix in "cache_mtx"
## getinv Returns the matrix currently stored in "cache_mtx"
##
## cacheSolve
##
## accepts a list vector previously created by a call to the "makeCacheMatrix"
## function and returns the inverse of the matrix indicated in that list from
## either cache (if it has been calculated before), or by calculating it using
## the solve function if it was not calculated before. If the inverse matrix has not
## been calculated before, it is cached for future retrieval.
##
############# HOW TO TEST THESE FUNCTIONS #################################################
##
## 1. Create a square non-singular input matrix, eg mtx_1 <- matrix(rnorm(9,1), 3, 3)
## 2. Create a list using makeCacheMatrix, eg list_1 <- makeCacheMatrix(mtx_1)
## 3. Calculate the inverse using function cacheSolve, eg inv_1 <- cacheSolve(list_1)
## 4. Note the message to indicate if the inverse is calculated anew
## 5. Rerun the function for the same list, eg inv_2 <- cacheSolve(list_1)
## 6. Again note the message indicating that the inverse was returned from cache
## 7. comparing the the resulting inverted matrices using "identical" function should
## in a "TRUE" result, eg identical(inv_1, inv_2)
## 8. To test that the inverse is correct, multiplying (using matrix multiplication)
## the original matrix with the inverse matrix should produce an identity matrix,
## (round the result to see it more clearly) eg round(solve(mtx_1 %*% inv_1))
##
##############################################################################################
makeCacheMatrix <- function(input_mtx = matrix()) {
cache_mtx <- NULL
set <- function(new_mtx) {
input_mtx <<- new_mtx
cache_mtx <<- NULL
}
get <- function() input_mtx
setinv <- function(solve) cache_mtx <<- solve
getinv <- function() cache_mtx
list(set = set, get = get,
setinv = setinv,
getinv = getinv)
}
## This function returns the invered matrix for the matrix of a matrix through the
## "input_mtx" passed the the function makeCacheMatrix through a direct call or
## passed through the "new_mtx" parameter of the "set" function from a list previously
## created by a call to the makeCacheMatrix function.
cacheSolve <- function(input_list, ...) {
## load the cached inverted matrix for this list. if it exists, return the cached
## inverted matrix. If not, use solve function to calclulate the inverted matrix
## and cache the result for this list.
inv_mtx <- input_list$getinv()
if (!is.null(inv_mtx)) {
message("You have inverted this matrix before. Getting cached matrix.")
return(inv_mtx)
}
message("This is the first time you are inverting this matrix. Using Solve function to calculate inverted matrix")
mtx <- input_list$get()
inv_mtx <- solve(mtx, ...)
input_list$setinv(inv_mtx)
inv_mtx
}
|
c47136061a2fd8ab14d44e5179443aa24b09b060
|
08c48f2627281810fe2a4a37bb1e9bc5c03eeb68
|
/Huan_link_all_script/R/x86_64-pc-linux-gnu-library/3.4/VennDiagram/tests/test-Three.R
|
436974b194de4a0499a4744d01357ca7461617c6
|
[] |
no_license
|
Lhhuan/drug_repurposing
|
48e7ee9a10ef6735ffcdda88b0f2d73d54f3b36c
|
4dd42b35e47976cf1e82ba308b8c89fe78f2699f
|
refs/heads/master
| 2020-04-08T11:00:30.392445
| 2019-08-07T08:58:25
| 2019-08-07T08:58:25
| 159,290,095
| 6
| 1
| null | null | null | null |
UTF-8
|
R
| false
| false
| 8,885
|
r
|
test-Three.R
|
#Testing using package testthat for detailed error messages
library(testthat)
#Get the testing function applied to compare the two venn diagram objects
source("testFunction.R");
#load in the reference plot data
load("data/plotsThree.rda");
#Suppress plotting for sanity
options(device=pdf());
#initialize the testing list of venn diagrams
venn.test <- list();
#Default
venn.test <- c(venn.test,list(draw.triple.venn(65, 75, 85,
35, 15, 25, 5, c("First", "Second", "Third"))))
#Default and Colour
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 65,
area2 = 75,
area3 = 85,
n12 = 35,
n23 = 15,
n13 = 25,
n123 = 5,
category = c("First", "Second", "Third"),
fill = c("blue", "red", "green"),
lty = "blank",
cex = 2,
cat.cex = 2,
cat.col = c("blue", "red", "green")
)))
#001
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 4,
area2 = 3,
area3 = 4,
n12 = 2,
n23 = 2,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
#category = c('C','B','A'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#010
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 3,
area2 = 3,
area3 = 4,
n12 = 1,
n23 = 2,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#011A
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 3,
area2 = 2,
area3 = 4,
n12 = 1,
n23 = 2,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#011O
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 3,
area2 = 3,
area3 = 3,
n12 = 1,
n23 = 2,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#012AA
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 2,
area3 = 4,
n12 = 1,
n23 = 2,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#021AA
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 3,
area2 = 1,
area3 = 3,
n12 = 1,
n23 = 1,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#022AAAO
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 1,
area3 = 3,
n12 = 1,
n23 = 1,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#022AAOO
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 2,
area3 = 2,
n12 = 1,
n23 = 1,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#023
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 1,
area3 = 2,
n12 = 1,
n23 = 1,
n13 = 2,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#032
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 1,
area3 = 1,
n12 = 1,
n23 = 1,
n13 = 1,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#033
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 1,
area2 = 1,
area3 = 1,
n12 = 1,
n23 = 1,
n13 = 1,
n123 = 1,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#100
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 3,
area2 = 3,
area3 = 3,
n12 = 1,
n23 = 1,
n13 = 1,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#110
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 2,
area3 = 3,
n12 = 0,
n23 = 1,
n13 = 1,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#111A
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 1,
area3 = 3,
n12 = 0,
n23 = 1,
n13 = 1,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#112AA
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 1,
area2 = 1,
area3 = 3,
n12 = 0,
n23 = 1,
n13 = 1,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#120
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 2,
area2 = 1,
area3 = 2,
n12 = 0,
n23 = 0,
n13 = 1,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#121AO
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 1,
area2 = 1,
area3 = 2,
n12 = 0,
n23 = 0,
n13 = 1,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#122AAOO
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 1,
area2 = 1,
area3 = 1,
n12 = 0,
n23 = 0,
n13 = 1,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
#130
venn.test <- c(venn.test,list(draw.triple.venn(
area1 = 1,
area2 = 1,
area3 = 1,
n12 = 0,
n23 = 0,
n13 = 0,
n123 = 0,
category = c('A', 'B', 'C'),
fill = c('red', 'blue', 'green'),
cat.col = c('red', 'blue', 'green'),
cex = c(1/2,2/2,3/2,4/2,5/2,6/2,7/2),
cat.cex = c(1,2,3),
euler = TRUE,
scaled = FALSE
)))
testNames <- c('default','colour-default','001','010','011A','011O','012AA','021AA','022AAAO','022AAOO','023','032','033','100','110','111A','112AA','120','121AO','122AAOO','130');
#Strip the polygons of their x and y values. They have equivalent information in their params field
for(i in 1:length(venn.test)){
for(j in 1:length(venn.test[[i]])){
if(class(venn.test[[i]][[j]])[1] == "polygon"){
venn.test[[i]][[j]]$x <- NULL;
venn.test[[i]][[j]]$y <- NULL;
}
}
}
#Loop over all of the test cases
for(i in 1:length(venn.plot)){
test_that(paste("Case",testNames[i],"of three categories"),
{
for(j in 1:length(venn.plot[[i]])){
expect_that(venn.test[[i]][[j]],is_identical_without_name(venn.plot[[i]][[j]]));
}
})
}
#Reaches here only if error is not thrown beforehand
print("Three category tests complete. No discrepancies found");
|
d6ea173e105368e1528deecc0ec05f7064019e36
|
03b13ddf39e2c7f1cab356ea589775cc31612a7e
|
/man/bhl_namelist.Rd
|
b85f076eaa71fafcccc23eb2210e6c5e2ceb383a
|
[
"MIT",
"LicenseRef-scancode-public-domain"
] |
permissive
|
firefoxxy8/rbhl
|
e7f0b134584bda13561fd0d4a77691b4f145f025
|
b046f5748342d2256242941213a9555157dca0ed
|
refs/heads/master
| 2020-03-27T19:32:33.766244
| 2018-08-25T15:21:59
| 2018-08-25T15:21:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 1,523
|
rd
|
bhl_namelist.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bhl_namelist.R
\name{bhl_namelist}
\alias{bhl_namelist}
\title{List the unique names.}
\usage{
bhl_namelist(startrow = NULL, batchsize = NULL, startdate = NULL,
enddate = NULL, as = "table", key = NULL, ...)
}
\arguments{
\item{startrow}{first name to return (if using as an offset)}
\item{batchsize}{number of names to return (numeric)}
\item{startdate}{(optional) start date of range between which to count
names (date)}
\item{enddate}{(optional) end date of range between which to count
names (date)}
\item{as}{(character) Return a list ("list"), json ("json"), xml ("xml"),
or parsed table ("table", default). Note that \code{as="table"} can give
different data format back depending on the function - for example,
sometimes a data.frame and sometimes a character vector.}
\item{key}{Your BHL API key, either enter, or loads from your \code{.Renviron}
as \code{BHL_KEY}
or from \code{.Rprofile} as \code{bhl_key}.}
\item{...}{Curl options passed on to \code{\link[crul:HttpClient]{crul::HttpClient()}}}
}
\description{
By using the startrow and batchsize parameters appropriately, you can
pull the list all at once, or in batches (i.e. 1000 names at a time).
Names both with and without NameBank identifiers are returned.
}
\examples{
\dontrun{
bhl_namelist(startrow=1, batchsize=99, startdate='10/15/2009',
enddate='10/16/2009')
bhl_namelist(startrow=1, batchsize=5, startdate='10/15/2009',
enddate='10/31/2009', as='json')
}
}
|
3fcfa3cb4d0113cb6a838d89179668397e41ca70
|
ffdea92d4315e4363dd4ae673a1a6adf82a761b5
|
/data/genthat_extracted_code/RNetLogo/examples/NLGetAgentSet.Rd.R
|
43611515bf29ab4db7823105c9c60a52403561dd
|
[] |
no_license
|
surayaaramli/typeRrh
|
d257ac8905c49123f4ccd4e377ee3dfc84d1636c
|
66e6996f31961bc8b9aafe1a6a6098327b66bf71
|
refs/heads/master
| 2023-05-05T04:05:31.617869
| 2019-04-25T22:10:06
| 2019-04-25T22:10:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,533
|
r
|
NLGetAgentSet.Rd.R
|
library(RNetLogo)
### Name: NLGetAgentSet
### Title: Reports variable value(s) of one or more agent(s) as a
### data.frame (optional as a list or vector)
### Aliases: NLGetAgentSet
### Keywords: interface NLGetAgentSet RNetLogo
### ** Examples
## Not run:
##D nl.path <- "C:/Program Files/NetLogo 6.0/app"
##D NLStart(nl.path)
##D # NLLoadModel(...)
##D NLCommand("create-turtles 10")
##D
##D colors <- NLGetAgentSet(c("who","xcor","ycor","color"),
##D "turtles with [who < 5]")
##D str(colors)
##D
##D # or as a list (slightly faster):
##D colors.list <- NLGetAgentSet(c("who","xcor","ycor","color"),
##D "turtles with [who < 5]", as.data.frame=FALSE)
##D str(colors.list)
##D
##D # or as a list with one list element for each agent
##D # (very slow!, not recommended especially for large agentsets)
##D colors.list2 <- NLGetAgentSet(c("who","xcor","ycor","color"),
##D "turtles with [who < 5]", as.data.frame=FALSE,
##D agents.by.row=TRUE)
##D str(colors.list2)
##D
##D # getting the ends of links is a little bit more tricky, because they store only the
##D # reference to the turtles and turtles cannot directly be requested.
##D # A way to go is:
##D # create some links
##D NLCommand("ask turtles [ create-links-with n-of 2 other turtles ]")
##D link.test <- NLGetAgentSet(c("[who] of end1","[who] of end2"),"links")
##D str(link.test)
## End(Not run)
|
52b345ec3b0512f2e1fa76b51339082a77c37039
|
551d324609cc89855800ef120341c25e53ca7f92
|
/Data Processing/pca.R
|
9aab04ce8074d3a3164279b66a46c9566487817b
|
[] |
no_license
|
GiorgosTsal/Machine-Learning-in-R
|
d8fc235bab6c830604c62535594f2673faf98b5a
|
e677c8d6488569e92ebf0a664068f0d30fedbb4d
|
refs/heads/master
| 2022-04-01T21:00:00.340468
| 2020-02-03T09:38:41
| 2020-02-03T09:38:41
| 234,272,304
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 5,026
|
r
|
pca.R
|
#in order to set current directory as root
script.dir <- dirname(sys.frame(1)$ofile)
setwd(script.dir)
cat("\014") # for clearing console or use Ctrl+L
rm(list=ls()) #fir clearing env
#install.packages("factoextra")
library("factoextra")
#Load the data and extract only active individuals and variables:
data(decathlon2)
decathlon2.active <- decathlon2[1:23, 1:10]
head(decathlon2.active[, 1:6])
plot(decathlon2)
#Compute PCA in R using prcomp()
res.pca <- prcomp(decathlon2.active, scale = TRUE)
#visualize eigenvalues
print(fviz_eig(res.pca))
print(fviz_pca_ind(res.pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
))
print(fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
))
print(fviz_pca_biplot(res.pca, repel = TRUE,
col.var = "#2E9FDF", # Variables color
col.ind = "#696969" # Individuals color
))
#Access to the PCA results
# Eigenvalues
eig.val <- get_eigenvalue(res.pca)
eig.val
# Results for Variables
res.var <- get_pca_var(res.pca)
res.var$coord # Coordinates
res.var$contrib # Contributions to the PCs
res.var$cos2 # Quality of representation
# Results for individuals
res.ind <- get_pca_ind(res.pca)
res.ind$coord # Coordinates
res.ind$contrib # Contributions to the PCs
res.ind$cos2 # Quality of representation
# Data for the supplementary individuals
ind.sup <- decathlon2[24:27, 1:10]
ind.sup[, 1:6]
#predict
ind.sup.coord <- predict(res.pca, newdata = ind.sup)
ind.sup.coord[, 1:4]
# Plot of active individuals
p <- fviz_pca_ind(res.pca, repel = TRUE)
# Add supplementary individuals
print(fviz_add(p, ind.sup.coord, color ="blue"))
# Centering and scaling the supplementary individuals
ind.scaled <- scale(ind.sup,
center = res.pca$center,
scale = res.pca$scale)
# Coordinates of the individividuals
coord_func <- function(ind, loadings){
r <- loadings*ind
apply(r, 2, sum)
}
pca.loadings <- res.pca$rotation
ind.sup.coord <- t(apply(ind.scaled, 1, coord_func, pca.loadings ))
ind.sup.coord[, 1:4]
groups <- as.factor(decathlon2$Competition[1:23])
print(fviz_pca_ind(res.pca,
col.ind = groups, # color by groups
palette = c("#00AFBB", "#FC4E07"),
addEllipses = TRUE, # Concentration ellipses
ellipse.type = "confidence",
legend.title = "Groups",
repel = TRUE
))
library(magrittr) # for pipe %>%
library(dplyr) # everything else
# 1. Individual coordinates
res.ind <- get_pca_ind(res.pca)
# 2. Coordinate of groups
coord.groups <- res.ind$coord %>%
as_data_frame() %>%
select(Dim.1, Dim.2) %>%
mutate(competition = groups) %>%
group_by(competition) %>%
summarise(
Dim.1 = mean(Dim.1),
Dim.2 = mean(Dim.2)
)
coord.groups
quanti.sup <- decathlon2[1:23, 11:12, drop = FALSE]
head(quanti.sup)
# Predict coordinates and compute cos2
quanti.coord <- cor(quanti.sup, res.pca$x)
quanti.cos2 <- quanti.coord^2
# Graph of variables including supplementary variables
p <- fviz_pca_var(res.pca)
print(fviz_add(p, quanti.coord, color ="blue", geom="arrow"))
# Helper function
#::::::::::::::::::::::::::::::::::::::::
var_coord_func <- function(loadings, comp.sdev){
loadings*comp.sdev
}
# Compute Coordinates
#::::::::::::::::::::::::::::::::::::::::
loadings <- res.pca$rotation
sdev <- res.pca$sdev
var.coord <- t(apply(loadings, 1, var_coord_func, sdev))
head(var.coord[, 1:4])
# Compute Cos2
#::::::::::::::::::::::::::::::::::::::::
var.cos2 <- var.coord^2
head(var.cos2[, 1:4])
# Compute contributions
#::::::::::::::::::::::::::::::::::::::::
comp.cos2 <- apply(var.cos2, 2, sum)
contrib <- function(var.cos2, comp.cos2){var.cos2*100/comp.cos2}
var.contrib <- t(apply(var.cos2,1, contrib, comp.cos2))
print(head(var.contrib[, 1:4]))
# Coordinates of individuals
#::::::::::::::::::::::::::::::::::
ind.coord <- res.pca$x
print(head(ind.coord[, 1:4]))
# Cos2 of individuals
#:::::::::::::::::::::::::::::::::
# 1. square of the distance between an individual and the
# PCA center of gravity
center <- res.pca$center
scale<- res.pca$scale
getdistance <- function(ind_row, center, scale){
return(sum(((ind_row-center)/scale)^2))
}
d2 <- apply(decathlon2.active,1,getdistance, center, scale)
# 2. Compute the cos2. The sum of each row is 1
cos2 <- function(ind.coord, d2){return(ind.coord^2/d2)}
ind.cos2 <- apply(ind.coord, 2, cos2, d2)
head(ind.cos2[, 1:4])
# Contributions of individuals
#:::::::::::::::::::::::::::::::
contrib <- function(ind.coord, comp.sdev, n.ind){
100*(1/n.ind)*ind.coord^2/comp.sdev^2
}
ind.contrib <- t(apply(ind.coord, 1, contrib,
res.pca$sdev, nrow(ind.coord)))
head(ind.contrib[, 1:4])
|
9314582f61eb152200a24d179369cfa65666bd45
|
5875db7aaae2fb33c2097008bbc91ffa677ba7fa
|
/R/selection_alg.R
|
89d26465d0a3c128287b70a57ff7434ca5f95096
|
[] |
no_license
|
ClimDesign/fixIDF
|
a4e086a63cc6ce6d786614773b5b900be0d5c4ea
|
e8c36ac9f7b721c02412a95cba8e1b4e43a3a755
|
refs/heads/main
| 2023-08-12T03:50:39.609330
| 2021-10-07T11:54:04
| 2021-10-07T11:54:04
| 333,784,713
| 1
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 4,555
|
r
|
selection_alg.R
|
selection_alg=function(quant_bay,maxit=1000,strategy="up",save.history=TRUE,seed=NULL){
if(is.null(seed)==FALSE){
set.seed(seed)
}
curvehistory=list()
n=length(quant_bay)
bestguess=c()
pvec=rep(0,n)
quantilevec=rep("50%",n)
quantvec=rep("50%",n)
quantilehistory=quantvec
names(pvec)=1:n
possiblequants=rownames(quant_bay[[1]])
possiblequants_temp=as.numeric(substr(possiblequants,1,nchar(possiblequants)-1))
possiblequants_prob=possiblequants_temp
possiblequants_prob=abs(50-possiblequants_prob)
quants=list(name=possiblequants,prob=possiblequants_prob)
convergence=TRUE
#0: Initialize with medians:
for(j in 1:n){
bestguess=rbind(bestguess,quant_bay[[j]][which(rownames(quant_bay[[1]])=="50%"),])
}
bestguess_initial=bestguess
#0: Start counter:
k=1
#Save curve history in a list:
if(save.history==TRUE){
curvehistory[[k]]=bestguess
}
#Check if posterior medians give consistent return levels:
isCrossingF=crossing_check(bestguess)
isNonMonotonicF=nonMonotonic_check(bestguess)
while((sum(isNonMonotonicF)>0 | sum(isCrossingF)>0 ) & k < maxit) {
#1: Identify problematic durations:
problematic_curves=sort(unique(c(which(isCrossingF !=0 ,arr.ind=T)[,1],which(isNonMonotonicF==1))))
#2: We draw one of the curves, denoted C*, from problematic_curves. This will be moved in this iteration:
tochange=sample(problematic_curves,1)
#Currently chosen quantile for C*
currentQuant=quantvec[tochange]
#Check which other curves C* crosses with:
whocross=sort(unique(c(which(isCrossingF[tochange,]==1),problematic_curves[which(abs(tochange-problematic_curves)<0)])))
if(sum(tochange<whocross)==length(whocross)){
indchange=which(rownames(quant_bay[[1]])==currentQuant)-1
}else if(sum(tochange>whocross)==length(whocross)){
indchange=which(rownames(quant_bay[[1]])==currentQuant)+1
}else{
if(strategy=="up"){
indchange=which(rownames(quant_bay[[1]])==currentQuant)+1
}
if(strategy=="down"){
indchange=which(rownames(quant_bay[[1]])==currentQuant)-1
}
}
#If we are outside our boundaries, we reset the curve to the posterior median:
if(indchange> dim(quant_bay[[tochange]])[1] | indchange<1){
indchange=which(rownames(quant_bay[[tochange]])=="50%") #Reset to median.
}
#Update our curve set accordingly:
bestguess[tochange,]=quant_bay[[tochange]][indchange,]
#Update probability vectors:
quantvec[tochange]=rownames(quant_bay[[tochange]])[indchange]
quantasnum=as.numeric(substr(quantvec[tochange],1,nchar(quantvec[tochange])-1))
pvec[tochange]=abs(50-quantasnum)/100
#Increase counter:
k=k+1
#Save quantile and curve history:
quantilehistory=cbind(quantilehistory,quantvec)
if(save.history==TRUE){
curvehistory[[k]]=bestguess
rownames(curvehistory[[k]])=names(quant_bay)
}
#Consistency check for the updated curve set:
isCrossingF=crossing_check(bestguess)
isNonMonotonicF=nonMonotonic_check(bestguess)
}
if(k ==maxit & (sum(isNonMonotonicF)>0 | sum(isCrossingF)>0 )){ #If we have met the stopping criterion indicating non-convergence:
if(strategy=="up"){
print(paste("Upwards algorithm didn't converge in ", maxit ," iterations.",sep=""))
}
if(strategy=="down"){
print(paste("Downwards algorithm didn't converge in ", maxit ," iterations.",sep=""))
}
}else if (k==1){ #If the posterior medians were consistent.
print("No adjustments needed. The posterior medians give consistent curves.")
}else{
if(strategy=="up"){
print(paste("Upwards algorithm converged in ", k ," iterations.",sep=""))
}
if(strategy=="down"){
print(paste("Downwards algorithm converged in ", k ," iterations.",sep=""))
}
}
quantilehistory=substr(quantilehistory,1,nchar(quantilehistory)-1)
rownames(bestguess)=names(quant_bay)
rownames(bestguess_initial)=names(quant_bay)
names(pvec)=names(quant_bay)
names(quantvec)=names(quant_bay)
if(k>1){
rownames(quantilehistory)=names(quant_bay)
colnames(quantilehistory)=paste("k=",1:k,sep="")
if(save.history==TRUE){
names(curvehistory)=paste("k=",1:k,sep="")
}
}
if(k==maxit){
k=0
convergence=FALSE
bestguess=NULL
pvec=NULL
quantvec=NULL}
return(list(convergence=convergence,k=k,adjusted.curves=bestguess,unadjusted.curves=bestguess_initial,pvec=pvec,quantvec=quantvec,quantile.history=quantilehistory,curve.history=curvehistory))
}
|
b99eb3348df3626ea98280a03ea70e1218d4e57d
|
6e32987e92e9074939fea0d76f103b6a29df7f1f
|
/googleaiplatformv1.auto/man/GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics.Rd
|
7a04422d40f8e85b6c9147d4ab9c6b75a19b3db1
|
[] |
no_license
|
justinjm/autoGoogleAPI
|
a8158acd9d5fa33eeafd9150079f66e7ae5f0668
|
6a26a543271916329606e5dbd42d11d8a1602aca
|
refs/heads/master
| 2023-09-03T02:00:51.433755
| 2023-08-09T21:29:35
| 2023-08-09T21:29:35
| 183,957,898
| 1
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 1,439
|
rd
|
GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/aiplatform_objects.R
\name{GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics}
\alias{GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics}
\title{GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics Object}
\usage{
GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics(
precision = NULL,
confidenceThreshold = NULL,
recall = NULL,
f1Score = NULL
)
}
\arguments{
\item{precision}{Precision for the given confidence threshold}
\item{confidenceThreshold}{Metrics are computed with an assumption that the Model never returns predictions with score lower than this value}
\item{recall}{Recall (True Positive Rate) for the given confidence threshold}
\item{f1Score}{The harmonic mean of recall and precision}
}
\value{
GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics object
}
\description{
GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics Object
}
\details{
Autogenerated via \code{\link[googleAuthR]{gar_create_api_objects}}
No description
}
\concept{GoogleCloudAiplatformV1SchemaModelevaluationMetricsTextExtractionEvaluationMetricsConfidenceMetrics functions}
|
5e633c50c9a400aaabf71e2a4fba8a4fb9a69f9c
|
012b34b9323b72a8a4a6e2a365849b69a9a78286
|
/Project 1 Plot 2.R
|
220cab4351c3edbb1d27f440a35fbf1fc989df7b
|
[] |
no_license
|
Shivens/Coursera
|
7e3585643e8026f9ec6e93e7a5eb2abe4f4a3082
|
7f95b6ee936b39b004134abdba6344520237a63b
|
refs/heads/master
| 2021-01-23T08:34:55.330442
| 2015-02-02T14:49:08
| 2015-02-02T14:49:08
| 29,438,173
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,177
|
r
|
Project 1 Plot 2.R
|
# To execute just copy the relevant sections and exceute (Ctrl+R)
############ DATA INPUT - Reading file ######################
rm(list = ls())
#0) Ensure file "household_power_consumption.txt" is in source directory
#1) Reading the .TXT file correctly, by skipping initial rows
mydata=read.csv("household_power_consumption.txt", sep = ";",header=TRUE,nrows=2880, skip=66636)
#2) Headers are lost by skipping so re-assigning column names
colnames(mydata)<-c( "Date","Time","Global_active_power","Global_reactive_power","Voltage","Global_intensity","Sub_metering_1","Sub_metering_2","Sub_metering_3")
#3) Check the read data
ls()
names(mydata)
mydata
############ Plot 2 ##################################
#1) Attach date and time as one string, ex:"2/2/2007 23:59:00"
timestr<-paste(mydata$Date,mydata$Time)
#2) Convert it to a time strip using 'Strptime()'
timestr<-strptime(timestr, "%d/%m/%Y %H:%M:%S")
#3) Plot Global active power against Time strip.
plot(timestr,mydata$Global_active_power,type="l",xlab="",ylab="Global Active Power (kilowatts)")
#Create PNG file
dev.copy(png,file="Plot2.png")
dev.off()
############ END ##################################
|
95c37b7ebb1ae57527ea7d65c8baa76086d14e68
|
007e32a803059d789dcc66b99dd14913b2e9489f
|
/Code/Modified_LC.r
|
7d2010407eed914d758a3dfe89e6eee72b3edee6
|
[] |
no_license
|
NanduDara/Mobile-Data-Offloading
|
cd4e8e94b22f35cd6750d3a2675b6ecbafd2b2da
|
a2bd8bb4991ac44fcf5bf86880d08543b733b71f
|
refs/heads/master
| 2020-08-05T17:04:51.127393
| 2019-10-03T16:31:08
| 2019-10-03T16:31:08
| 212,626,491
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,413
|
r
|
Modified_LC.r
|
#There are 10 data items in increasing order
n <- 10
m <- 3
z <- sample(30000:40000, n)
z <- sort(z)
#Local Cost
l_c <- matrix(data=0, nrow=n,
ncol=m)
l_e <- runif(m, min = 0, max = 1)
l_e <- round(l_e, 3)
l_e <- sort(l_e)
l_t <- runif(m, min = 0, max = 1)
l_t <- round(l_t, 3)
l_t <- sort(l_t)
alpha <- runif(m, min = 0, max = 1)
alpha <- round(alpha, 2)
alpha <- sort(alpha)
gamma <- sample(200:600, m)
gamma <- sort(gamma)
freq <- runif(m, min = 0, max = 1)
freq <- round(freq, 6)
freq <- sort(freq)
process_task <- function(z,gamma,freq){
value <- (z*gamma)/freq
returnValue(value)
}
for(i in 1:n)
{
for(j in 1:m)
{
l_c[i,j] <- ((l_e[j])*(alpha[j])*((z[i]*gamma[j])/freq[j])) +
((l_t[j])*((z[i]*gamma[j])/freq[j]))
l_c[i,j] <- l_c[i,j] / 1000000
}
}
for(j in 1:m)
{
l_c[,j] <- round(l_c[,j],digits=2)
}
data <- data.frame(alpha,freq,gamma,l_e,l_t)
plot_data <- data.frame(l_c[,1],l_c[,2],l_c[,3],z)
write.csv(plot_data,file="one.csv")
write.csv(data,file="two.csv")
#Graph 1
data <- read.csv("one.csv")
colnames(data)[1] <- "one"
colnames(data)[2] <- "two"
colnames(data)[3] <- "three"
Data <- c(1,2,3,4,5,6,7,8,9,10)
plot(Data, data$one, xlab='Data', ylab='Cost', type='o', col='green')
axis(1, seq(1,10,1))
lines(Data, data$two, type='o',col='purple')
lines(Data, data$three, type='o',col='red')
|
c42153e04fca44ffc456a4dab52807698c9d1e62
|
fea763229750657d1f22b2fb970b9abb357c72bb
|
/InClass/.Rproj.user/99D7318E/sources/per/t/D1344DEF-contents
|
efd14083342e698d5a979847dd466c31d22ea6ad
|
[] |
no_license
|
AbigailCastro17/SYS2202-Data-and-Information-Engineering
|
8b9547f203ce7dc04a178414a5583481bfc798a1
|
ae0002c643537e86d3e2865929e4054aec35786a
|
refs/heads/main
| 2023-04-30T22:25:24.315274
| 2021-05-19T04:39:23
| 2021-05-19T04:39:23
| 368,744,123
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 2,166
|
D1344DEF-contents
|
# You can convert this into an .Rmd if you are comfortable with it.
# The name of your file should include your Zoom team number. Please make sure to pick a consistent name with your teammates.
# ----------------------------------------------------------
library(dplyr)
library(nycflights13)
library(tidyverse)
View(flights)
?flights
# Imagine you are hired as a Systems Engineer to optimize the air-traffic at New York airports.
# First you need to identify what needs to be optimized:
# Brainstorm about potential problems in air traffic. Write down at least 3 potential problems.
# 1. Bad weather
# 2. Destination
# 3. Time of Year
# Time of Year
# Month, maybe more flights during certain months
# Data sources
# Distance
# Longer flights, more likely to cancel
# Time of Day
# Later flights more likely to cancel
# Ww want to see if later flights cause more problems
# For each item in your list of problems,
# identify data sources in nycflights13 that can be helpful in your analysis.
# Write down the rationale for why/how you think this data will help demonstrate the problem.
# List the set of data transformation techniques you may need for each, e.g., what new variables/attributes do you need to create? what combination of data columns will you need? etc.
# List the visualization techniques you can use to demonstrate the problem, trends, etc. What will each visualization show?
# Write an R script for demonstrating the first problem in your list.
flights <- within(flights, month <- factor(month, levels = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "NA"), ordered = TRUE))
ggplot(data = flights) +
geom_bar(mapping = aes(x = month))
flights <- within(flights, origin <- factor(origin))
ggplot(data = flights) +
geom_bar(mapping = aes(x = origin))
ggplot(data = flights) +
geom_point(mapping = aes(x = distance, y = dep_delay, color = origin, na.rm = FALSE))
ggplot(data = flights) +
geom_point(mapping = aes(x = distance, y = arr_delay, color = dest))
ggplot(data = flights, aes(x = dep_delay, y = arr_delay, color = origin, na.rm = TRUE)) +
geom_point() +
geom_smooth()
|
|
6601b89c588bce8478a9196adc1b93082d9d6605
|
7caa535fa86544482ae18d5408012edc9fbc5ddd
|
/man/InitBinaryFA.Rd
|
d9ff93aea19430d21e015d1c069c4509bf0c3930
|
[
"Apache-2.0"
] |
permissive
|
kant/scBFA
|
7e11800a7bf6b4fa1fa963b51a22b6168e8cf554
|
82913a20ccaafd8622d51fc4634a854344920c82
|
refs/heads/master
| 2020-12-11T16:41:58.304222
| 2019-08-22T06:39:28
| 2019-08-22T06:39:28
| 233,900,004
| 0
| 0
| null | 2020-01-14T17:44:16
| 2020-01-14T17:44:15
| null |
UTF-8
|
R
| false
| true
| 2,056
|
rd
|
InitBinaryFA.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/BFA.R
\name{InitBinaryFA}
\alias{InitBinaryFA}
\title{This function should be called to initialize input parameters into the
main scBFA function}
\usage{
InitBinaryFA(modelEnv, GeneExpr, numFactors, epsilon, X = NULL,
Q = NULL, initCellcoef, updateCellcoef, updateGenecoef)
}
\arguments{
\item{modelEnv}{Empty R environment variable to contain following parameters:
{A,Z,V,U,\eqn{\beta},\eqn{\gamma},\eqn{\epsilon}}}
\item{GeneExpr}{G by N rawcount matrix,
in which rows are genes and columns are cells}
\item{numFactors}{Numeric value, number of latent dimensions}
\item{epsilon}{Numeric value, parameter to control the strength of
regularization}
\item{X}{N by C cell-specific covariate matrix(e.g batch effect),
in which rows are cells,columns are number of covariates.
If no such covariates are available, then X = NULL}
\item{Q}{G by T gene-specific covariate matrix(e.g quality control measures),
in which rows are genes columns are number of covariates,
If no such covariates are available, then Q = NULL}
\item{initCellcoef}{Initialization of C by G gene-specific coefficient matrix
as user-defined coefficient \eqn{\beta}.
Such user defined coefficient can be applied to address confounding batch
effect}
\item{updateCellcoef}{Logical value, parameter to decide whether to
update C by G gene-specific coefficient matrix.
Again, when the cell types are confounded with technical batches or
there is no cell level covariate matrix,
the user can keep the initialization of coefficients as known estimate.}
\item{updateGenecoef}{Logical value, parameter to decide whether to update
N by T gene-specific coefficient matrix.
Again, when there is no gene level covariate matrix,
this value should be FALSE by default.}
}
\value{
A model environment containing the following parameters:
{A,Z,V,U,\eqn{\beta},\eqn{\gamma},\eqn{\epsilon}}.
}
\description{
This function should be called to initialize input parameters into the
main scBFA function
}
\keyword{internal}
|
4a1d8c4a6cd9b3f438b651d5db738a2fec4aa75a
|
45745857ce9ef0eafd57201cf1a966095fe0c54c
|
/.Rproj.user/5205562C/sources/s-6E0280BE/3CC48C71-contents
|
6b550abf8d1967c8b24403814e463235981358bb
|
[] |
no_license
|
anuran-roy/learning-R
|
3fade44be5ffbfb150cfa92340a9a31464ae2384
|
797b60963c15a693ecf89078c195867ade0a9f84
|
refs/heads/main
| 2023-06-23T10:38:36.308879
| 2021-07-16T15:29:36
| 2021-07-16T15:29:36
| 386,683,338
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,201
|
3CC48C71-contents
|
library(ggplot2)
ggplot(mtcars, aes(x="disp", y= "mpg")) #, aes(x=read)) + geom_bar()
data(iris)
# data(package = .packages(all.available = TRUE))
IrisPlot <- ggplot(iris, aes(x= Sepal.Length, y=Petal.Length, colour=Species)) + geom_density()
print(IrisPlot)
data("airquality")
OzonePlot <- ggplot(airquality,
aes(x= Ozone)) + geom_histogram(aes(y=..count..),
colour = "black",
fill = "cornflowerblue",
binwidth = 5) + scale_x_continuous(
name = "Mean ozone\n(ppb)",
breaks = seq(0,175, 25),
limits = c(0,25+max(airquality$Ozone, na.rm = TRUE))
)
print(OzonePlot)
ggplot(airquality,aes(x=Ozone)) + geom_density() # KD Plot
ggplot(airquality,
aes(x=factor(airquality$Month,
labels=c("May", "Jun", "Jul", "Aug", "Sep")),
y=Ozone)) + geom_boxplot(
fill="gray",
colour = "black"
) + scale_x_discrete(name = "Month") + ggtitle(
"Boxplot of mean ozone by month"
) # Box Plot
# Save a plot as a JPEG file
jpeg("myplot.jpg")
counts <- table(mtcars$gear)
barplot(counts)
dev.off() # Returns control to console
|
|
b8ca5da92ee4af63b11a1e20b42365ba73f7a92e
|
ca04b59fa5778544808aac5f8e8d4f1a7f890b1e
|
/man/hi-package.Rd
|
4c89fe8d7bf1b6de94790e4aaaa1bdfebfe1cfdb
|
[] |
no_license
|
elistein/capm
|
72cba9ea2652d8da9518406ecfa1854ee23f9cdf
|
9c3757449f597ba1fb58d6405382673f8db60029
|
refs/heads/master
| 2020-04-06T03:49:19.543078
| 2013-09-16T22:12:27
| 2013-09-16T22:12:27
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,157
|
rd
|
hi-package.Rd
|
\name{capm-package}
\alias{capm-package}
\alias{capm}
\docType{package}
\title{
Customer Analytics Using Probability Models
}
\description{
Fit latent variable models to understand who your customers are and what they will do next. Contains maximum likelihood estimation routines for a variety of models, as well as S3 methods to explore model fit and produce forecasts.
}
\details{
\tabular{ll}{
Package: \tab capm\cr
Type: \tab Package\cr
Version: \tab 1.0\cr
Date: \tab 2013-05-17\cr
License: \tab What license is it under?\cr
}
~~ An overview of how to use the package, including the most important functions ~~
}
\author{
Eli Stein (eli.manfred.stein@gmail.com)
Maintainer: Who to complain to <yourfault@somewhere.net>
~~ The author and/or maintainer of the package ~~
}
\references{
~~ Literature or other references for background information ~~
}
~~ Optionally other standard keywords, one per line, from file KEYWORDS in the R documentation directory ~~
\keyword{ package }
\seealso{
~~ Optional links to other man pages, e.g. ~~
~~ \code{\link[<pkg>:<pkg>-package]{<pkg>}} ~~
}
\examples{
~~ simple examples of the most important functions ~~
}
|
488607410f11196006653cf76dc5d98eae3a528a
|
d32b0504ce7158272bba512bfba6ba2a6f01b07e
|
/man/flexCrossHaz-package.Rd
|
4db4bc7a3d2014e768c9482fead76c07f1acd9b7
|
[] |
no_license
|
cran/flexCrossHaz
|
0834f8da50c7d7c36286bd4223a1f2b96ddea6df
|
1790e7dfd7eb9e0387e98b9681665c0415b48a43
|
refs/heads/master
| 2020-06-06T04:00:09.243786
| 2010-03-25T00:00:00
| 2010-03-25T00:00:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,627
|
rd
|
flexCrossHaz-package.Rd
|
\name{flexCrossHaz-package}
\alias{flexCrossHaz-package}
\alias{flexCrossHaz}
\docType{package}
\title{
Flexible crossing hazards in the Cox model
}
\description{
Estimation of Cox model with flexible time-varying effects via P-splines and possible crossing points.
}
\details{
\tabular{ll}{
Package: \tab flexCrossHaz\cr
Type: \tab Package\cr
Version: \tab 0.2\cr
Date: \tab 2010-03-25\cr
License: \tab GPL\cr
}
Given a covariate with a time-varying effect, the package \code{flexCrossHaz} allows to
include it in the `linear predictor' of the Cox model. Penalized splines ar employed
to obtain a smooth estimate of the time-varying effect, and the possible crossing point is estimated.
Several variables with time-varying effect are allowed.
}
\author{
Vito M.R. Muggeo \email{vito.muggeo@unipa.it}\cr
Miriam Tagliavia \email{tagliavia@dssm.unipa.it}
Maintainer: Miriam Tagliavia \email{tagliavia@dssm.unipa.it}
}
\references{
Verweij, P. and van Houwelingen, H. (1995) Time-dependent effects of fixed
covariates in Cox regression. \emph{Biometrics} ; \bold{51}:1550--1556.
Mantel, N. and Stablein, D. (1988) The crossing hazard function problem. \emph{The
Statistician} ; \bold{37}:59--64.
Liu, K., Qiu, P. and Sheng, J. (2007) Comparing two crossing hazard rates by Cox
proportional hazards modelling. \emph{Statistics in Medicine} ; \bold{26}:375--391.
Muggeo, V.M.R. and Tagliavia, M. (2010) A flexible approach to the crossing
hazards problems. \emph{Submitted}.
}
\keyword{ package }
\keyword{regression}
\seealso{
\code{\link[survival]{coxph}}
}
|
0fc8d9da0cedff0c7de284d03ac5c79309172d99
|
a7d3f3e36460e71c4b34f0c95f955818ed2727f4
|
/tests/testthat.R
|
aa1883a04673201ff4d35285c29b2171083421e5
|
[
"MIT"
] |
permissive
|
etiennebacher/shinyfullscreen
|
9585779741b4d9788040d970eb51f140377fe2c4
|
81ca0b905e4636d942dca01feb3017662c7254b7
|
refs/heads/master
| 2023-05-04T06:07:53.131718
| 2023-04-20T14:31:03
| 2023-04-20T14:31:03
| 320,671,350
| 31
| 2
|
NOASSERTION
| 2021-01-11T19:51:12
| 2020-12-11T19:58:35
|
R
|
UTF-8
|
R
| false
| false
| 74
|
r
|
testthat.R
|
library(testthat)
library(shinyfullscreen)
test_check("shinyfullscreen")
|
1fba8ba67c8de19414a1dfacd27e22daec5c3291
|
438a9cb09f3afcc8cc9da4622028abe408fb15ac
|
/R_code/demo_R.r
|
b58ab3153877e084c2363be1d832a28b10fee567
|
[] |
no_license
|
Stuart-Aitken/ISS
|
a4cf29684e80f95f761ab0694b9daf90d0e8f03a
|
7c8c738665df796b78338f779a88a1b2531575ff
|
refs/heads/master
| 2020-07-23T09:47:30.621173
| 2019-09-11T08:36:23
| 2019-09-11T08:36:23
| 207,518,733
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 5,307
|
r
|
demo_R.r
|
# Copyright (C) 2019 The University of Edinburgh
# Author Stuart Aitken MRC IGMM stuart.aitken@igmm.ed.ac.uk
# All Rights Reserved.
# Funded by the Medical Research Council
# https://www.ed.ac.uk/mrc-human-genetics-unit
library(e1071);
library(Hmisc);
source('functions.r');
quartz(width=12,height=4)
par(mfrow=c(1,2));
# example 1. 5 unlabelled data points
# 5 data points (4 discrete attributes) with two distinct patterns
obs <- rbind(c( "1", "1","-1","-1"), # pattern A
c("-1","-1", "1", "1"), # pattern B
c( "1", "1","-1","-1"), # pattern A
c("-1","-1", "1", "1"), # pattern B
c("-1","-1", "1", "1")); # pattern B
colnames(obs) <- c('d1','d2','d3','d4');
obs <- data.frame(obs);
# prior to calling EM Naive Bayes, randomly initialise probability tables following the naive Bayes object convention
# q0 specifies the initial class probabilities
# q_y0 is the list of attribute values / class probability tables
set.seed(2017);
q0 <- c(x<-runif(1),1-x);
tables2 <- vector('list',length=4);
for(i in 1:4) {
tables2i <- rbind(c(x<-runif(1),1-x),
c(x<-runif(1),1-x));
tables2i <- data.frame(tables2i);
colnames(tables2i) <- c('-1','1');
rownames(tables2i) <- c('y1','y2');
tables2[[i]] <- tables2i;
}
tables2;
# call EM Naive Bayes specifying 2 class labels, plot log likelihood on completion of EM
resultEM_k_eq_2 <- EM_NB_Fn(obs,q0,tables2,maxiter=10,classLabels=c('y1','y2'),PLOT=TRUE);
resultEM_k_eq_2;
# predict labels for data using standard predict() method
pred_class <- predict(as_NBobj(resultEM_k_eq_2,colnames(obs)),obs);
pred_class;
# example 2. iris data
data(iris);
# discretise iris data into 3 bins
irisDiscr <- iris;
irisDiscr$Sepal.Length <- cut2(irisDiscr$Sepal.Length,g=3);
irisDiscr$Sepal.Width <- cut2(irisDiscr$Sepal.Width,g=3);
irisDiscr$Petal.Length <- cut2(irisDiscr$Petal.Length,g=3);
irisDiscr$Petal.Width <- cut2(irisDiscr$Petal.Width,g=3);
irisDiscr$Species <- factor(irisDiscr$Species);
# prior to calling EM Naive Bayes, randomly initialise probability tables for 3 classes
# q01, q02, (1-q01-q02) specify the initial class probability
# tables3 is the list of attribute values / class probability tables [for simplicity here, assume 3 bins in all cases]
set.seed(2109);
q01 <- runif(1,min=0,max=0.4);
q02 <- runif(1,min=0,max=0.4);
tables3 <- vector('list',length=4);
for(i in 1:4) {
tables3[[i]] <- (array(dim=c(3,3),0));
rownames(tables3[[i]]) <- c('y1','y2','y3');
colnames(tables3[[i]]) <- levels(irisDiscr[,i]);
for(j in 1:3) {
q01ij <- runif(1,min=0,max=0.4);
q02ij <- runif(1,min=0,max=0.4);
tables3[[i]][j,] <- c(q01ij,q02ij,1-(q01ij+q02ij));
}
}
tables3;
# call EM Naive Bayes specifying 3 class labels, plot log likelihood on iteration 20 and on completion of EM
resultEM_k_eq_3 <- EM_NB_Fn(irisDiscr[,1:4],c(q01,q02,(1-q01-q02)),tables3,
maxiter=100,classLabels=c('y1','y2','y3'),FACTORS=TRUE,PLOT=TRUE);
lll <- length(resultEM_k_eq_3$ll);
cat(paste('no. iterations:',(lll-1),'last delta LL:',resultEM_k_eq_3$ll[lll]-resultEM_k_eq_3$ll[(lll-1)],'\n'));
# predict labels for data using standard predict() method
pred_class_iris <- predict(as_NBobj(resultEM_k_eq_3,colnames(irisDiscr)[1:4]),irisDiscr[,1:4]);
pred_class_iris;
# compare with true labels
table(pred=pred_class_iris,true=irisDiscr$Species);
#pred setosa versicolor virginica
# y3 50 0 0
# y2 0 49 10
# y1 0 1 40
par(mfrow=c(1,3)); # compare with PCA projection
x <- prcomp(iris[,1:4]);
cols <- array(dim=length(pred_class_iris),'red')
cols[pred_class_iris=='y2']<-'green'
cols[pred_class_iris=='y3']<-'blue'
plotPCA(x,choices=c(1,2),cols);
plotPCA(x,choices=c(1,3),cols);
plotPCA(x,choices=c(1,4),cols);
# example 3. iris data looking for 4 classes
# prior to calling EM Naive Bayes, randomly initialise probability tables for 4 classes
set.seed(2099);
q01 <- runif(1,min=0,max=0.3);
q02 <- runif(1,min=0,max=0.3);
q03 <- runif(1,min=0,max=0.3);
tables4 <- vector('list',length=4);
for(i in 1:4) {
tables4[[i]] <- (array(dim=c(4,3),0));
rownames(tables4[[i]]) <- c('y1','y2','y3','y4');
colnames(tables4[[i]]) <- levels(irisDiscr[,i]);
for(j in 1:4) {
q01ij <- runif(1,min=0,max=0.3);
q02ij <- runif(1,min=0,max=0.3);
tables4[[i]][j,] <- c(q01ij,q02ij,1-(q01ij+q02ij));
}
}
tables4;
par(mfrow=c(1,1));
resultEM_k_eq_4 <- EM_NB_Fn(irisDiscr[,1:4],c(q01,q02,q03,(1-q01-q02-q03)),tables4,
maxiter=500,classLabels=c('y1','y2','y3','y4'),FACTORS=TRUE,PLOT=TRUE);
lll <- length(resultEM_k_eq_4$ll);
cat(paste('no. iterations:',(lll-1),'last delta LL:',resultEM_k_eq_4$ll[lll]-resultEM_k_eq_4$ll[(lll-1)],'\n'));
# predict labels for data using standard predict() method
pred_class_iris_4 <- predict(as_NBobj(resultEM_k_eq_4,colnames(irisDiscr)[1:4]),irisDiscr[,1:4]);
pred_class_iris_4;
# compare with true labels
table(pred=pred_class_iris_4,true=irisDiscr$Species);
#pred setosa versicolor virginica
# y2 50 0 0
# y1 0 49 9
# y3 0 0 23
# y4 0 1 18
|
5eba58ca4211fa2c8fce55b05ba0a9fed35d5817
|
ffcb30f62bb5a82ce1fd709d456f64d1e910e4e3
|
/src/update-depth-charts.R
|
cf678356f2705acec4cc5a59954deee438fedab7
|
[
"MIT"
] |
permissive
|
nflverse/nflverse-rosters
|
9d3deef3aea215db279c89bc3672964a851c8af9
|
265468baa09d27a94efad2776e194135b721e59f
|
refs/heads/master
| 2023-08-03T10:15:17.147507
| 2023-08-01T02:32:08
| 2023-08-01T02:32:08
| 295,816,576
| 1
| 2
|
NOASSERTION
| 2023-09-06T06:06:31
| 2020-09-15T18:32:02
|
R
|
UTF-8
|
R
| false
| false
| 3,275
|
r
|
update-depth-charts.R
|
scrape_teams <- function(season) {
h <- httr::handle("https://www.nfl.info")
r <- httr::GET(
handle = h,
path = glue::glue(
"/nfldataexchange/dataexchange.asmx/getClubs?lseason={season}"
),
httr::authenticate("media", "media"),
url = NULL
)
teams_df <- httr::content(r) |>
XML::xmlParse() |>
XML::xmlToDataFrame()
rm(h) # close handle when finished, have had the api get mad when I don't close it
return(teams_df)
}
scrape_dc <- function(season, team, season_type) {
h <- httr::handle("https://www.nfl.info")
r <- httr::GET(
handle = h,
path = glue::glue(
"/nfldataexchange/dataexchange.asmx/getGameDepthChart?lSeason={season}&lSeasonType={season_type}&lWeek=0&lClub={team}"
),
httr::authenticate("media", "media"),
url = NULL
)
dc_df <- httr::content(r) |>
XML::xmlParse() |>
XML::xmlToDataFrame()
rm(h)
return(dc_df)
}
build_dc <-
function(season = nflreadr:::most_recent_season(roster = T)) {
cli::cli_alert_info("Scraping teams...")
teams <- purrr::map_dfr(season, scrape_teams) |>
dplyr::filter(!(ClubCode %in% c("AFC", "NFC", "RIC", "SAN", "CRT", "IRV"))) |>
# remove all-star teams
dplyr::mutate(Season = as.integer(Season)) |>
dplyr::select(club_code = ClubCode, season = Season) |>
tidyr::expand_grid(season_type = c("REG", "POST"))
cli::cli_alert_info("Scraping depth charts...")
progressr::with_progress({
p <- progressr::progressor(steps = nrow(teams))
dc_df <-
purrr::pmap_dfr(list(teams$season, teams$club_code, teams$season_type),
\(x, y, z) {
df <- scrape_dc(x, y, z)
p()
return(df)
})
})
if (nrow(dc_df)) {
dc_df <- dc_df |>
dplyr::mutate(
ClubCode = dplyr::case_when(
ClubCode == "ARZ" ~ "ARI",
ClubCode == "BLT" ~ "BAL",
ClubCode == "CLV" ~ "CLE",
ClubCode == "HST" ~ "HOU",
ClubCode == "SL" ~ "STL",
T ~ ClubCode
),
full_name = paste(FootballName, LastName),
Season = as.numeric(Season),
Week = as.numeric(Week),
) |>
janitor::clean_names() |>
dplyr::rename(game_type = season_type) |>
dplyr::group_by(season) |>
dplyr::mutate(
game_type = dplyr::case_when(
game_type == "POST" & week == 1 ~ "WC",
game_type == "POST" &
week == 2 ~ "DIV",
game_type == "POST" &
week == 3 ~ "CON",
game_type == "POST" &
week == 4 ~ "SB",
T ~ game_type
),
week = dplyr::case_when(
game_type %in% c("WC", "DIV", "CON", "SB") ~ week + max(week[game_type == "REG"]),
T ~ week
),
) |>
dplyr::ungroup()
cli::cli_alert_info("Save depth charts...")
nflversedata::nflverse_save(
data_frame = dc_df,
file_name = glue::glue("depth_charts_{season}"),
nflverse_type = "depth charts",
release_tag = "depth_charts"
)
}
}
# purrr::walk(2001:2022, build_dc)
build_dc()
|
8fce9518157facc8b8cb2fa04788ecf6245b02ec
|
c15c4062d360fd5f18e4718097352391e8439b90
|
/Scripts/Env_variables/env.nc_to_csv.R
|
abade36ac4e3ab02da8c4c8f38150d153f30c382
|
[] |
no_license
|
EveTC/Pararge_aegeria_morphometrics
|
f2292737c57aaf8f0aa685ad7f776f7e09c27184
|
78b1f79dd8c9d9c4b155762b451feb8043eee58a
|
refs/heads/master
| 2023-06-20T10:57:59.580931
| 2021-07-19T09:52:38
| 2021-07-19T09:52:38
| 262,007,077
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 55,143
|
r
|
env.nc_to_csv.R
|
### Bring in environmental variables as .nc files and make to csv
## Environmental dataset: HadUK-Grid Gridded Climate Observations on a 1km grid over the UK
### N.B. I can not directly porovide the environmental data. It is available through the CEDA archives and the Met office (for 2018 temp data).
## Follows http://geog.uoregon.edu/bartlein/courses/geog490/week04-netCDF.html
#### 1. Set up ####
# clear R environment
#rm(list=ls())
# install required libraries
#install.packages("RCurl")
#install.packages("readr")
# install and load packages
#install.packages("chron")
#install.packages("ncdf.tools")
#install.packages("ncdf")
# Load libraries required
library(RCurl)
library(readr)
library(raster)
library(ncdf4)
library(ncdf)
library(chron)
library(lattice)
library(RColorBrewer)
library(ncdf.tools)
#### 2. Mean Monthly air temp 2018 ####
ncpath <- "./Data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201801-201812"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname, write=T)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname) # This should be a matrix with all NAs
# Change missing value - as this is not present in the file for 2018.
# Find out what missing value is in many decimals
sprintf("%.100f", tmp_array[1,1,1])
# Set missing value
Mvalue <- 9.969209968386869047442886268468442020e+36
# change missing value in nc file
ncvar_change_missval(ncin, dname, Mvalue)
print(ncin)
# now when we call tmp_array these numbers should be replaced with NA
tmp_array <- ncvar_get(ncin,dname)
# correct
# continue as normal
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2017
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==Mvalue] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
colMeans(x=tmp_df_All, na.rm=T)
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201801-201812"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Mean air temperature 2017 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201701-201712"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
fillvalue
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2017
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201701-201712"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2016 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201601-201612"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
length(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
length(na.omit(tmp_df_All))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201601-201612"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2015 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201501-201512"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201501-201512"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2014 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201401-201412"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201401-201412"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2013 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201301-201312"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201301-201312"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2012 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201201-201212"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201201-201212"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2011 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201101-201112"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201101-201112"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2010 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_201001-201012"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_201001-201012"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2009 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_200901-200912"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_200901-200912"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2008 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_200801-200812"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_200801-200812"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2007 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_200701-200712"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
length(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
length(na.omit(tmp_df_All))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_200701-200712"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2006 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_200601-200612"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname, write=T)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname) # this should be all NAs
# its not! There is no missing value number
# Find out what missing value is in many decimals
sprintf("%.100f", tmp_array[1,1,1])
# Set missing value
Mvalue <- 9969209968386869047442886268468442020
# change missing value in nc file
ncvar_change_missval(ncin, dname, Mvalue)
print(ncin) # missing value has been inserted
# reload and it should work
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
length(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
length(na.omit(tmp_df_All))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_200601-200612"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temp 2005 ####
ncpath <- "./data/UKCP18/Mean_air_temperature_(tas)/.nc_files/"
ncname <- "tas_hadukgrid_uk_1km_mon_200501-200512"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname, write=T)
print(ncin)
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname) # this should be all NAs
# its not! There is no missing value number
# Find out what missing value is in many decimals
sprintf("%.100f", tmp_array[1,1,1])
# Set missing value
Mvalue <- 9969209968386869047442886268468442020
# change missing value in nc file
ncvar_change_missval(ncin, dname, Mvalue)
print(ncin) # missing value has been inserted
# reload and it should work
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
#tustr <- strsplit(tunits$value, " ")
#tdstr <- strsplit(unlist(tustr)[3], "-")
#tmonth <- as.integer(unlist(tdstr)[2])
#tday <- as.integer(unlist(tdstr)[3])
#tyear <- as.integer(unlist(tdstr)[1])
#chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2016
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
#Jan <- 1
#tmp_slice <- tmp_array[,,Jan]
#dim(tmp_slice)
# plot Jan Temps
#image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
#grid <- expand.grid(lon=lon, lat=lat)
#cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
#levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
# col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
#lonlat <- as.matrix(expand.grid(lon,lat))
#dim(lonlat)
#tmp_vec <- as.vector(tmp_slice)
#length(tmp_vec)
#tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
#names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
#head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
length(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun",
"tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
length(na.omit(tmp_df_All))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/Mean_air_temperature_(tas)/"
csvname <- "tas_hadukgrid_uk_1km_mon_200501-200512"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
#### Temperature 20yrs monthly average ####
ncpath <- "./data/UKCP18/long-term/"
ncname <- "tas_hadukgrid_uk_1km_mon-20y_198101-200012"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
dname <- "tas"
ncin <- nc_open(ncfname)
print(ncin)
# get corodinate including time variables
# get corodinate including time variables
lon <- ncvar_get(ncin,"projection_x_coordinate")
nlon <- dim(lon)
head(lon)
lat <- ncvar_get(ncin, "projection_y_coordinate")
nlat <- dim(lat)
head(lat)
print(c(nlon,nlat))
# get time
time <- ncvar_get(ncin, "time")
time
tunits <- ncatt_get(ncin, "time", "units")
nt <- dim(time)
nt
tunits
## get temperature variable and its attributes
tmp_array <- ncvar_get(ncin,dname)
dlname <- ncatt_get(ncin,dname,"long_name")
dunits <- ncatt_get(ncin,dname,"untis")
fillvalue <- ncatt_get(ncin,dname,"_FillValue")
dim(tmp_array)
# get global attributes
title <- ncatt_get(ncin,0,"title")
short_name <- ncatt_get(ncin,0,"short_name")
collection <- ncatt_get(ncin,0,"collection")
comment <- ncatt_get(ncin,0,"comment")
institution <- ncatt_get(ncin,0,"institution")
datasource <- ncatt_get(ncin,0,"source")
references <- ncatt_get(ncin,0,"references")
Conventions <- ncatt_get(ncin,0,"Conventions")
# close file
ncdf4::nc_close(ncin)
## Reshape from raster to rectangular
# Convert time variable
tustr <- strsplit(tunits$value, " ")
tdstr <- strsplit(unlist(tustr)[3], "-")
tmonth <- as.integer(unlist(tdstr)[2])
tday <- as.integer(unlist(tdstr)[3])
tyear <- as.integer(unlist(tdstr)[1])
chron(time, origin=c(tday,tmonth,tyear)) # should they not all be 2017?
# another method
convertDateNcdf2R(time, units = "hours") # confirmed that all points are from year 2017
## Replace netCDF fillvalues with R NAs
tmp_array[tmp_array==fillvalue$value] <- NA
length(na.omit(as.vector(tmp_array[,,1])))
## Get a single slice of data
Jan <- 1
tmp_slice <- tmp_array[,,Jan]
dim(tmp_slice)
# plot Jan Temps
image(lon,lat,tmp_slice, col=rev(brewer.pal(10,"RdBu")))
# alt plot
grid <- expand.grid(lon=lon, lat=lat)
cutpts <- c(-5,0,1,2,3,4,5,6,7,8,9,10)
levelplot(tmp_slice ~ lon * lat, data=grid, at=cutpts, cuts=11, pretty=T,
col.regions=(rev(brewer.pal(10,"RdBu"))))
## Create dataframe
lonlat <- as.matrix(expand.grid(lon,lat))
dim(lonlat)
tmp_vec <- as.vector(tmp_slice)
length(tmp_vec)
tmp_df01<- data.frame(cbind(lonlat,tmp_vec))
names(tmp_df01) <- c("lon", "lat", paste(dname, as.character(Jan), sep="_"))
head(na.omit(tmp_df01), 10)
### Convert whole array
tmp_vec_long <- as.vector(tmp_array)
length(tmp_vec_long)
tmp_mat <- matrix(tmp_vec_long, nrow=nlon*nlat, ncol=nt)
dim(tmp_mat)
head(na.omit(tmp_mat))
lonlat <- as.matrix(expand.grid(lon,lat))
tmp_df_All <- data.frame(cbind(lonlat,tmp_mat))
names(tmp_df_All) <- c("lon", "lat", "tmpJan", "tmpFeb","tmpMar","tmpApr","tmpMay","tmpJun", "tmpJul","tmpAug","tmpSep","tmpOct","tmpNov","tmpDec")
head(na.omit(tmp_df_All, 20))
### Calculate 1) annual mean temp; 2) MTWA - Mean temp of warmest month; and 3) MTCO - mean temp of coldest month
tmp_df_All$mtwa <- apply(tmp_df_All[3:14],1,max) # mtwa
tmp_df_All$mtco <- apply(tmp_df_All[3:14],1,min) # mtco
tmp_df_All$mat <- apply(tmp_df_All[3:14],1,mean) # annual (i.e. row) means
head(na.omit(tmp_df_All))
## data to csv
# read out dataframe to csv
csvpath <- "./data/UKCP18/long-term/"
csvname <- "tas_hadukgrid_uk_1km_mon_201701-201712"
csvfile <- paste(csvpath, csvname,".csv", sep="")
write.table(na.omit(tmp_df_All), csvfile, row.names = FALSE, sep = ",")
|
a71acb7de50877519ebcacc8c87bb8ec32432c73
|
4db6edaf2be0fe5ce5a8932e71a39954dc73cc7e
|
/scripts/00_Main.R
|
fc3056da2e0733b18168ad7ccfe3bdfc2150b0ec
|
[] |
no_license
|
RSGInc/cmap_freight_model
|
60999aced8db8df55002f5deab900d786615bd9b
|
aea542c286cbece5a18fc2d5a7bb277c80d39afa
|
refs/heads/master
| 2021-01-20T14:01:58.429355
| 2017-07-28T19:12:29
| 2017-07-28T19:12:29
| 82,729,904
| 0
| 0
| null | 2017-02-21T21:39:50
| 2017-02-21T21:39:49
| null |
UTF-8
|
R
| false
| false
| 10,260
|
r
|
00_Main.R
|
##############################################################################################
#Title: CMAP Agent Based Freight Forecasting Code
#Project: CMAP Agent-based economics extension to the meso-scale freight model
#Description: 00_Main.R controls the model flow and sources in other scripts to run
# components of the model. The code as whole implements the national supply
# chain freight framework, which is based on earlier work for FHWA carried
# out by RSG
#Date: January 28, 2014
#Author: Resource Systems Group, Inc.
#Copyright: Copyright 2014 RSG, Inc. - All rights reserved.
##############################################################################################
#---------------------------------------------------------------------
#Define Model/Scenario Control Variables/Inputs/Packages/Steps
#---------------------------------------------------------------------
#1.Set the base directory (the directory in which the model resides)
if (!exists("scenario")) {
library(envDocument)
scriptpath <- envDocument::get_scriptpath()
#print(paste("envDocument::get_scriptpath():", envDocument::get_scriptpath()))
if (length(scriptpath) < 2) {
#How to get script directory: http://stackoverflow.com/a/30306616/283973
scriptDir <- getSrcDirectory(function(x)
x)
if (length(scriptDir) < 2) {
scriptDir <- getwd()
#print(paste("getwd():", getwd()))
if (!file.exists("cmap_freight_model.Rproj"))
stop(
paste0(
"Can not find path of script and the working directory '",
scriptDir,
"' does not appear to be the project root!"
)
)
}
basedir <- scriptDir
} else {
scriptdir <- dirname(scriptpath)
basedir <-
dirname(scriptdir) #basedir is the root of the github repo -- one above the scripts directory
}
print(paste0("basedir: ", basedir))
} #end if baseDir not already set
#there is code, such as source statments that assume the working directory is set to base
setwd(basedir)
#2. Set the scenario to run -- same as the folder name inside the scenarios directory
if (!exists("scenario")) {
scenario <- "base"
}
#3. Run the model
#rFreight install zip should be in directory within model
if (!dir.exists("./library")) {
dir.create("./library")
}
install.packages(file.path(basedir, "rFreight_0.1.zip"),
repos = NULL,
lib = "./library/")
library(rFreight, lib.loc = "./library/")
#define the components that comprise the model: name, titles, scripts
steps <-
c(
"firmsyn",
"pmg",
"pmgcon",
"pmgout",
"daysamp",
"whouse",
"vehtour",
"stopseq",
"stopdur",
"tourtod",
"preptt"
)
steptitles <-
c(
"Firm Synthesis",
"Procurement Market Games",
"PMG Controller",
"PMG Outputs",
"Daily Sample",
"Warehouse Allocations",
"Vehicle Choice and Tour Pattern",
"Stop Sequence",
"Stop Duration",
"Time of Day",
"Prepare Trip Table"
)
stepscripts <-
c(
"01_Firm_Synthesis.R",
"02_Procurement_Markets.R",
"03_PMG_Controller.R",
"04_PMG_Outputs.R",
"05_Daily_Sample.R",
"06_Warehouse_Allocation_CMAP.R",
"07_Vehicle_Choice_Tour_Pattern_CMAP.R",
"08_Stop_Sequence_CMAP.R",
"09_Stop_Duration.R",
"10_Time_of_Day.R",
"11_Prepare_Trip_Table_CMAP.R"
)
#create the model list to hold that information, load packages, make model step lists
model <- startModel(
basedir = basedir,
scenarioname = scenario,
packages = c(
"data.table",
"bit64",
"reshape",
"reshape2",
"fastcluster"
),
steps = steps,
steptitles = steptitles,
stepscripts = stepscripts
)
rm(basedir, scenario, steps, steptitles, stepscripts)
#Load file paths to model inputs, outputs, and workspaces
source("./scripts/00_File_Locations.R")
print(paste0("maxrscriptinstances: ", model$scenvars$maxrscriptinstances))
#-----------------------------------------------------------------------------------
#Run model steps
#-----------------------------------------------------------------------------------
progressManager(
"Start",
model$logs$Step_RunTimes,
model$scenvars$outputlog,
model$logs$Main_Log,
model$scenvars$outputprofile,
model$logs$Profile_Log,
model$logs$Profile_Summary
)
# split this out to run steps seperately more easily
# functionalize the step 3 stuff to allow just certain markets to run
# change 03_PMG_Controller.R to using parallel instead of tasklist approach
#lapply(model$stepscripts,source)
isPeterDevelopmentMode <-
dir.exists(model$outputdir) &&
(length(list.files(model$outputdir)) > 10) &&
interactive() &&
(Sys.info()[["user"]] == "peter.andrews")
if(!model$scenvars$runSensitivityAnalysis) {
if (isPeterDevelopmentMode && exists("ineligible")) {
print("NOTICE -- skipping steps 1 & 2 because in isPeterDevelopmentMode")
} else {
source(model$stepscripts[1]) #Firm Synthesis
source(model$stepscripts[2]) #Prepare Procurement Markets
}
source(model$stepscripts[3]) #PMG Controller (running the PMGs)
source(model$stepscripts[4]) #PMG Outputs (creating pairs.Rdata)
if (isPeterDevelopmentMode) {
print("NOTICE -- skipping steps 5:11 because in isPeterDevelopmentMode")
} else {
for (scriptNumber in 5:11) {
source(model$stepscripts[scriptNumber]) #Truck Touring Model
}
}
save(
list = c("model", model$steps),
file = file.path(model$outputdir, "modellists.Rdata")
)
progressManager(
"Stop",
model$logs$Step_RunTimes,
model$scenvars$outputlog,
model$logs$Main_Log,
model$scenvars$outputprofile,
model$logs$Profile_Log,
model$logs$Profile_Summary
)
} else {
# First change the functions from rFreight package
# loadInputs2 <- function(filelist, inputdir) {
# if (length(filelist) > 0) {
# for (i in 1:length(filelist)) {
# if (!exists(names(filelist)[i]))
# assign(names(filelist)[i], fread(file.path(inputdir, filelist[[i]])), envir = .GlobalEnv)
# }
# }
# }
# environment(loadInputs2) <- environment(loadInputs)
# assignInNamespace("loadInputs",loadInputs2,ns = "rFreight")
# Running Sensitivity Analysis
source(model$stepscripts[1]) #Firm Synthesis
modeCategories <- fread("./DashBoard/mode_description.csv", stringsAsFactors = FALSE)
setkey(modeCategories, ModeNumber)
mesoFAFCBPMap <- fread('./DashBoard/meso_faf_map.csv')
setkey(mesoFAFCBPMap,"MESOZONE")
source(file = file.path(model$basedir,"scenarios","base","sensitivity","design","sensitivity_variables.R"))
sensitivity_environment <- new.env()
allPC <- data.table()
endPMG <- FALSE # To make sure the progressEnd in Procurement Script doesn't run until the entire run is done.
if(!dir.exists(file.path(model$outputdir,"parametersOutput"))) dir.create(file.path(model$outputdir,"parametersOutput")) # Create the directory to save output.
if(model$scenvars$runParameters){
for(choice in exp_design[,Choice]){
model$parameterdir <- file.path(model$outputdir,"parametersOutput")
model$parameterdesign <- choice
B0 <- exp_design[choice,as.numeric(B0)]
B1 <- exp_design[choice,as.numeric(B1)]
B2_mult <- exp_design[choice,as.numeric(B2)]
B3_mult <- exp_design[choice,as.numeric(B3)]
B4 <- exp_design[choice,as.numeric(B4)]
B5_mult <- exp_design[choice,as.numeric(B5)]
if(choice==nrow(exp_design)) endPMG <- TRUE
source(model$stepscripts[2]) #Prepare Procurement Markets
source(model$stepscripts[3]) #PMG Controller (running the PMGs)
# allPC <- rbind(allPC,get("pc",envir = sensitivity_environment))
}
} else {
if(!dir.exists(file.path(model$outputdir,"skimsoutput"))) dir.create(file.path(model$outputdir,"skimsoutput"))
model$sensitivitydir <- file.path(model$basedir,"scenarios","base","sensitivity","skims")
skimsChoicedirs <- list.dirs(model$sensitivitydir,recursive = FALSE)
pmg$inputs[["skims"]] <- NULL
limitruns <- length(skimsChoicedirs)
for(choice in skimsChoicedirs[1:limitruns]){
print(choice)
model$skimsdir <- choice
if(choice==skimsChoicedirs[limitruns]) endPMG <- TRUE
source(model$stepscripts[2]) #Prepare Procurement Markets
source(model$stepscripts[3]) #PMG Controller (running the PMGs)
# allPC <- rbind(allPC,get("pc",envir = sensitivity_environment))
}
readData <- function(loc){
filelist <- list.files(loc,recursive = FALSE,full.names = TRUE)
return(rbindlist(lapply(filelist,function(x) get(load(x)))))
}
outputLocation <- file.path(model$outputdir,"skimsoutput",basename(skimsChoicedirs))
allPC <- data.table(rbindlist(lapply(outputLocation[1:limitruns],readData)))
saveRDS(allPC,file = file.path(model$outputdir,"skimsoutput","sensitivityrun1.rds"))
# run skims here
}
# rsgcolordf <- data.frame(red=c(246,0,99,186,117,255,82), green=c(139,111,175,18,190,194,77), blue=c(31,161,94,34,233,14,133), colornames=c("orange","marine","leaf","cherry","sky","sunshine","violet"))
#
# rsgcolordf <- rsgcolordf %>% mutate(hexValue=rgb(red,green,blue,maxColorValue=255))
#
# makeMoreColors <- colorRampPalette(rsgcolordf$hexValue)
# modeColors <- data.table(mode=c("Truck","Rail","Water","Air","Multiple","Pipeline","Other","None"),colors=makeMoreColors(8),stringsAsFactors = FALSE,key = "mode")
# modeColors2 <- makeMoreColors(8)
# names(modeColors2) <- c("Truck","Rail","Water","Air","Multiple","Pipeline","Other","None")
#
# allPC %>% ggplot(aes(x=Distance_Bin))+geom_bar(aes(fill=Mode),position = "fill")+theme_bw()+facet_grid(Commodity_SCTG~B0)+scale_fill_manual("Mode",values = makeMoreColors(6))+scale_x_continuous(breaks = seq(0,75,10),labels = label_distance)+xlab("Distance")
# saveRDS(allPC,file = file.path(model$outputdir,"sensitivityrun1.rds"))
}
|
10492fb098f22e7c1aedd90fa42930958df15627
|
6e0e38fc926c0d51340903674fb2d0d08eccdd9c
|
/src/tab_table1.R
|
cc1ebb10b829c129830620b735fab58daab30dd9
|
[] |
no_license
|
eribul/NH_luxation_infektion
|
a512f0039f2c50cbdd93d2ea9d9931f0cf3ef217
|
4370ef63748fbb59d80880ebd69254f8e45c8f89
|
refs/heads/master
| 2023-04-16T17:26:38.085338
| 2022-01-28T17:39:31
| 2022-01-28T17:39:31
| 259,828,410
| 0
| 0
| null | 2022-01-28T17:38:35
| 2020-04-29T04:58:49
|
HTML
|
ISO-8859-1
|
R
| false
| false
| 5,363
|
r
|
tab_table1.R
|
suppressMessages({library(ProjectTemplate); load.project()})
load("cache/df.RData")
dft1 <-
df %>%
mutate(
Charlson = replace(CCI_index_quan_original, CCI_index_quan_original > 1, "2+"),
Elixhauser = replace(ECI_index_sum_all, ECI_index_sum_all > 2, "3+"),
RxRiskV = cut(Rx_index_pratt, c(-Inf, 0, 3, 6, Inf), c("-5-0", "1-3", "4-6", "7+")),
P_BMI = relevel(P_BMI, "under/normal weight"),
P_Age = cut(P_Age, c(0, 49, 59, 69, 79, Inf), c("<50", "50-<60", "60-<70", "70-<80", "80+"))
) %>%
select(
PJI = outcome,
P_Age,
P_Sex,
P_BMI,
P_ASA,
P_DiaGrp,
cemented_stem,
cemented_cup,
P_TypeOfHospital,
education,
civil_status,
Charlson,
Elixhauser,
RxRiskV,
starts_with("c_"),
) %>%
setNames(gsub(": ", "", clean_names(names(.))))
t1 <-
tableone::CreateTableOne(
strata = "PJI",
vars = setdiff(names(dft1), "PJI"),
data = dft1,
test = FALSE
) %>% print(
printToggle = FALSE,
showAllLevels = TRUE
) %>%
as_tibble(rownames = "what") %>%
rename(
`SE PJI` = `TRUE`,
`SE No PJI` = `FALSE`
) %>%
mutate(
what = na_if(what, ""),
what = zoo::na.locf(what),
what = gsub(":? \\(%\\)", "", what)
)
t1_tot <-
tableone::CreateTableOne(
vars = setdiff(names(dft1), "PJI"),
data = dft1,
test = FALSE,
) %>%
print(
printToggle = FALSE,
showAllLevels = TRUE
) %>%
as_tibble(rownames = "what") %>%
rename(`SE Total` = Overall) %>%
mutate(
what = na_if(what, ""),
what = zoo::na.locf(what),
what = gsub(":? \\(%\\)", "", what)
)
se_table1 <-
left_join(
t1,
t1_tot
) %>%
filter(level != "FALSE") %>%
mutate_at(vars(-what, -level), zero) %>%
select(
what,
level,
`SE PJI`,
`SE No PJI`,
`SE Total`
) %>%
mutate(
what = case_when(
what == "n" ~ "Total",
what == "AIDS/HIV hiv" ~ "AIDS/HIV",
what == "Heart infarct" ~ "Myocardial infarction",
what == "Peptiulcer" ~ "Peptic ulcer",
what == "Rheumatidisease" ~ "Rheumatic disease",
TRUE ~ what
),
level = tolower(level),
level = na_if(level, ""),
level = na_if(level, "true")
)
# DK table ----------------------------------------------------------------
dk1 <-
docxtractr::read_docx("validation/DK_table1_20210325.docx") %>%
docxtractr::docx_extract_tbl()
names(dk1) <- c("what", "No_PJI_N", "No_PJI_prop", "PJI_N", "PJI_prop", "Tot_N", "Tot_prop")
dk1 <- dk1[-(1:2), ] # Remove headers and age (which should not be categorized)
dk1 <- mutate(dk1, across(-what, as.numeric))
# Identifiera namn på faktorer till skillnad från levels
dk1$factors <- dk1$what %in% dk1$what[which(is.na(dk1$Tot_N)) -1]
# Save empty row for Elixhauser == 0
elix0 <- filter(dk1, what == "0") %>% slice(1)
dk2 <-
dk1 %>%
distinct() %>%
# 0-raden för Elixhauser försvinner och behöver läggas tillbaka
add_row(elix0, .after = which(.$what == "Elixhauser")[1]) %>%
# FLytta ner icke-NA-värden till resp level
mutate(across(c(-what, -factors), zoo::na.locf)) %>%
# Ta bort värdena från faktor-rubriken
mutate(across(c(-what, -factors), ~ replace(., factors, NA))) %>%
# Ta bort de värden som inte fanns från början
mutate(across(c(-what, -factors, -Tot_N, -Tot_prop),
~ replace(., what %in% c("Sequelae after childhood hip disease",
"Inflammatory joint disease"), NA))) %>%
mutate(
level = replace(what, factors, NA),
what = replace(what, !factors & what != "Total", NA),
what = zoo::na.locf(what)
) %>%
filter(
level != "No",
what != "Region"
)
# Slå samman civilstånd "." och "divorced till single
sing <-
dk2 %>%
filter(level %in% c(".", "Divorced")) %>%
select(-level) %>%
group_by(what, factors) %>%
summarise(across(everything(), sum)) %>%
mutate(level = "Single")
dk2 <-
dk2 %>%
filter(!level %in% c(".", "Divorced")) %>%
bind_rows(sing) %>%
transmute(
what,
level,
`DK PJI` = sprintf("%d (%.1f)", PJI_N, PJI_prop),
`DK No PJI` = sprintf("%d (%.1f)", No_PJI_N, No_PJI_prop),
`DK Total` = sprintf("%d (%.1f)", Tot_N, Tot_prop)
) %>%
mutate(
what = case_when(
what == "Rx index" ~ "RxRiskV",
what == "Fluid electolyte disorders" ~ "Fluid electrolyte disorders",
TRUE ~ what
),
level = gsub("Widow", "Widow/widower", level),
level = tolower(level),
level = na_if(level, "yes"),
level = na_if(level, "total")
)
# Slå samman --------------------------------------------------------------
# Check that no levels differ
setdiff(se_table1$what, dk2$what)
setdiff(se_table1$level, dk2$level)
setdiff(dk2$what, se_table1$what)
setdiff(dk2$level, se_table1$level)
table1 <-
left_join(se_table1, dk2) %>%
mutate(
level = ifelse(level %in% c("i", "ii", "iii"), toupper(level), level),
) %>%
mutate(across(everything(), na_if, "NA (NA)")) %>%
mutate(across(c(`DK PJI`, `DK No PJI`, `DK Total`),
~ ifelse(what == "Total", sub("\\(100.0\\)", "", .), .)
))
cache("table1")
|
d67e614ff6bb4e70c79d6983072c3ad12f116c60
|
ac5cf1135044426715a39d041348afd25c68d585
|
/Code/Sandbox_fishtree.R
|
c4b5ae7c2a189ddaee9fd78b70f3eb2efe2b4f05
|
[] |
no_license
|
OScott19/ResearchProject
|
a173773130ed4c3ae151530691a514b96ac692c2
|
7f39f7202ee0643985d9b239309033a3e4f3c41d
|
refs/heads/master
| 2022-11-11T20:09:06.123108
| 2020-06-26T14:52:36
| 2020-06-26T14:52:36
| 234,543,392
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 108
|
r
|
Sandbox_fishtree.R
|
anewtree <- read.tree(file = "../../../Downloads/fish_trees", fill = T,
quote = "")
|
40fcc17dee8c558fe453fabc1d0e14bd1d828fe7
|
45b9583d47dfcca8cd18875a1d24480e7443c0b4
|
/examples/demo-html.R
|
044e88d20689bae07b13d5b06896a833d6cf475c
|
[] |
no_license
|
araastat/BIOF439Online
|
a0ab26503781eb5c3b7b1b9905ab08bb21dac891
|
290b43bcff1c5a87f8c6285025bf5a4d6c410cb5
|
refs/heads/master
| 2022-11-15T02:43:38.550469
| 2020-07-15T09:02:45
| 2020-07-15T09:02:45
| 274,275,185
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,293
|
r
|
demo-html.R
|
## exams ----------------------------------------------------------------------------
## load package
library("exams")
## exam with a simple vector of exercises in R/Markdown (.Rmd) format
## -> alternatively try a list of vectors of more exercises
myexam <- c("boxplots.Rmd")
## exams2html -----------------------------------------------------------------------
## HTML output (1 file per exam)
## -> typically used for quickly checking if an exercise can be converted to HTML
## -> or customized via suitable templates
## generate the HTML version of a single exercise (shown in browser)
## with default settings, using MathML
exams2html("exercises/boxplots.Rmd")
## using MathJax (works in all browsers, including Chrome)
exams2html("exercises/boxplots.Rmd", converter = "pandoc-mathjax")
## generate a single HTML exam (shown in browser)
## with specification of a template (the default) %s encoding
exams2html(myexam, n = 1,
edir = "exercises",
template = "templates/plain.html")
## generate three HTML exams without solutions in output directory
exams2html(myexam, n = 3, name = "html-demo", solution = FALSE,
dir = "output",
edir = "exercises",
template = "templates/plain.html")
## ----------------------------------------------------------------------------------
|
6def559c67b5e5fe9c3e10d6457eb6d1382256d3
|
c3d2fb0a02e5eabbd0234860186f246651c9fb39
|
/R/Economics/unemploy-fx-match-r3.r
|
e152e95dd2a9ab2b242c9a87199f2fabf6425198
|
[] |
no_license
|
ppbppb001/Snippets
|
09216417c52af40c947114bc106aee97776674f7
|
49e254eecd55f5e777d87c3f06c720cb881fb2dd
|
refs/heads/master
| 2023-08-14T08:16:07.814866
| 2023-08-07T11:57:15
| 2023-08-07T11:57:15
| 93,360,154
| 0
| 1
| null | null | null | null |
UTF-8
|
R
| false
| false
| 10,107
|
r
|
unemploy-fx-match-r3.r
|
#-------------------------------------------
# <unemploy-fx-match-r3.r>
# Improve the target table with
# unemployment and FX data colmum
# date matcing
#
# [2017-06-14] - New calculation added
#--------------------------------------------
# Key Constants: ........................
lookup.dateformat <- "%d-%b-%y" # date format string for lookup, like'20-May-16'
target.dateformat <- "%Y-%m-%d" # target date format: '2016-05-20'
# target.dateformat <- "%d-%b-%Y" # target date format: '20-May-2016'
# target.dateformat <- "%d-%b-%y" # target date format: '20-May-16'
# target.dateformat <- "%b %d, %Y" # target date format: 'May 20, 2016'
# target.dateformat <- "%b %d, %y" # target date format: 'May 20, 16'
# target.dateformat <- "%d/%m/%Y" # target date format: '20/5/2016'
#
# column name of 'lookup.dfnew'
cn.k.date <- "Date"
cn.k.ue <- "Unemployment.Rate"
cn.k.uea <- "Unemployment.Rate.Annual"
cn.k.uek1 <- "Unemployment.K1" # 'Unemployment.K1' = Value.Year(i-1) - Value.Year(i-2)
cn.k.uek2 <- "Unemployment.K2" # 'Unemployment.K2' = K1/Value.Year(i-2)
cn.k.uek3 <- "Unemployment.K3" # 'Unemployment.K3' = K2*(Value.Year(i-1) - 0.05)
cn.k.datefx <- "Date.FX"
cn.k.aud <- "AUDUSD"
cn.k.auda <- "AUDUSD.Annual"
cn.k.audk1 <- "AUDUSD.K1" # 'AUDUSD.K1' = Value.Year(i-1) - Value.Year(i-2)
cn.k.audk2 <- "AUDUSD.K2" # 'AUDUSD.K2' = K1/Value.Year(i-2)
cn.k.audk3 <- "AUDUSD.K3" # 'AUDUSD.K3' = K2*(Value.Year(i-1) - 0.5)
# column name of 'target.dfnew'
cn.t.date <- "Date"
cn.t.x <- "X" # the simulation of another data series
cn.t.ue <- "Unemployment.Rate"
cn.t.uea <- "Unemployment.Rate.Annual"
cn.t.uek1 <- "Unemployment.K1"
cn.t.uek2 <- "Unemployment.K2"
cn.t.uek3 <- "Unemployment.K3"
cn.t.aud <- "AUDUSD"
cn.t.auda <- "AUDUSD.Annual"
cn.t.audk1 <- "AUDUSD.K1"
cn.t.audk2 <- "AUDUSD.K2"
cn.t.audk3 <- "AUDUSD.K3"
# Load unemployment and Fx historical data: ..................
lookup.df <- read.csv("aus-unemploy-fx.csv", stringsAsFactors = FALSE)
lookup.rows <- dim(lookup.df)[1]
# Make a new lookup dataframe with 2 extra columns for annual values:
lookup.dfnew <- data.frame(Date = lookup.df[,"Date"], # Date (mm-yy)
Unemployment.Rate = lookup.df[,"Unemployment.Rate"], # Unemployment.Rate
Unemployment.Rate.Annual = rep(NA, lookup.rows), # Unemployment.Rate.Annual
Unemployment.K1 = rep(NA, lookup.rows), # Unemployment.K1
Unemployment.K2 = rep(NA, lookup.rows), # Unemployment.K2
Unemployment.K3 = rep(NA, lookup.rows), # Unemployment.K3
Date.FX = lookup.df[,"Date.FX"], # Date.FX (dd-mm-yy)
AUDUSD = lookup.df[,"AUDUSD"], # AUDUSD
AUDUSD.Annual = rep(NA, lookup.rows), # AUDUSD.Annual
AUDUSD.K1 = rep(NA, lookup.rows), # AUDUSD.K1
AUDUSD.K2 = rep(NA, lookup.rows), # AUDUSD.K2
AUDUSD.K3 = rep(NA, lookup.rows), # AUDUSD.K3
stringsAsFactors = FALSE) # No factors for string type
# Calculate and Fill up 'lookup.dfnew':
# K1/K2/K3 calculated and assigned to lookup table
lookup.datefx <- strptime(lookup.df[,"Date.FX"], lookup.dateformat)
ue.annual <- NULL # save annual value of unemployment
aud.annual <- NULL # save annual value of AUD
lastyear <- 0
for (i in seq(lookup.rows)) {
if (lastyear != lookup.datefx[i]$year){
lastyear <- lookup.datefx[i]$year
ixs <- which(lookup.datefx$year == lastyear) # Indices of matched items
xmean.ue <- mean(lookup.dfnew[ixs, cn.k.ue])
lookup.dfnew[ixs, cn.k.uea] <- xmean.ue # Annual mean of Unemployment.Rate
xmean.aud <- mean(lookup.dfnew[ixs, cn.k.aud])
lookup.dfnew[ixs, cn.k.auda] <- xmean.aud # Annual mean of AUDUSD
ue.annual <- c(ue.annual, xmean.ue) # Append annual value
aud.annual <- c(aud.annual, xmean.aud) # Append annual value
# Unemploymeny.K1/K2/K3:
lx <- length(ue.annual)
if (lx >= 3) {
# Calculate Unemployment.K1/K2/K3
k1 <- ue.annual[lx-1] - ue.annual[lx-2]
k2 <- k1 / ue.annual[lx-2]
k3 <- k2 * (ue.annual[lx-1] - 0.05)
# Assign Unemployment.K1/K2/K3
lookup.dfnew[ixs, cn.k.uek1] <- k1
lookup.dfnew[ixs, cn.k.uek2] <- k2
lookup.dfnew[ixs, cn.k.uek3] <- k3
}
# AUDUSD.K1/K2/K3:
lx <- length(aud.annual)
if (lx >= 3) {
# Calculate AUDUSD.K1/K2/K3
k1 <- aud.annual[lx-1] - aud.annual[lx-2]
k2 <- k1 / aud.annual[lx-2]
k3 <- k2 * (aud.annual[lx-1] - 0.5)
# Assign AUDUSD.K1/K2/K3
lookup.dfnew[ixs, cn.k.audk1] <- k1
lookup.dfnew[ixs, cn.k.audk2] <- k2
lookup.dfnew[ixs, cn.k.audk3] <- k3
}
}
}
# Make pseudo target table to be improved: ...................
# *** THE AFTER MAY BE MASKED OFF ***
target.rows <- 10000 # rows of pseudo target data frame
# Make pseudo X data series:
target.colx <- sample(100, target.rows, replace = TRUE) # colx of target is for nothing
# Make pseudo date series
xyears <- sample(2010:2016, target.rows, replace = TRUE) # random years: 2010~2016
xmonths <- sample(1:12, target.rows, replace = TRUE) # random months: 1~12
xdays <- sample(1:28, target.rows, replace = TRUE) # random days: 1~28
xdatestr <- paste(as.character(xyears),"-",
as.character(xmonths),"-",
as.character(xdays),
sep="")
xdate <- strptime(xdatestr, "%Y-%m-%d") # format of random date string is like "YYYY-MM-DD"
target.coldate <- strftime(xdate, target.dateformat) # date column of target as character
# *** THE BEFORE MAY BE MASKED OFF ***
# *** COMPOSE 'target.df' ***
# Compose target.df by the given data series.
# Only 2 pseudo data series are used in the following demo code, you may put
# whatever data series concerned onto the param list of 'data.frame()':
target.df <- data.frame(Date = target.coldate, # Col-1: Date
X = target.colx, # Col-2: X
stringsAsFactors = FALSE) # No factors for string type
# *** COMPOSE - END ***
# Improve/Match the target data frame with unemployment and AUD ..............................
tm.Start <- proc.time() # Time of Start
# Add extra columns to target data frame:
target.rows <- length(target.df[,1]) # get row count of target.df
target.dfnew <- data.frame(target.df, # Original target
Unemployment.Rate = rep(NA, target.rows), # Unemployment.Rate
Unemployment.Rate.Annual = rep(NA, target.rows), # Unemployment.Rate.Annual
Unemployment.K1 = rep(NA, target.rows), # Unemployment.K1
Unemployment.K2 = rep(NA, target.rows), # Unemployment.K2
Unemployment.K3 = rep(NA, target.rows), # Unemployment.K3
AUDUSD = rep(NA, target.rows), # AUDUSD
AUDUSD.Annual = rep(NA, target.rows), # AUDUSD.Annual
AUDUSD.K1 = rep(NA, target.rows), # AUDUSD.K1
AUDUSD.K2 = rep(NA, target.rows), # AUDUSD.K2
AUDUSD.K3 = rep(NA, target.rows), # AUDUSD.K3
stringsAsFactors = FALSE)
# Build a string vector in format of lookup.dateformat
# to reflect target date column:
xdate <- strptime(as.character(target.dfnew$Date), target.dateformat) # string -> xdate
target.datestr.aslookup <- strftime(xdate, lookup.dateformat) # xdate -> string in lookup format
# scan and match: loop through 'lookup.dfnew':
for (i in seq(lookup.rows)) {
k.row <- lookup.dfnew[i,] # one row in 'lookup.dfnew'
k.date <- as.character(k.row[, cn.k.date]) # k.date = date in string
ixs <- grep(k.date, target.datestr.aslookup) # indices of target items matching k.date
if (length(ixs) > 0){ # index set available?
target.dfnew[ixs, cn.t.ue] <- k.row[, cn.k.ue] # copy "Unemployment.Rate"
target.dfnew[ixs, cn.t.uea] <- k.row[, cn.k.uea] # copy "Unemployment.Rate.Annual"
target.dfnew[ixs, cn.t.uek1] <- k.row[, cn.k.uek1] # copy "Unemployment.K1"
target.dfnew[ixs, cn.t.uek2] <- k.row[, cn.k.uek2] # copy "Unemployment.K2"
target.dfnew[ixs, cn.t.uek3] <- k.row[, cn.k.uek3] # copy "Unemployment.K3"
target.dfnew[ixs, cn.t.aud] <- k.row[, cn.k.aud] # copy "AUDUSD"
target.dfnew[ixs, cn.t.auda] <- k.row[, cn.k.auda] # copy "AUDUSD.Annual"
target.dfnew[ixs, cn.t.audk1] <- k.row[, cn.k.audk1] # copy "AUDUSD.K1"
target.dfnew[ixs, cn.t.audk2] <- k.row[, cn.k.audk2] # copy "AUDUSD.K1"
target.dfnew[ixs, cn.t.audk3] <- k.row[, cn.k.audk3] # copy "AUDUSD.K1"
}
}
tm.Finish <- proc.time() # Time of Finish
# Check result: ..............
print (head(target.dfnew))
print (tail(target.dfnew))
cat("\nTime Consumed = ", (tm.Finish - tm.Start)[3],"(s)")
|
99761262520ee3f3be965d76be17146544e668d3
|
3aa98ae7a9734c7891d0493a443b58acf497f36d
|
/s6_results_sim_setting_2.R
|
30505fd05a85ed2e14d9bd891f91fc5c45adf427
|
[] |
no_license
|
LTTTDH/SING
|
bca9dd4ab9ea8e0550686c978a8add46bca7ce2f
|
650fc4fff7429387a059d97c14495dd86fd4a161
|
refs/heads/master
| 2023-05-27T15:06:48.905382
| 2021-03-18T20:53:55
| 2021-03-18T20:53:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 19,865
|
r
|
s6_results_sim_setting_2.R
|
# Simulation setting 2
# Error calculation for all methods, and creation of figures
# Load the results of joint ICA
load("jointICA_LargeScaleindiv10.Rda")
# Load the results from separate approach (rho = 0)
load("sepJB_LargeScale.Rda")
# Load the results from SING (from small rho to large rho)
load("out_indiv_small.Rda")
load("out_indiv_medium.Rda")
load("out_indiv_large.Rda")
# Load the results from mCCA + joint ICA
load("mCCA_LargeScale.Rda")
# Load true underlying components
load("SimulatedLargeScaleindiv10.Rdata")
trueJx <- mj %*% rbind(sj1x, sj2x)
trueJy <- t(t(mj) * c(-5, 2)) %*% rbind(sj1y, sj2y)
trueJxF2 <- sum(trueJx^2)
trueJyF2 <- sum(trueJy^2)
# Source all the functions
source("jngcaFunctions.R")
source("mCCAjointICA.R")
# Create data frame to store results for all methods
methods = c("Joint ICA", "mCCA+jICA", "rho 0", "rho averaged", "small rho", "medum rho", "large rho")
types = c("Sx", "Sy", "Mx", "My", "Jx", "Jy")
errors = matrix(NA, length(methods), length(types))
errors = as.data.frame(errors)
colnames(errors) = types
rownames(errors) = methods
# Data processing and dimensions
n = nrow(dX)
pX = ncol(dX)
pY = ncol(dY)
# For X
# Center
dXsA <- dX - matrix(rowMeans(dX), n, pX, byrow = F)
# Scale rowwise
est.sigmaXA = tcrossprod(dXsA)/(pX-1) ## since already centered, can just take tcrossprod
whitenerXA = est.sigmaXA%^%(-0.5)
invLx = est.sigmaXA%^%(0.5)
xDataA = whitenerXA %*% dXsA
# For Y
# Center
dYsA <- dY - matrix(rowMeans(dY), n, pY, byrow = F)
# Scale rowwise
est.sigmaYA = tcrossprod(dYsA)/(pY-1) ## since already centered, can just take tcrossprod
whitenerYA = est.sigmaYA%^%(-0.5)
yDataA = whitenerYA %*% dYsA
invLy = est.sigmaYA%^%(0.5)
# Starting points for the algorithm are Us
###########################################
Uxfull <- output_sepJB$estX_JB$Ws
Mx_JB = est.M.ols(sData = output_sepJB$estX_JB$S, xData = t(dX))
Uyfull <- output_sepJB$estY_JB$Ws
My_JB = est.M.ols(sData = output_sepJB$estY_JB$S, xData = t(dY))
matchMxMy = greedymatch(t(Mx_JB), t(My_JB), Ux = t(Uxfull), Uy = t(Uyfull))
cor(matchMxMy$Mx[, 1:2], matchMxMy$My[, 1:2]) # 0.95 and 0.93
# Calculate errors for Sx
############################
#joint ICA
errorSx = frobICA(S1 = t(rbind(sj1x, sj2x)), S2 = out_jointICA$S[1:pX, ], standardize = T)
errorSx # 1.408
errors[1, 1] = errorSx
# mCCA + joint ICA
errorSx = frobICA(S1 = t(rbind(sj1x, sj2x)), S2 = out_mcca$S[1:pX, ], standardize = T)
errorSx #1.41
errors[2, 1] = errorSx
# rho = 0 with all 2 matched components
Sxmatched = matchMxMy$Ux[1:2, ] %*% xDataA
errorSx = frobICA(S1 = t(rbind(sj1x, sj2x)), S2 = t(Sxmatched), standardize = T)
errorSx # 0.051
errors[3, 1] = errorSx
# small rho
Sxmatched = out_indiv_small$Ux[1:2, ] %*% xDataA
errorSx = frobICA(S1 = t(rbind(sj1x, sj2x)), S2 = t(Sxmatched), standardize = T)
errorSx # 0.035
errors[5, 1] = errorSx
# medium rho
Sxmatched = out_indiv_medium$Ux[1:2, ] %*% xDataA
errorSx = frobICA(S1 = t(rbind(sj1x, sj2x)), S2 = t(Sxmatched), standardize = T)
errorSx # 0.035
errors[6, 1] = errorSx
# large rho
Sxmatched = out_indiv_large$Ux[1:2, ] %*% xDataA
errorSx = frobICA(S1 = t(rbind(sj1x, sj2x)), S2 = t(Sxmatched), standardize = T)
errorSx # 0.035
errors[7, 1] = errorSx
# Calculate errors for Sy
############################
#joint ICA
errorSy = frobICA(S1 = t(rbind(sj1y, sj2y)), S2 = out_jointICA$S[(pX+1):(pX+pY), ], standardize = T)
errorSy # 1.409
errors[1, 2] = errorSy
# mCCA + joint ICA
errorSy = frobICA(S1 = t(rbind(sj1y, sj2y)), S2 = out_mcca$S[(pX+1):(pX+pY), ], standardize = T)
errorSy #1.41
errors[2, 2] = errorSy
# rho = 0 with all 2 matched components
Symatched = matchMxMy$Uy[1:2, ] %*% yDataA
errorSy = frobICA(S1 = t(rbind(sj1y, sj2y)), S2 = t(Symatched), standardize = T)
errorSy # 0.031, same
errors[3, 2] = errorSy
# small rho
Symatched = out_indiv_small$Uy[1:2, ] %*% yDataA
errorSy = frobICA(S1 = t(rbind(sj1y, sj2y)), S2 = t(Symatched), standardize = T)
errorSy # 0.023
errors[5, 2] = errorSy
# medium rho
Symatched = out_indiv_medium$Uy[1:2, ] %*% yDataA
errorSy = frobICA(S1 = t(rbind(sj1y, sj2y)), S2 = t(Symatched), standardize = T)
errorSy # 0.023
errors[6, 2] = errorSy
# large rho
Symatched = out_indiv_large$Uy[1:2, ] %*% yDataA
errorSy = frobICA(S1 = t(rbind(sj1y, sj2y)), S2 = t(Symatched), standardize = T)
errorSy # 0.023
errors[7, 2] = errorSy
# Calculate errors for M
############################
# joint ICA
dXcentered <- dX - matrix(rowMeans(dX), n, pX, byrow = F)
dYcentered <- dY - matrix(rowMeans(dY), n, pY, byrow = F)
# Normalization step here. Divide by \|X\|_F^2 each part
dXsA <- dXcentered/sqrt(mean(dXcentered^2))
dYsA <- dYcentered/sqrt(mean(dYcentered^2))
# Concatenate them together [X, Y] and perform SVD (PCA)
dXY <- cbind(dXsA, dYsA) # [X, Y] ~ UDV'
Mjoint = est.M.ols(sData = out_jointICA$S, xData = t(dXY))
errorM = frobICA(M1 = Mjoint, M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorM # 1.362
errors[1, 3:4] = errorM
# mCCA + joint ICA
errorMx = frobICA(M1 = out_mcca$Mx, M2 = t(mj), standardize = T) * sqrt(nrow(mj))
errorMx #1.37
errors[2, 3] = errorMx
errorMy = frobICA(M1 = out_mcca$My, M2 = t(mj), standardize = T) * sqrt(nrow(mj))
errorMy #1.32
errors[2, 4] = errorMy
# rho = 0 with on matched
Mxjoint = tcrossprod(invLx, matchMxMy$Ux[1:2, ])
errorMx = frobICA(M1 = t(Mxjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMx # 0.295
Myjoint = tcrossprod(invLy, matchMxMy$Uy[1:2, ])
errorMy = frobICA(M1 = t(Myjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMy # 0.208
errors[3, 3] = errorMx
errors[3, 4] = errorMy
cordiag = diag(cor(Mxjoint, Myjoint))
cordiag # 0.95 and 0.93
newM = (Mxjoint + Myjoint%*% sign(diag(cordiag)))
newM = newM %*% diag(1/apply(newM, 2, function(x) sqrt(sum(x^2))))
errorM = frobICA(M1 = t(newM), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorM # 0.171
# small rho on matched
Mxjoint = tcrossprod(invLx, out_indiv_small$Ux[1:2, ])
errorMx = frobICA(M1 = t(Mxjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMx # 0.118
Myjoint = tcrossprod(invLy, out_indiv_small$Uy[1:2, ])
errorMy = frobICA(M1 = t(Myjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMy # 0.121
errors[5, 3] = errorMx
errors[5, 4] = errorMy
cordiag = diag(cor(Mxjoint, Myjoint))
cordiag #0.9994; 0.9999
newM = (Mxjoint + Myjoint%*% sign(diag(cordiag)))
newM = newM %*% diag(1/apply(newM, 2, function(x) sqrt(sum(x^2))))
newM = newM %*% diag(1/apply(newM, 2, function(x) sqrt(sum(x^2))))
errorM = frobICA(M1 = t(newM), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorM # 0.12
# medium rho on matched
Mxjoint = tcrossprod(invLx, out_indiv_medium$Ux[1:2, ])
errorMx = frobICA(M1 = t(Mxjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMx # 0.115
Myjoint = tcrossprod(invLy, out_indiv_medium$Uy[1:2, ])
errorMy = frobICA(M1 = t(Myjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMy # 0.115
errors[6, 3] = errorMx
errors[6, 4] = errorMy
cordiag = diag(cor(Mxjoint, Myjoint))
cordiag #0.99999; 0.999998
newM = (Mxjoint + Myjoint%*% sign(diag(cordiag)))
newM = newM %*% diag(1/apply(newM, 2, function(x) sqrt(sum(x^2))))
newM = newM %*% diag(1/apply(newM, 2, function(x) sqrt(sum(x^2))))
errorM = frobICA(M1 = t(newM), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorM # 0.115
# large rho on matched
Mxjoint = tcrossprod(invLx, out_indiv_large$Ux[1:2, ])
errorMx = frobICA(M1 = t(Mxjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMx # 0.114
Myjoint = tcrossprod(invLy, out_indiv_large$Uy[1:2, ])
errorMy = frobICA(M1 = t(Myjoint), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorMy # 0.114
errors[7, 3] = errorMx
errors[7, 4] = errorMy
cordiag = diag(cor(Mxjoint, Myjoint))
cordiag #0.999999999; 1
newM = (Mxjoint + Myjoint%*% sign(diag(cordiag)))
newM = newM %*% diag(1/apply(newM, 2, function(x) sqrt(sum(x^2))))
newM = newM %*% diag(1/apply(newM, 2, function(x) sqrt(sum(x^2))))
errorM = frobICA(M1 = t(newM), M2 = t(mj), standardize = T) * sqrt(ncol(Mjoint))
errorM # 0.114
# Calculate errors for Jx and Jy
############################
# Joint ICA
errorJx = sum((tcrossprod(t(out_jointICA$Mjoint), out_jointICA$S[1:pX, ]) * sqrt(mean(dXcentered^2)) - trueJx)^2)/trueJxF2
errorJx #89.3
errors[1, 5] = sqrt(errorJx)
errorJy = sum((tcrossprod(t(out_jointICA$Mjoint), out_jointICA$S[(pX + 1):(pX + pY), ])* sqrt(mean(dYcentered^2)) - trueJy)^2)/trueJyF2
errorJy # 61.1
errors[1, 6] = sqrt(errorJy)
# mCCA + Joint ICA
errorJx = sum((tcrossprod(t(out_mcca$Mx), out_mcca$S[1:pX, ]) - trueJx)^2)/trueJxF2
errorJx # 92.2
errors[2, 5] = sqrt(errorJx)
errorJy = sum((tcrossprod(t(out_mcca$My), out_mcca$S[(pX+1):(pX+pY), ]) - trueJy)^2)/trueJyF2
errorJy # 62.3
errors[2, 6] = sqrt(errorJy)
# separate rho
Sxmatched = matchMxMy$Ux[1:2, ] %*% xDataA
Symatched = matchMxMy$Uy[1:2, ] %*% yDataA
Mxjoint = tcrossprod(invLx, matchMxMy$Ux[1:2, ])
Myjoint = tcrossprod(invLy, matchMxMy$Uy[1:2, ])
errorJx = sum((Mxjoint %*% Sxmatched - trueJx)^2)/trueJxF2
errorJx #0.095
errorJy = sum((Myjoint %*% Symatched - trueJy)^2)/trueJyF2
errorJy # 0.025
errors[3, 5] = sqrt(errorJx)
errors[3, 6] = sqrt(errorJy)
# averaged rho
newM = aveM(matchMxMy$Mx[,1:2], matchMxMy$My[,1:2])
errorM = frobICA(M1 = t(newM), M2 = t(data$mj), standardize = T)*sqrt(ncol(Mjoint))
errors[4, 3:4] = errorM
# Back projection on the mixing matrix
outx <- est.S.backproject(Sxmatched, Mxjoint, newM)
outy <- est.S.backproject(Symatched, Myjoint, newM)
errorSxAve = frobICA(S2 = t(rbind(sj1x, sj2x)), S1 = t(outx$S), standardize = T)
errorSyAve = frobICA(S2 = t(rbind(sj1y, sj2y)), S1 = t(outy$S), standardize = T)
errors[4, 1] = errorSxAve
errors[4, 2] = errorSyAve
# Joint signal Frobenius norm reconstruction error with average
errorJxave = sum((newM %*% diag(outx$D) %*% outx$S/sqrt(pX-1) - trueJx)^2)/trueJxF2
errorJyave = sum((newM %*% diag(outy$D) %*% outy$S/sqrt(pY-1) - trueJy)^2)/trueJyF2
errors[4, 5] = sqrt(errorJxave)
errors[4, 6] = sqrt(errorJyave)
# small rho
Sxmatched = out_indiv_small$Ux[1:2, ] %*% xDataA
Symatched = out_indiv_small$Uy[1:2, ] %*% yDataA
Mxjoint = tcrossprod(invLx, out_indiv_small$Ux[1:2, ])
Myjoint = tcrossprod(invLy, out_indiv_small$Uy[1:2, ])
errorJx = sum((Mxjoint %*% Sxmatched - trueJx)^2)/trueJxF2
errorJx #0.095
errorJy = sum((Myjoint %*% Symatched - trueJy)^2)/trueJyF2
errorJy # 0.025
errors[5, 5] = sqrt(errorJx)
errors[5, 6] = sqrt(errorJy)
# medium rho
Sxmatched = out_indiv_medium$Ux[1:2, ] %*% xDataA
Symatched = out_indiv_medium$Uy[1:2, ] %*% yDataA
Mxjoint = tcrossprod(invLx, out_indiv_medium$Ux[1:2, ])
Myjoint = tcrossprod(invLy, out_indiv_medium$Uy[1:2, ])
errorJx = sum((Mxjoint %*% Sxmatched - trueJx)^2)/trueJxF2
errorJx #0.095
errorJy = sum((Myjoint %*% Symatched - trueJy)^2)/trueJyF2
errorJy # 0.025
errors[6, 5] = sqrt(errorJx)
errors[6, 6] = sqrt(errorJy)
# large rho
Sxmatched = out_indiv_large$Ux[1:2, ] %*% xDataA
Symatched = out_indiv_large$Uy[1:2, ] %*% yDataA
Mxjoint = tcrossprod(invLx, out_indiv_large$Ux[1:2, ])
Myjoint = tcrossprod(invLy, out_indiv_large$Uy[1:2, ])
errorJx = sum((Mxjoint %*% Sxmatched - trueJx)^2)/trueJxF2
errorJx #0.095
errorJy = sum((Myjoint %*% Symatched - trueJy)^2)/trueJyF2
errorJy # 0.025
errors[7, 5] = sqrt(errorJx)
errors[7, 6] = sqrt(errorJy)
errors = round(errors, 3)
# Create a table with all errors
####################################
library(xtable)
table = xtable(errors, digits = 3)
print(table)
# Save true components, estimated from jointICA, estimated with rho=0, estimated with small rho'
############################
Sxtrue = t(rbind(sj1x, sj2x))
Sytrue = t(rbind(sj1y, sj2y))
SxjointICA = out_jointICA$S[1:pX, ]
SyjointICA = out_jointICA$S[(pX+1):(pX + pY), ]
Sx_rho0 = t(matchMxMy$Ux[1:2, ] %*% xDataA)
Sy_rho0 = t(matchMxMy$Uy[1:2, ] %*% yDataA)
Sx_rhoSmall = t(out_indiv_small$Ux[1:2, ] %*% xDataA)
Sy_rhoSmall = t(out_indiv_small$Uy[1:2, ] %*% yDataA)
Sx_rhoLarge = t(out_indiv_large$Ux[1:2, ] %*% xDataA)
Sy_rhoLarge = t(out_indiv_large$Uy[1:2, ] %*% yDataA)
SxmCCA = out_mcca$S[1:pX, ]
SymCCA = out_mcca$S[(pX+1):(pX + pY), ]
Sxtrue = signchange(Sxtrue)
Sytrue = signchange(Sytrue)
SxjointICA = signchange(SxjointICA)
SyjointICA = signchange(SyjointICA)
Sx_rhoSmall = signchange(Sx_rhoSmall)
Sy_rhoSmall = signchange(Sy_rhoSmall)
Sx_rhoLarge = signchange(Sx_rhoLarge)
Sy_rhoLarge = signchange(Sy_rhoLarge)
SxmCCA = signchange(SxmCCA)
SymCCA = signchange(SymCCA)
# Save the components
save(Sxtrue, Sytrue, SxjointICA, SyjointICA, Sx_rhoSmall, Sy_rhoSmall, Sx_rhoLarge, Sy_rhoLarge, SxmCCA, SymCCA, file = "EstimatedComponentsLarge.Rda")
load("EstimatedComponentsLarge.Rda")
# Create all the plots for joint components
out_true1 = plotNetwork(Sytrue[,1], title='Truth',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
out_true2 = plotNetwork(Sytrue[,2], title='Truth',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
out_joint1 = plotNetwork(SyjointICA[,1], title='Joint ICA',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
out_joint2 = plotNetwork(SyjointICA[,2], title='Joint ICA',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
out_rhoLarge1 = plotNetwork(Sy_rhoLarge[,1], title='large~rho',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
out_rhoLarge2 = plotNetwork(Sy_rhoLarge[,2], title='large~rho',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
out_mcca1 = plotNetwork(SymCCA[,1], title='mCCA+jICA',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
out_mcca2 = plotNetwork(SymCCA[,2], title='mCCA+jICA',qmin=0.005, qmax=0.995, path = 'community_affiliation_mmpplus.csv')
# Compare loadings from the components of Y shared structure
############################################################################
mmp_modules = read.csv('community_affiliation_mmpplus.csv')
mmp_order = order(mmp_modules$Community_Vector)
Community = factor(mmp_modules$Community_Label)[mmp_order]
# 1st component loadings
dataLoad <- data.frame(x = rep(c(1:379), 4), loadingsum2 = c(out_true1$loadingsummary[mmp_order], out_rhoLarge1$loadingsummary[mmp_order], out_joint1$loadingsummary[mmp_order], out_mcca1$loadingsummary[mmp_order]), Community = rep(Community, 4), Method = rep(c("Truth", "SING", "Joint~ICA", "mCCA+jICA"), each = 379))
dataLoad$Method <- relevel(as.factor(dataLoad$Method), "Truth")
# 2nd component loadings
dataLoad2 <- data.frame(x = rep(c(1:379), 4), loadingsum2 = c(out_true2$loadingsummary[mmp_order], out_rhoLarge2$loadingsummary[mmp_order], out_joint2$loadingsummary[mmp_order], out_mcca2$loadingsummary[mmp_order]), Community = rep(Community, 4), Method = rep(c("Truth", "SING", "Joint~ICA", "mCCA+jICA"), each = 379))
dataLoad2$Method <- relevel(as.factor(dataLoad2$Method), "Truth")
dataLoad$component <- "Component~1"
dataLoad2$component <- "Component~2"
dataAll <- rbind(dataLoad, dataLoad2)
dataAll$Method= factor(dataAll$Method, levels = c("Truth", "SING", "Joint~ICA", "mCCA+jICA"))
# Relevle
pdf(file = "LargeScaleBothComponentsY_mCCA.pdf", width = 14, height = 4)
p = ggplot(dataAll, aes(x = x, y = loadingsum2, col = Community))+geom_point(size = 4) + facet_grid(component~Method, labeller = label_parsed)+xlab('MMP Index')+ylab('L1 Norm of the Rows') + theme(text = element_text(size=20))
print(p)
dev.off()
# Compare visual networks from the components of Y shared structure
############################################################################
qmin=0.005
qmax=0.995
labels = c('VI','SM','DS','VS','DM','CE','SC')
coords = c(0,70.5,124.5,148.5,197.5,293.5,360.5)
zmin = -6
zmax = 6
meltsub = create.graph.long(out_true1$netmat,mmp_order)
meltsub$Method = "Truth"
meltsub$component = "Component~1"
meltsubT = create.graph.long(out_true2$netmat,mmp_order)
meltsubT$Method = "Truth"
meltsubT$component = "Component~2"
meltsub = rbind(meltsub, meltsubT)
meltsub2 = create.graph.long(out_joint1$netmat, mmp_order)
meltsub2$Method = "Joint~ICA"
meltsub2$component = "Component~1"
meltsub2T = create.graph.long(out_joint2$netmat,mmp_order)
meltsub2T$Method = "Joint~ICA"
meltsub2T$component = "Component~2"
meltsub2 = rbind(meltsub2, meltsub2T)
meltsub3 = create.graph.long(out_rhoLarge1$netmat, mmp_order)
meltsub3$Method = "Large~rho"
meltsub3$component = "Component~1"
meltsub3T = create.graph.long(out_rhoLarge2$netmat,mmp_order)
meltsub3T$Method = "Large~rho"
meltsub3T$component = "Component~2"
meltsub3 = rbind(meltsub3, meltsub3T)
meltsub4 = create.graph.long(out_mcca1$netmat, mmp_order)
meltsub4$Method = "mCCA+jICA"
meltsub4$component = "Component~1"
meltsub4T = create.graph.long(out_mcca2$netmat,mmp_order)
meltsub4T$Method = "mCCA+jICA"
meltsub4T$component = "Component~2"
meltsub4 = rbind(meltsub4, meltsub4T)
meltsubAll = rbind(meltsub, meltsub2, meltsub4, meltsub3)
meltsubAll$Method <- as.factor(meltsubAll$Method)
meltsubAll$Method <- relevel(meltsubAll$Method, "Truth")
meltsubAll$Method= factor(meltsubAll$Method, levels = c("Truth", "Joint~ICA", "mCCA+jICA", "Large~rho"))
# Truncate small values for ease of signal visualization
meltsubAll$value[abs(meltsubAll$value) < 1] = 0
g2 = ggplot(meltsubAll, aes(X1, X2,fill=value)) + geom_tile()+ scale_fill_gradient2(low = "blue", high = "red", limits=c(zmin,zmax), oob=squish)+labs(x = "Node 1", y = "Node 2") + coord_cartesian(clip='off',xlim=c(-0,390)) + facet_grid(component~Method, labeller = label_parsed)
for (i in 1:7) {
if (i!=3) {
g2 = g2+geom_hline(yintercept = coords[i],linetype="dotted",size=0.5)+geom_vline(xintercept = coords[i],linetype="dotted",size=0.5)+annotation_custom(grob = textGrob(label = labels[i], hjust = 0, gp = gpar(cex = 1)),ymin = (coords[i]+10), ymax = (coords[i]+10), xmin = 385, xmax = 385)+annotation_custom(grob = textGrob(label = labels[i], hjust = 0, gp = gpar(cex = 1)),xmin = (coords[i]+10), xmax = (coords[i]+10), ymin = -7, ymax = -7)
} else{
g2 = g2+geom_hline(yintercept = coords[i],linetype="dotted",size=0.5)+geom_vline(xintercept = coords[i],linetype="dotted",size=0.5)+annotation_custom(grob = textGrob(label = labels[i], hjust = 0, gp = gpar(cex = 1)),ymin = (coords[i]+10), ymax = (coords[i]+10), xmin = 385, xmax = 385)+annotation_custom(grob = textGrob(label = labels[i], hjust = 0, gp = gpar(cex = 1)),xmin = (coords[i]+1), xmax = (coords[i]+1), ymin = -7, ymax = -7)
}
}
g2 = g2 + theme(text = element_text(size=24))
g2 = g2 + theme(text = element_text(size=30))
print(g2)
g2 = g2 + theme(text = element_text(size=40))
print(g2)
# pdf(file = "LargeScaleComponentsYnetwork.pdf", width = 14, height = 6)
# print(g2)
# dev.off()
png(filename = "LargeScaleComponentsYnetwork_mCCA.png",
width = 2500, height = 2000)
print(g2)
dev.off()
# Create cifti files:
#############################################################################################
source('makecifti.R')
# match joint ICA:
SxjointICA_matched = matchICA(S = SxjointICA,template = Sxtrue)
cor(SxjointICA_matched,Sxtrue)
# joint components do not contain the joint signal
cor(Sx_rhoSmall,Sxtrue)
apply(Sx_rhoSmall,2,function(x) mean(x^3))
apply(SxjointICA_matched,2,function(x) mean(x^3))
# If necessary run the following:
#Sxtrue = signchange(Sxtrue)
#Sx_rhoLarge = signchange(Sx_rhoLarge)
#SxjointICA = signchange(SxjointICA)
#apply(t(sIxs),2,function(x) mean(x^3))
#SIxs = signchange(t(sIxs))
# This function has dependencies that will need to be modified. It requires matlab and wb_command:
makecifti(Sxtrue,"Sxtrue.dtseries.nii")
makecifti(Sx_rhoSmall,"Sx_rhoSmall.dtseries.nii")
makecifti(SxjointICA_matched,"SxjointICA.dtseries.nii")
# Alternative showing how to specify pathnames on other systems:
#makecifti(Sxtrue,"Sxtrue.dtseries.nii", wbloc='/home/benjamin/Applications2/workbench/bin_linux64/wb_command', matlabloc='/usr/local/bin/matlab')
|
9d582dfbf3cf7afbf5772572b2be71e2d40d841e
|
d2ac85674d6812fe3f606094bae82ea089659609
|
/Scripts/gammbootstrap.R
|
4b5d5a9ef85abb0ccf2a58e0b5d8ae8afb46cf77
|
[] |
no_license
|
LabNeuroCogDevel/R03Behavioral
|
2a98e71917b1f35a4affe08298e32f9100df3b93
|
f743b316ac00aa3381eb72ae08c47b3c87891ebf
|
refs/heads/master
| 2020-09-23T07:19:38.313210
| 2019-12-05T22:19:06
| 2019-12-05T22:19:06
| 225,437,014
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 8,855
|
r
|
gammbootstrap.R
|
#!/usr/bin/env Rscript
library(dplyr)
library(tidyr)
library(lubridate)
library(ggplot2)
library(lsmeans)
library(mgcv)
library(itsadug)
library(lme4)
library(lsmeans)
library(stats)
library(psych)
library(parallel)
library(lme4) # bootMer
library(MASS) ## for mvrnorm
library(cowplot)
lunaize_geomraster<-function(x){
x+theme_bw()+theme(panel.grid.minor = element_blank(),panel.grid.major = element_blank())+theme(axis.ticks.y=element_line(colour="white"))+theme(axis.title.y=element_blank(),axis.ticks.y=element_blank(),axis.text.y=element_blank())+
theme(legend.position = "none")#+theme(axis.title.x=element_blank(),axis.text.x=element_blank())
}
#library(gbp) # bin bpacking problem solver
######################
#' @output - this thing
coglongdf<-read.csv("/Users/brendenclemmens/Desktop/Projects/R03_behavioral/data/btc_R03scoredmeasures_20190313.csv")
# btc_simgam <- function() {
# coglongdf<-read.csv("/Users/brendenclemmens/Desktop/Projects/R03_behavioral/data/btc_R03scoredmeasures_20190313.csv")
# fml <- f1score~s(Ageatvisit)+s(id, bs="re")
# m <- gam(fml, data=coglongdf)
# ci <- ci_from_simgam(m, 'Ageatvisit')
# }
ci_from_simgam <- function(m, agevar, n=10000) {
simdiff <- sim_diff1_from_gam(m, agevar, n=10000)
ci <- ci_from_simdiff1(simdiff$pred, simdiff$ages)
}
sim_diff1_from_gam <- function(m, agevar, id='id', n.iterations=10000) {
## From
# https://stats.stackexchange.com/questions/190348/can-i-use-bootstrapping-to-estimate-the-uncertainty-in-a-maximum-value-of-a-gam
v <- m$model[, agevar]
cond_list <- list(seq(min(v), max(v), by=.1))
pp <- data.frame(a=cond_list[[1]], b=Inf)
# names should match what went into the model
names(pp) <- c(agevar, id)
Xp <- predict(m, pp, type="lpmatrix")
pp2<-pp
pp2$visit=1
Xp2<-predict(m, pp2, type="lpmatrix")
mu_beta <- coef(m)
sigma_Vb <- vcov(m) # variance-covariance matrix of the main parameters fitted model
# used as: a positive-definite symmetric matrix specifying the covariance matrix of the variables.
set.seed(10)
mrand <- mvrnorm(n.iterations, mu_beta, sigma_Vb)
ilink <- family(m)$linkinv
# assumes last column is the id/raneff
Xp_noid <- Xp[,1:ncol(Xp)-1]
mrand_noid <- mrand[,1:ncol(mrand)-1]
# generate a whole bunch of plausable values, get the diff
pred <- lapply(seq_len(n.iterations), function(i) {
pred <- ilink(Xp_noid %*% mrand_noid[i, ])
dff <- c(NA,diff(pred))
#ci <- quantile(dff, c(.025,.975)) ## get 95% CI
})
return(list(pred=pred, ages=pp[,1]))
}
ci_from_simdiff1 <- function(pred, ages) {
names(pred) <- 1:length(pred)
mm <- t(bind_rows(pred))
# this is the ouptut !
mean_dff <- apply(mm, 2, mean)
ci <- apply(mm, 2, quantile, c(.025,.975), na.rm=T)
colnames(ci) <- ages
return(list(ci=ci,mean_dff=mean_dff))
# this is for fun
ages[which.min(ci[1,])]
ages[which.min(ci[2,])]
plot(ages, means_dff)
for(i in 1:10) lines(ages, pred[[i]])
}
####ploting thresholded derivs####
plotgammfactorwithderiv<-function(df,model,derivs,agevar,yvar,idvar,xplotname="Age",yplotname="fit",savename="growthrate"){
ci<-data.frame(derivs$ci)
derivages<-as.numeric(gsub("X","",names(ci)))
names(ci)<-derivages
cit<-as.data.frame(t(ci))
names(cit)<-c("low","high")
cit$age<-row.names(cit)
meanderivdf<-as.data.frame(derivs$mean_dff)
names(meanderivdf)<-"deriv"
meanderivdf$age<-derivages
sigages<-merge(meanderivdf,cit,by="age")
sigages$derivthresh<-sigages$deriv
sigages$derivthresh[sign(sigages$low)!=sign(sigages$high)]<-0
maturationpoint<-data.frame(age=min(sigages$age[sigages$derivthresh==0],na.rm=TRUE))
print(maturationpoint$age)
maturationpoint$height<-1
tile<-ggplot(sigages,aes(x=age,y=1,fill=derivthresh))+geom_raster(interpolate=TRUE)+scale_fill_gradient2(low = "blue", high = "red", mid = "white",midpoint = 0, space = "Lab",breaks=c(max(meanderivdf$deriv,na.rm=TRUE),0,min(meanderivdf$deriv,na.rm=TRUE)),limits=c(min(meanderivdf$deriv,na.rm=TRUE),max(meanderivdf$deriv,na.rm=TRUE)))
tile2<-tile+geom_segment(aes(x=maturationpoint$age,xend=maturationpoint$age,y=.5,yend=1.5),linetype=2,colour="black")+xlab("\nAge")
tile3<-lunaize_geomraster(tile2)+theme(text = element_text(size=36))
#tile4<-tile3+theme(panel.border = element_rect(colour = "black", fill=NA, size=1),plot.margin = margin(-1, -1, -1, -1, "cm"))
modeldata<-data.frame(ydata=model$y,agevar=model$model[,agevar])
agepred<-get_predictions(model,cond=list(Ageatvisit=derivages))
ageplot<-ggplot(agepred,aes_string(x=agepred[,agevar],y='fit'))+geom_line(colour="black",size=2)+geom_point(data=modeldata,aes(x=agevar,ydata),alpha=.2)+
geom_line(data=df,aes_string(x=agevar,y=yvar,group=idvar),alpha=.2)+ylab(yplotname)+xlab(xplotname)
ageplot2<-ageplot#+#geom_vline(xintercept = maturationpoint$age,linetype=2)
ageplot3<-LNCDR::lunaize(ageplot2)+theme(text = element_text(size=36))+theme(axis.title.x=element_blank(),axis.text.x=element_blank())
library(grid)
library(gridExtra)
plotsavename<-paste0("/Users/brendenclemmens/Desktop/Projects/R03_behavioral/Data/",paste0(savename,".pdf"))
tilegrob<-ggplotGrob(tile3)
agegrob<-ggplotGrob(ageplot3)
g<-rbind(agegrob,tilegrob,size="first")
panels <- g$layout$t[grep("panel", g$layout$name)]
g$heights[panels] <- unit(c(1,.1),"null")
pdf(plotsavename, height = 9, width = 12)
grid.draw(g)
dev.off()
}
#######
coglongdf_agerank<-coglongdf %>% group_by(id) %>% mutate(minage=min(Ageatvisit)+id/10000) %>% ungroup %>% mutate(agerank=rank(minage))
coglongdf_agerankwithvisits<-coglongdf_agerank %>% group_by(id) %>% mutate(nvisits=n())
coglongdf_agerankwithvisits$fiveormore<-"1-4 Visits"
coglongdf_agerankwithvisits$fiveormore[coglongdf_agerankwithvisits$nvisits>4]<-"5 or More Visits"
mainageplot<-ggplot(coglongdf_agerankwithvisits,aes(x=Ageatvisit,y=agerank,group=id,colour=as.factor(fiveormore)))+geom_line()+geom_point()
mainageplot<-mainageplot+scale_colour_manual(values=c("black","black"))+ylab("Subjects")+xlab("Age")
mainageplotgp<-LNCDR::lunaize(mainageplot)+theme(text = element_text(size=36))+theme(legend.position = "none")
mainageplotgp<-mainageplotgp+theme(axis.ticks.y=element_blank(),axis.text.y=element_blank())
ggsave("/Users/brendenclemmens/Desktop/Projects/R03_behavioral/Data/ageplot.pdf",mainageplotgp,height=8,width=10)
#######all data
#####factor 1############
m1_factormodel<-gam(f1score~s(Ageatvisit)+s(id, bs="re"),data=coglongdf)
derivsfactor1<-ci_from_simgam(m1_factormodel, 'Ageatvisit')
derivsfactor1<-LNCDR::gam_growthrate(derivsfactor1, 'Ageatvisit')
LNCDR::gam_growthrate_plot(coglongdf,m1_factormodel,derivsfactor1,'Ageatvisit','f1score','id')
plotgammfactorwithderiv(coglongdf,m1_factormodel,derivsfactor1,'Ageatvisit','f1score','id',yplotname="Cognitive Control",savename="factor1")
####factor 2##############
m2_factormodel<-gam(f2score~s(Ageatvisit)+s(id, bs="re"),data=coglongdf)
derivsfactor2<-ci_from_simgam(m2_factormodel, 'Ageatvisit')
plotgammfactorwithderiv(coglongdf,m2_factormodel,derivsfactor2,'Ageatvisit','f2score','id',yplotname="Pure Latency",savename="factor2")
derivsfactor2<-LNCDR::gam_growthrate(m2_factormodel, 'Ageatvisit')
gam_growthrate_plot(coglongdf,m2_factormodel,derivsfactor2,'Ageatvisit','f2score','id')
###factor 1, 5 or more visits#######
coglongdfwithvisits<-coglongdf %>% group_by(id) %>% mutate(nvisits=n())
coglongdfwithvisits_fiveormore<-coglongdfwithvisits[coglongdfwithvisits$nvisits>4,]
##############
m1_factormodel<-gam(f1score~s(Ageatvisit)+s(id, bs="re"),data=coglongdfwithvisits_fiveormore)
derivsfactor1<-ci_from_simgam(m1_factormodel, 'Ageatvisit')
plotgammfactorwithderiv(coglongdfwithvisits_fiveormore,m1_factormodel,derivsfactor1,'Ageatvisit','f1score','id',yplotname="Cognitive Control",savename="factor1.fiveormorevisits")
#########
m2_factormodel<-gam(f2score~s(Ageatvisit)+s(id, bs="re"),data=coglongdfwithvisits_fiveormore)
derivsfactor2<-ci_from_simgam(m2_factormodel, 'Ageatvisit')
plotgammfactorwithderiv(coglongdfwithvisits_fiveormore,m2_factormodel,derivsfactor2,'Ageatvisit','f2score','id',yplotname="Pure Latency",savename="factor2.fiveormorevisits")
###############
##################control for practice effects######
coglongdfwithvisitno<-coglongdf %>% group_by(id) %>% mutate(visit=rank(d8))
m1_factormodel<-gam(f1score~s(Ageatvisit)+s(visit)+s(id, bs="re"),data=coglongdfwithvisitno)
derivsfactor1<-LNCDR::gam_growthrate(m1_factormodel, 'Ageatvisit')
gam_growthrate_plot(coglongdf,m1_factormodel,derivsfactor1,'Ageatvisit','f1score','id')
plotgammfactorwithderiv(coglongdfwithvisitno,m1_factormodel,derivsfactor1,'Ageatvisit','f1score','id',yplotname="Cognitive Control",savename="factor1.visitcovariation")
######
|
a4cba23932c4b29624ef7cdb966270daa112f03b
|
559713216d4fe05838b1450981d8f6a2bd838135
|
/profiling/6.bode_new_data/6.D.3_collect_ik.R
|
9750886746f95c0c82565e7b8e9dd7537f9c5f79
|
[] |
no_license
|
yangjl/phasing
|
6ac18f067c86d225d7351dfb427b6ae56713ce1b
|
99a03af55171dac29b51961acb6a044ea237cb3a
|
refs/heads/master
| 2020-04-06T06:58:38.234815
| 2016-06-10T00:40:36
| 2016-06-10T00:40:36
| 38,838,697
| 1
| 2
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,241
|
r
|
6.D.3_collect_ik.R
|
### Jinliang Yang
### use impute_parent in CJ data
#library(imputeR)
get_ik <- function(path="largedata/ik", pattern="kid_geno"){
files <- list.files(path, pattern, full.names = TRUE)
message(sprintf("### found [ %s ] files!", length(files)))
kgeno <- read.csv(files[1])
for(i in 2:length(files)){
ktem <- read.csv(files[i])
if(sum(kgeno$snpid != ktem$snpid) == 0){
kgeno <- cbind(kgeno, ktem[, -1])
message(sprintf("###>>> read the [ %s/%s ] file", i, length(files)))
}else{
stop("!!! snpid not match !!!")
}
}
return(kgeno)
}
##############
ikgeno <- get_ik(path="largedata/bode/ik", pattern="kid_geno")
#library(imputeR)
library(data.table, lib="~/bin/Rlib/")
imp53 <- read.csv("largedata/bode/ip53_imputed.csv")
names(imp53) <- gsub("\\.", ":", names(imp53))
if(sum(ikgeno$snpid != row.names(imp53)) > 0) stop("!")
ipgeno <- merge(imp53, ikgeno, by.x="row.names", by.y="snpid", sort=FALSE)
names(ipgeno)[1] <- "snpid"
names(ipgeno) <- gsub("\\.", ":", names(ipgeno))
names(ipgeno) <- gsub("^X", "", names(ipgeno))
write.table(ipgeno, "largedata/landrace_imputeR_01232016.txt", sep="\t",
row.names=FALSE, quote=FALSE)
|
a3c14298d96055e7b1048cce5ee35774f9462496
|
e2f37b60e1cd4fdf9c002cd267a79f2881b248dd
|
/inst/examples/plots.R
|
4defeb34a58399cd8c8c97c278c5830c0d301ee2
|
[
"CC0-1.0"
] |
permissive
|
cboettig/pdg_control
|
8b5ac745a23da2fa7112c74b93765c72974ea9b9
|
d29c5735b155d1eb48b5f8b9d030479c7ec75754
|
refs/heads/master
| 2020-04-06T03:40:50.205377
| 2017-10-17T02:47:24
| 2017-10-17T02:47:24
| 2,390,280
| 7
| 2
| null | null | null | null |
UTF-8
|
R
| false
| false
| 3,229
|
r
|
plots.R
|
# file plots.R
# author Carl Boettiger, <cboettig@gmail.com>
# date 2011-11-16
# creates extra plots accompanying Reed.R
# for stat plots
require(ggplot2)
require(Hmisc)
require(pdgControl)
## FIXME Once standardized, all these plots should become package fns
## Reshape and summarize data ###
dat <- melt(sims, id="time") # reshapes the data matrix to "long" form
# some stats on the replicates, (stat_sumary can do this instead)
m <- cast(dat, time ~ variable, mean) # mean population
err <- cast(dat, time ~ variable, sd) # sd population
## Show dynamics of a single replicate
ex <- sample(1:100,1) # a random replicate
p0 <- ggplot(dat) +
geom_line(aes(time, value, color = variable),
data = subset(dat, L1 == ex)) +
geom_abline(intercept = opt$S, slope = 0, col = "darkred") + # show Reed's S: optimal escapement
geom_abline(intercept = xT, slope = 0, lty = 2) #+ # show Allee threshold
#print(p0)
p1 <- plot_replicates(sims)
## Update the main p1 plot to
## make the crashed trajectories stand out?
#p1 <- p1 + geom_line(aes(time, value, group = L1),
# data = subset(dat, variable == "harvest" &
# (L1 %in% optimal_crashed$L1)), col = "darkgreen", alpha = 0.5) +
# geom_line(aes(time, value, group = L1),
# data = subset(dat, variable == "fishstock" &
# (L1 %in% optimal_crashed$L1)), col = "darkblue", alpha = 0.5)
#### p2 Plots the unharvested dynamics ###
crashed = subset(dat, variable =="unharvested" & time == OptTime - 1 & value < xT)
p2 <- ggplot(data = subset(dat, variable == "unharvested"),
aes(time, value, group = L1)) + geom_line(alpha = 0.2) +
# shows the mean +/- mult * sd , requires Hmisc
stat_summary(mapping = aes(group = 1), fun.data = mean_sdl,
geom = "smooth", mult = 1) +
opts(title=sprintf("Unfished dynamics, %d populations crash", dim(crashed)[1]))
## Profits plot #######
p3 <- ggplot(subset(dat, variable == "harvest"),
aes(time, profit(value, K), group = L1)) +
geom_line(alpha = .2) +
labs(x = "Time (yrs)", y = "Profit") +
stat_summary(fun.data = mean_sdl,
geom = "smooth", mapping = aes(group = 1),
lwd = 1, col = "darkred", mult = 1)
# fun.data should be used for functions that give mean+sd back
# otherwise, use fun.y = mean, fun.ymin =
# profits for each rep, by timestep
require(plyr)
cash <- ddply(subset(dat, variable == "harvest"), "L1",
function(df) profit(dat$variable, K))
require(data.table)
DT <- data.table(dat)
DT[, profit
# add mean line by hand
# p3 <- p3+geom_line(aes(time,rowMeans(cash))) # average profit made as function of time
p4 <- qplot(colSums(cash), xlab="Total Profit", ylab=NULL) + # histogram of total profit made
geom_vline(xintercept=mean(colSums(cash))) + # expected total profit
opts(plot.margin=unit(rep(0,4), "lines")) + theme_gray(9) #appearances
subvp <- viewport(width=.3, height=.3, x=.8, y=.8)
#png("profit.png")
#print(p3)
#print(p4, vp=subvp)
#dev.off()
#ggsave("samplerun.png", plot=p0)
#ggsave("fished.png", plot=p1)
#ggsave("unfished.png", plot=p2)
#require(socialR)
#upload("profit.png samplerun.png fished.png unfished.png", script="Reed.R", tag="PDG_Control")
|
072218ce67cb9a3b7f45d8f6d186c16931646936
|
2b106b4488e294b561de4cdd8492d5341229d6d4
|
/man/zoom_mat.Rd
|
738a6eee491967ae5236e9281508bc0b6a69099e
|
[
"Apache-2.0"
] |
permissive
|
ysnghr/fastai
|
120067fcf5902b3e895b1db5cd72d3b53f886682
|
b3953ad3fd925347362d1c536777e935578e3dba
|
refs/heads/master
| 2022-12-15T17:04:53.154509
| 2020-09-09T18:39:31
| 2020-09-09T18:39:31
| 292,399,169
| 0
| 0
|
Apache-2.0
| 2020-09-09T18:34:06
| 2020-09-02T21:32:58
|
R
|
UTF-8
|
R
| false
| true
| 529
|
rd
|
zoom_mat.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/vision_augment.R
\name{zoom_mat}
\alias{zoom_mat}
\title{zoom_mat}
\usage{
zoom_mat(
x,
min_zoom = 1,
max_zoom = 1.1,
p = 0.5,
draw = NULL,
draw_x = NULL,
draw_y = NULL,
batch = FALSE
)
}
\arguments{
\item{x}{x}
\item{min_zoom}{min_zoom}
\item{max_zoom}{max_zoom}
\item{p}{p}
\item{draw}{draw}
\item{draw_x}{draw_x}
\item{draw_y}{draw_y}
\item{batch}{batch}
}
\description{
Return a random zoom matrix with `max_zoom` and `p`
}
|
932a7eddfbc5d15b41bb619b29ace1c21700e56c
|
29585dff702209dd446c0ab52ceea046c58e384e
|
/Rvcg/R/vcgIsosurface.r
|
1fdffd374cf32782140620386b1c1fe1faaf6fd8
|
[] |
no_license
|
ingted/R-Examples
|
825440ce468ce608c4d73e2af4c0a0213b81c0fe
|
d0917dbaf698cb8bc0789db0c3ab07453016eab9
|
refs/heads/master
| 2020-04-14T12:29:22.336088
| 2016-07-21T14:01:14
| 2016-07-21T14:01:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 3,612
|
r
|
vcgIsosurface.r
|
#' Create Isosurface from 3D-array
#'
#' Create Isosurface from 3D-array using Marching Cubes algorithm
#'
#' @param vol an integer valued 3D-array
#' @param threshold threshold for creating the surface
#' @param spacing numeric 3D-vector: specifies the voxel dimensons in x,y,z direction.
#' @param origin numeric 3D-vector: origin of the original data set, will transpose the mesh onto that origin.
#' @param direction a 3x3 direction matrix
#' @param IJK2RAS 4x4 IJK2RAS transformation matrix
#' @param as.int logical: if TRUE, the array will be stored as integer (might decrease RAM usage)
#'
#' @return returns a triangular mesh of class "mesh3d"
#' @examples
#' #this is the example from the package "misc3d"
#' x <- seq(-2,2,len=50)
#' g <- expand.grid(x = x, y = x, z = x)
#' v <- array(g$x^4 + g$y^4 + g$z^4, rep(length(x),3))
#' storage.mode(v) <- "integer"
#' \dontrun{
#' mesh <- vcgIsosurface(v,threshold=10)
#' require(rgl)
#' wire3d(mesh)
#' ##now smooth it a little bit
#' wire3d(vcgSmooth(mesh,"HC",iteration=3),col=3)
#' }
#' @export
vcgIsosurface <- function(vol,threshold,spacing=NULL, origin=NULL,direction=NULL,IJK2RAS=diag(c(-1,-1,1,1)),as.int=FALSE) {
if (length(dim(vol)) != 3)
stop("3D array needed")
mirr <- FALSE
mvol <- max(vol)
minvol <- min(vol)
if (threshold == mvol)
threshold <- threshold-1e-5
else if (threshold > mvol || threshold < minvol)
stop("threshold is outside volume values")
if (as.int)
storage.mode(vol) <- "integer"
volmesh <- .Call("RMarchC",vol,threshold)
rm(vol)
gc()
volmesh$vb <- rbind(volmesh$vb,1)
volmesh$it <- volmesh$it
if (!is.null(origin))
origin <- as.vector(applyTransform(t(origin),IJK2RAS))
class(volmesh) <- "mesh3d"
if (!is.null(spacing))
volmesh$vb[1:3,] <- volmesh$vb[1:3,]*spacing
if (!is.null(direction)) {
IJK2RAS <- cbind(rbind(direction,0),c(0,0,0,1))%*%IJK2RAS
if (det(direction) < 0)
mirr <- TRUE
}
volmesh <- applyTransform(volmesh,IJK2RAS)
if (!is.null(origin))
volmesh$vb[1:3,] <- volmesh$vb[1:3,]+origin
if (mirr)
volmesh <- invertFaces(volmesh)
if (!checkNormOrient(volmesh))
volmesh <- invertFaces(volmesh)
return(volmesh)
}
###helpers imported from Morpho
invertFaces <- function (mesh) {
mesh$it <- mesh$it[c(3, 2, 1), ]
mesh <- vcgUpdateNormals(mesh)
return(mesh)
}
applyTransform <- function(x,trafo,inverse)UseMethod("applyTransform")
applyTransform.matrix <- function(x,trafo,inverse=FALSE) {
if (is.matrix(trafo)) {
if (ncol(trafo) == 3 && ncol(x) ==3)
trafo <- mat3x3tomat4x4(trafo)
if (inverse)
trafo <- solve(trafo)
out <-homg2mat(trafo%*%mat2homg(x))
} else {
stop("trafo must be a matrix")
}
return(out)
}
applyTransform.mesh3d <- function(x,trafo,inverse=FALSE) {
x$vb[1:3,] <- t(applyTransform(t(x$vb[1:3,]),trafo,inverse = inverse))
## case affine transformation
reflect <- FALSE
if (is.matrix(trafo)) {
if (det(trafo) < 0)
reflect <- TRUE
} else {
stop("trafo must be a matrix")
}
if (reflect) {
x <- invertFaces(x)
}
if (!is.null(x$normals))
x <- vcgUpdateNormals(x)
return(x)
}
mat3x3tomat4x4 <- function(x) {
n <- ncol(x)
x <- rbind(cbind(x,0),0);x[n+1,n+1] <-1
return(x)
}
mat2homg <- function(x) {
x <- rbind(t(x),1)
return(x)
}
homg2mat <- function(x) {
m <- nrow(x)
x <- t(x[1:(m-1),])
return(x)
}
|
50f17fa60bbf09ced6d6df84553261ea82d7207c
|
2c6465921e8d18a9133cd61727765dd7a07beaea
|
/Simulation Gestational Diabetes WHO/rotina_simulacao_20120909.r
|
30bd64d07691b03abd04f7ecfc1848da1f726ee0
|
[
"MIT"
] |
permissive
|
isix/Othprojects
|
ea260b2b91a1e5880b98b382432c09614cf69b5a
|
f53c443e3314a0097f2abd9b872dd45d55e8e275
|
refs/heads/master
| 2020-03-08T08:04:38.878648
| 2018-06-20T04:32:01
| 2018-06-20T04:32:01
| 128,011,680
| 0
| 0
| null | null | null | null |
ISO-8859-1
|
R
| false
| false
| 20,604
|
r
|
rotina_simulacao_20120909.r
|
setwd("C:/Maicon/20120907")
# Settings
n <- 1000000 ;
alfa <- 0.05
# The Beta distribution with parameters shape1 = a and shape2 = b has density
#
# G(a+b)/(G(a)G(b))x^(a-1)(1-x)^(b-1)
#
# for a > 0, b > 0 and 0 = x = 1 where the boundary values at x=0 or x=1 are defined as by continuity (as limits).
# The mean is a/(a+b) and the variance is ab/((a+b)^2 (a+b+1)).
# Given a and b, return a array with mean, variance, deviation, lower endpoint and upper endpoint of the 100(1-alfa)% confidence interval for Beta distribution.
beta.parametros <- function(a, b, alfa, digits = 5) {
media <- a / (a+b)
variancia <- (a * b)/ ( (a+b)^2 * (a+b+1) )
liminf <- qbeta(alfa/2, a, b)
limsup <- qbeta(1 - alfa/2, a, b)
return( round( c("Mean"=media,"Var"=variancia,"SD"=variancia^.5, "LL"=liminf, "UL"=limsup) , digits=5) )
}
# Example :
beta.parametros(3, 6, alfa)
# Set RNG seed
set.seed(37589411)
# Values for PWHO
# PWHO <- seq(0.05,0.15,0.01)
PWHO <- 0.05
# Simulated parameters values
# LGA Birth (LGA)
LGA_Iwho_negative <- rbeta(n, 1.5*900, 1.5*9100 ) ; c <- 1.5; beta.parametros(c*900, 9100*c, alfa)
LGA_logRRwho <- rnorm(n, 0.4256, 0.0494) ; # Distribution for log(RR)
LGA_Ptreatment <- rbeta(n, 40.5, 4.5 ) ; c <- 4.5; beta.parametros(9*c, 1*c, alfa) # approximated solution
LGA_logRPiadpsg <- rnorm(n, 0.4055, 0.0730) ; # Distribution for log(RP)
LGA_logRRtreatment <- rnorm(n, -0.6095, 0.1245) ; # Distribution for log(RR)
LGA_logRRiadpsg <- rnorm(n, 0.5503, 0.1558) ; # Distribution for log(RR)
# Preeclampsia (PE)
PE_Iwho_negative <- rbeta(n, 22.5, 477.5 ) ; c <- 0.5; beta.parametros(c*45, c*955, alfa)
PE_logRRwho <- rnorm(n, 0.5260, 0.1288) ; # Distribution for log(RR)
PE_Ptreatment <- rbeta(n, 40.5, 4.5 ) ; c <- 4.5; beta.parametros(9*c, 1*c, alfa) # approximated solution
PE_logRPiadpsg <- rnorm(n, 0.4055, 0.0730) ; # Distribution for log(RP)
PE_logRRtreatment <- rnorm(n, -0.4903, 0.1413) ; # Distribution for log(RR)
PE_logRRiadpsg <- rnorm(n, 0.5374, 0.1108) ; # Distribution for log(RR)
# Caesarean section (CS)
CS_Iwho_negative <- rbeta(n, 11.7475, 51.7525 ) ; beta.parametros(11.7475, 51.7525, alfa)
CS_logRRwho <- rnorm(n, 0.3144, 0.0508) ; # Distribution for log(RR)
CS_Ptreatment <- rbeta(n, 40.5, 4.5 ) ; c <- 4.5; beta.parametros(9*c, 1*c, alfa) # approximated solution
CS_logRPiadpsg <- rnorm(n, 0.4055, 0.0730) ; # Distribution for log(RP)
CS_logRRtreatment <- rnorm(n, -0.1100, 0.0797) ; # Distribution for log(RR)
CS_logRRiadpsg <- rnorm(n, 0.2086, 0.1035) ; # Distribution for log(RR)
# Set simulated block
set.idiaf <- function( PWHO, Iwho_negative, logRRwho, Ptreatment, logRRtreatment, logRPiadpsg, logRRiadpsg) {
IDIAF <- ( ( PWHO * Iwho_negative * exp(logRRwho) ) ) + ( ( 1 - PWHO ) * Iwho_negative ) / ( (1 - ( PWHO * exp(logRPiadpsg) ) ) + ( exp(logRRiadpsg) * PWHO * exp(logRPiadpsg) ) )
return(IDIAF)
}
# Functions for model simulation
simula.nao.rastrear <- function ( n , PWHO, Iwho_negative, logRRwho, Ptreatment, logRRtreatment, logRPiadpsg, logRRiadpsg) {
Iwho_positive <- Iwho_negative * exp(logRRwho) # Iwho_positive = Iwho_negative * RRwho
ans <- (
( PWHO * Iwho_positive ) + ( ( 1 - PWHO ) * Iwho_negative )
)
return(ans)
}
simula.who <- function ( n , PWHO, Iwho_negative, logRRwho, Ptreatment, logRRtreatment, logRPiadpsg, logRRiadpsg) {
Iwho_positive <- Iwho_negative * exp(logRRwho)
ans <- (
( ( 1 - PWHO ) * Iwho_negative ) +
( PWHO * ( 1 - Ptreatment ) * Iwho_positive ) +
( PWHO * Ptreatment * exp(logRRtreatment) * Iwho_positive )
)
return(ans)
}
simula.iadpsg <- function ( n , PWHO, Iwho_negative, logRRwho, Ptreatment, logRRtreatment, logRPiadpsg, logRRiadpsg) {
Piadpsg <- PWHO * exp(logRPiadpsg) # Piadpsg = Pwho * PRiadpsg
Iiadpsg_negative <- ( ( PWHO * Iwho_negative * exp(logRRwho) ) +
( ( 1 - PWHO) * Iwho_negative ) ) / ( ( ( 1 - (PWHO * exp(logRPiadpsg) ) ) ) +
( PWHO * exp(logRPiadpsg) * exp(logRRiadpsg) ) )
Iiadpsg_positive <- Iiadpsg_negative * exp(logRRiadpsg)
ans <- (
( ( 1 - Piadpsg ) * Iiadpsg_negative ) +
( Piadpsg * Iiadpsg_positive * Ptreatment * exp(logRRtreatment) ) +
( Piadpsg * Iiadpsg_positive * ( 1 - Ptreatment ) )
)
return(ans)
}
# Looping PWHO values
datasummary <- array(,10)
datasummary.diff <- array(,10)
datasummary.table.diff <- array(,3)
names(datasummary) <- c("PWHO", "Strategy", "Min.", "1st Qu.", "Median", "Mean", "3rd Qu.", "Max.")
names(datasummary.diff) <- c("PWHO", "Strategy", "Min.", "1st Qu.", "Median", "Mean", "3rd Qu.", "Max.")
for ( i in PWHO ) {
arrayPWHO <- rep(i, n)
# Compute values for each screening strategies
resultados.IADPSG.LGA <- simula.iadpsg( n , arrayPWHO, LGA_Iwho_negative, LGA_logRRwho, LGA_Ptreatment, LGA_logRRtreatment, LGA_logRPiadpsg, LGA_logRRiadpsg)
resultados.IADPSG.PE <- simula.iadpsg( n , arrayPWHO, PE_Iwho_negative, PE_logRRwho, PE_Ptreatment, PE_logRRtreatment, PE_logRPiadpsg, PE_logRRiadpsg)
resultados.IADPSG.CS <- simula.iadpsg( n , arrayPWHO, CS_Iwho_negative, CS_logRRwho, CS_Ptreatment, CS_logRRtreatment, CS_logRPiadpsg, CS_logRRiadpsg)
resultados.NR.LGA <- simula.nao.rastrear( n , arrayPWHO, LGA_Iwho_negative, LGA_logRRwho, LGA_Ptreatment, LGA_logRRtreatment, LGA_logRPiadpsg, LGA_logRRiadpsg)
resultados.NR.PE <- simula.nao.rastrear( n , arrayPWHO, PE_Iwho_negative, PE_logRRwho, PE_Ptreatment, PE_logRRtreatment, PE_logRPiadpsg, PE_logRRiadpsg)
resultados.NR.CS <- simula.nao.rastrear( n , arrayPWHO, CS_Iwho_negative, CS_logRRwho, CS_Ptreatment, CS_logRRtreatment, CS_logRPiadpsg, CS_logRRiadpsg)
resultados.WHO.LGA <- simula.who( n , arrayPWHO, LGA_Iwho_negative, LGA_logRRwho, LGA_Ptreatment, LGA_logRRtreatment, LGA_logRPiadpsg, LGA_logRRiadpsg)
resultados.WHO.PE <- simula.who( n , arrayPWHO, PE_Iwho_negative, PE_logRRwho, PE_Ptreatment, PE_logRRtreatment, PE_logRPiadpsg, PE_logRRiadpsg)
resultados.WHO.CS <- simula.who( n , arrayPWHO, CS_Iwho_negative, CS_logRRwho, CS_Ptreatment, CS_logRRtreatment, CS_logRPiadpsg, CS_logRRiadpsg)
resultado.final <- data.frame(
"PWHO" = arrayPWHO,
"NR.LGA" = resultados.NR.LGA,
"NR.PE" = resultados.NR.PE,
"NR.CS" = resultados.NR.CS,
"WHO.LGA" = resultados.WHO.LGA,
"WHO.PE" = resultados.WHO.PE,
"WHO.CS" = resultados.WHO.CS,
"IADPSG.LGA" = resultados.IADPSG.LGA,
"IADPSG.PE" = resultados.IADPSG.PE,
"IADPSG.CS" = resultados.IADPSG.CS
)
write.csv2( resultado.final , paste("table_data_PWHO_", i,".csv", sep="") )
# Compute differences
Delta.NR.WHO.LGA <- resultados.NR.LGA - resultados.WHO.LGA
Delta.NR.IADPSG.LGA <- resultados.NR.LGA - resultados.IADPSG.LGA
Delta.WHO.IADPSG.LGA <- resultados.WHO.LGA - resultados.IADPSG.LGA
Delta.NR.WHO.PE <- resultados.NR.PE - resultados.WHO.PE
Delta.NR.IADPSG.PE <- resultados.NR.PE - resultados.IADPSG.PE
Delta.WHO.IADPSG.PE <- resultados.WHO.PE - resultados.IADPSG.PE
Delta.NR.WHO.CS <- resultados.NR.CS - resultados.WHO.CS
Delta.NR.IADPSG.CS <- resultados.NR.CS - resultados.IADPSG.CS
Delta.WHO.IADPSG.CS <- resultados.WHO.CS - resultados.IADPSG.CS
# Compute p-values empirical # Pr { standart strategy > alternative strategy }
comptype <- c("NR.WHO.LGA","NR.IADPSG.LGA","WHO.IADPSG.LGA","NR.WHO.PE","NR.IADPSG.PE","WHO.IADPSG.PE","NR.WHO.CS","NR.IADPSG.CS","WHO.IADPSG.CS")
resultados.pvalue <- array(,0)
for (i in comptype) {
ans <- c(i, eval(parse(text=paste("sum( ifelse(Delta.",i ," < 0 , 1, 0) ) / n",sep=""))) )
resultados.pvalue <- rbind(resultados.pvalue, ans)
print( ans )
}
write.csv2( resultados.pvalue , paste("Summary_pvalues.csv", sep=""))
# NNS for screening strategies
NNS.Delta.NR.WHO.LGA <- 1 / Delta.NR.WHO.LGA
NNS.Delta.NR.IADPSG.LGA <- 1 / Delta.NR.IADPSG.LGA
NNS.Delta.WHO.IADPSG.LGA <- 1 / Delta.WHO.IADPSG.LGA
NNS.Delta.NR.WHO.PE <- 1 / Delta.NR.WHO.PE
NNS.Delta.NR.IADPSG.PE <- 1 / Delta.NR.IADPSG.PE
NNS.Delta.WHO.IADPSG.PE <- 1 / Delta.WHO.IADPSG.PE
NNS.Delta.NR.WHO.CS <- 1 / Delta.NR.WHO.CS
NNS.Delta.NR.IADPSG.CS <- 1 / Delta.NR.IADPSG.CS
NNS.Delta.WHO.IADPSG.CS <- 1 / Delta.WHO.IADPSG.CS
# Compute binary variables for proportions
Bin.Delta.NR.WHO.LGA <- ifelse(Delta.NR.WHO.LGA > 0, 1, 0)
Bin.Delta.NR.IADPSG.LGA <- ifelse(Delta.NR.IADPSG.LGA > 0, 1, 0)
Bin.Delta.WHO.IADPSG.LGA <- ifelse(Delta.WHO.IADPSG.LGA > 0, 1, 0)
Bin.Delta.NR.WHO.PE <- ifelse(Delta.NR.WHO.PE > 0, 1, 0)
Bin.Delta.NR.IADPSG.PE <- ifelse(Delta.NR.IADPSG.PE > 0, 1, 0)
Bin.Delta.WHO.IADPSG.PE <- ifelse(Delta.WHO.IADPSG.PE > 0, 1, 0)
Bin.Delta.NR.WHO.CS <- ifelse(Delta.NR.WHO.CS > 0, 1, 0)
Bin.Delta.NR.IADPSG.CS <- ifelse(Delta.NR.IADPSG.CS > 0, 1, 0)
Bin.Delta.WHO.IADPSG.CS <- ifelse(Delta.WHO.IADPSG.CS > 0, 1, 0)
comptype <- c("NR.WHO.LGA","NR.IADPSG.LGA","WHO.IADPSG.LGA","NR.WHO.PE","NR.IADPSG.PE","WHO.IADPSG.PE","NR.WHO.CS","NR.IADPSG.CS","WHO.IADPSG.CS")
for (i in comptype) {
ans <- eval(parse(text=paste("table(Bin.Delta.",i,")",sep="")))
print(ans)
if ( length(ans) < 2 ) ans <- c("0" = 0, ans[1] )
datasummary.table.diff <- rbind( datasummary.table.diff, as.array(c(i,ans)) )
}
# Save data
datasummary.table.diff <- datasummary.table.diff[ !is.na(datasummary.table.diff[,1]) ,]
datasummary.table.diff <- data.frame(
"Comparação" = as.character(datasummary.table.diff[,1]),
"Freq 0" = as.numeric(as.character(datasummary.table.diff[,2])),
"Freq 1" = as.numeric(as.character(datasummary.table.diff[,3])),
"Fr 0" = (100 * (as.numeric(as.character(datasummary.table.diff[,2])) / n )),
"Fr 1" = (100 * (as.numeric(as.character(datasummary.table.diff[,3])) / n ))
)
write.csv2( datasummary.table.diff , "Statistics_Binary_Comparison.csv", row.names=FALSE )
resultado.final.diff <- data.frame(
"PWHO" = arrayPWHO,
"NR vs WHO - LGA" = Delta.NR.WHO.LGA,
"NR vs IADPSG - LGA" = Delta.NR.IADPSG.LGA,
"WHO vs IADPSG - LGA" = Delta.WHO.IADPSG.LGA,
"NR vs WHO - PE" = Delta.NR.WHO.PE,
"NR vs IADPSG - PE" = Delta.NR.IADPSG.PE,
"WHO vs IADPSG - PE" = Delta.WHO.IADPSG.PE,
"NR vs WHO - CS" = Delta.NR.WHO.CS,
"NR vs IADPSG - CS" = Delta.NR.IADPSG.CS,
"WHO vs IADPSG - CS" = Delta.WHO.IADPSG.CS
)
write.csv2( resultado.final.diff , paste("table_data_Differences_PWHO_", i,".csv", sep=""), row.names=FALSE )
# Compute summary tables
datasummary <- rbind( datasummary, c( i, "NR.LGA", c(summary(resultado.final$"NR.LGA",)) ,
quantile(resultado.final$"NR.LGA", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "NR.PE", c(summary(resultado.final$"NR.PE")) ,
quantile(resultado.final$"NR.LGA", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "NR.CS", c(summary(resultado.final$"NR.CS")) ,
quantile(resultado.final$"NR.LGA", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "WHO.LGA", c(summary(resultado.final$"WHO.LGA")) ,
quantile(resultado.final$"WHO.LGA", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "WHO.PE", c(summary(resultado.final$"WHO.PE")) ,
quantile(resultado.final$"WHO.PE", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "WHO.CS", c(summary(resultado.final$"WHO.CS")) ,
quantile(resultado.final$"WHO.CS", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "IADPSG.LGA", c(summary(resultado.final$"IADPSG.LGA")) ,
quantile(resultado.final$"IADPSG.LGA", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "IADPSG.PE", c(summary(resultado.final$"IADPSG.PE")) ,
quantile(resultado.final$"IADPSG.PE", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary <- rbind( datasummary, c( i, "IADPSG.CS", c(summary(resultado.final$"IADPSG.CS")) ,
quantile(resultado.final$"IADPSG.CS", probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
# Compute summary tables for differences
datasummary.diff <- rbind( datasummary.diff, c( i, "NR vs WHO - LGA", c(summary(Delta.NR.WHO.LGA)) ,
quantile(Delta.NR.WHO.LGA, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary.diff <- rbind( datasummary.diff, c( i, "NR vs IADPSG - LGA", c(summary(Delta.NR.IADPSG.LGA)) ,
quantile(Delta.NR.IADPSG.LGA, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
# Compute summary : screening strategies WHO vs IADPSG for LGA
datasummary.diff <- rbind( datasummary.diff, c( i, "WHO vs IADPSG - LGA", c(summary(Delta.WHO.IADPSG.LGA)) ,
quantile(Delta.WHO.IADPSG.LGA, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary.diff <- rbind( datasummary.diff, c( i, "NR vs WHO - PE", c(summary(Delta.NR.WHO.PE)) ,
quantile(Delta.NR.WHO.PE, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary.diff <- rbind( datasummary.diff, c( i, "NR vs IADPSG - PE", c(summary(Delta.NR.IADPSG.PE)) ,
quantile(Delta.NR.IADPSG.PE, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
# Compute summary : screening strategies WHO vs IADPSG for PE
datasummary.diff <- rbind( datasummary.diff, c( i, "WHO vs IADPSG - PE", c(summary(Delta.WHO.IADPSG.PE)) ,
quantile(Delta.WHO.IADPSG.PE, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary.diff <- rbind( datasummary.diff, c( i, "NR vs WHO - CS", c(summary(Delta.NR.WHO.CS)) ,
quantile(Delta.NR.WHO.CS, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
datasummary.diff <- rbind( datasummary.diff, c( i, "NR vs IADPSG - CS", c(summary(Delta.NR.IADPSG.CS)) ,
quantile(Delta.NR.IADPSG.CS, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
# Compute summary : screening strategies WHO vs IADPSG for CS
datasummary.diff <- rbind( datasummary.diff, c( i, "WHO vs IADPSG - CS", c(summary(Delta.WHO.IADPSG.CS)) ,
quantile(Delta.WHO.IADPSG.CS, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
}
# Save summary data
datasummary <- datasummary[ !is.na(datasummary[,1]) ,]
datasummary.diff <- datasummary.diff[ !is.na(datasummary.diff[,1]) ,]
datasummary <- data.frame(datasummary)
names(datasummary) <- c(names(datasummary)[1:(length(names(datasummary))-2)],
paste("Percentil ",round((alfa/2)*100, digits=1),sep=""), paste("Percentil ",round((1-alfa/2)*100, digits=1),sep=""))
datasummary.diff <- data.frame(datasummary.diff)
names(datasummary.diff) <- c(names(datasummary.diff)[1:(length(names(datasummary))-2)],
paste("Percentil ",round((alfa/2)*100, digits=1),sep=""), paste("Percentil ",round((1-alfa/2)*100, digits=1),sep=""))
write.csv2( datasummary , paste("Summary_statistics.csv", sep=""), row.names=FALSE )
write.csv2( datasummary.diff , paste("Summary_statistics_for_differences.csv", sep=""), row.names=FALSE )
# Summary - distribution - Compute the Highest Posterior Density Interval (HPD)
require(hdrcde)
require(boa)
comptype <- c("NR.LGA","NR.PE","NR.CS","WHO.LGA","WHO.PE","WHO.CS","IADPSG.LGA","IADPSG.PE","IADPSG.CS")
for (i in comptype) {
print(paste("Computing HPD Interval for ",i,sep=""))
graphname <- paste("grafico_",i,".png", sep="")
png(file.path(paste(getwd(),"//saida", sep=""),graphname))
ans <- hdr.den(resultado.final[,i])
dev.off()
# Using boa package
ans <- boa.hpd(resultado.final[,i], alpha = 0.05)
write.csv2( ans , paste("HPD ",i,".csv", sep=""))
print( ans )
}
comptype <- c("NR.WHO.LGA","NR.IADPSG.LGA","WHO.IADPSG.LGA","NR.WHO.PE","NR.IADPSG.PE","WHO.IADPSG.PE","NR.WHO.CS","NR.IADPSG.CS","WHO.IADPSG.CS")
for (i in comptype) {
print(paste("Computing HPD Interval for Difference ",i,sep=""))
graphname <- paste("grafico_IDiff_",i,".png", sep="")
png(file.path(paste(getwd(),"//saida", sep=""),graphname))
ans <- eval(parse(text=paste("hdr.den(Delta.",i,")",sep="")))
dev.off()
# Using boa package
ans <- eval(parse(text=paste("boa.hpd(Delta.",i,", alpha = 0.05)",sep="")))
write.csv2( ans , paste("HPD Diff ",i,".csv", sep=""))
print( ans )
}
comptype <- c("NR.WHO.LGA","NR.IADPSG.LGA","WHO.IADPSG.LGA","NR.WHO.PE","NR.IADPSG.PE","WHO.IADPSG.PE","NR.WHO.CS","NR.IADPSG.CS","WHO.IADPSG.CS")
for (i in comptype) {
print(paste("Computing HPD Interval for NNS",i,sep=""))
graphname <- paste("grafico_NNS_Diff_",i,".png", sep="")
png(file.path(paste(getwd(),"//saida", sep=""),graphname))
ans <- eval(parse(text=paste("plot(density(NNS.Delta.",i,"))",sep="")))
dev.off()
# Using boa package
ans <- eval(parse(text=paste("boa.hpd(NNS.Delta.",i,", alpha = 0.05)",sep="")))
write.csv2( ans , paste("HPD Diff ",i,".csv", sep=""))
print( ans )
}
###############################
# Sensitivity analysis - HAPO #
###############################
# Screening strategies settings
LGA_Ptreatment <- rbeta(n, 40.5, 4.5 ) ; c <- 4.5; beta.parametros(9*c, 1*c, alfa) # melhor solução encontrada
LGA_logRRtreatment <- rnorm(n, -0.6095, 0.1245) ; # A distribuição de log(RR)
PE_Ptreatment <- rbeta(n, 40.5, 4.5 ) ; c <- 4.5; beta.parametros(9*c, 1*c, alfa) # melhor solução encontrada
PE_logRRtreatment <- rnorm(n, -0.4903, 0.1413) ; # A distribuição de log(RR)
CS_Ptreatment <- rbeta(n, 40.5, 4.5 ) ; c <- 4.5; beta.parametros(9*c, 1*c, alfa) # melhor solução encontrada
CS_logRRtreatment <- rnorm(n, -0.1100, 0.0797) ; # A distribuição de log(RR)
# Common parameters settings
Pwho_HAPO <- 0.114
Piadpsg_HAPO <- 0.161
LGA_Iwhopos_HAPO <- 0.137
PE_Iwhopos_HAPO <- 0.076
CS_Iwhopos_HAPO <- 0.244
LGA_Iiadpsgpos_HAPO <- 0.162
PE_Iiadpsgpos_HAPO <- 0.091
CS_Iiadpsgpos_HAPO <- 0.244
# Compute incidence reduction - WHO
RI_LGA_WHO <- Pwho_HAPO * LGA_Iwhopos_HAPO * LGA_Ptreatment * (1-exp(LGA_logRRtreatment))
NNS_LGA_WHO <- 1 / RI_LGA_WHO
RI_PE_WHO <- Pwho_HAPO * PE_Iwhopos_HAPO * PE_Ptreatment * (1-exp(PE_logRRtreatment))
NNS_PE_WHO <- 1 / RI_PE_WHO
RI_CS_WHO <- Pwho_HAPO * CS_Iwhopos_HAPO * CS_Ptreatment * (1-exp(CS_logRRtreatment))
NNS_CS_WHO <- 1 / RI_CS_WHO
# Compute incidence reduction - IADPSG
RI_LGA_IADPSG <- Piadpsg_HAPO * LGA_Iiadpsgpos_HAPO * LGA_Ptreatment * (1-exp(LGA_logRRtreatment))
NNS_LGA_IADPSG <- 1 / RI_LGA_IADPSG
RI_PE_IADPSG <- Piadpsg_HAPO * PE_Iiadpsgpos_HAPO * PE_Ptreatment * (1-exp(PE_logRRtreatment))
NNS_PE_IADPSG <- 1 / RI_PE_IADPSG
RI_CS_IADPSG <- Piadpsg_HAPO * CS_Iiadpsgpos_HAPO * CS_Ptreatment * (1-exp(CS_logRRtreatment))
NNS_CS_IADPSG <- 1 / RI_CS_IADPSG
# Save data
resultado.final.sa <- data.frame(
"RI_LGA_WHO" = RI_LGA_WHO,
"NNS_LGA_WHO" = NNS_LGA_WHO,
"RI_PE_WHO" = RI_PE_WHO,
"NNS_PE_WHO" = NNS_PE_WHO,
"RI_CS_WHO" = RI_CS_WHO,
"NNS_CS_WHO" = NNS_CS_WHO,
"RI_LGA_IADPSG" = RI_LGA_IADPSG,
"NNS_LGA_IADPSG" = NNS_LGA_IADPSG,
"RI_PE_IADPSG" = RI_PE_IADPSG,
"NNS_PE_IADPSG" = NNS_PE_IADPSG,
"RI_CS_IADPSG" = RI_CS_IADPSG,
"NNS_CS_IADPSG" = NNS_CS_IADPSG
)
write.csv2( resultado.final.sa , "table_data_sensitivity analysis.csv" )
# Compute summary tables
tabela.resumo.sa <- array(,9)
vet.nomeselementos <- c("RI_LGA_WHO","NNS_LGA_WHO","RI_PE_WHO","NNS_PE_WHO","RI_CS_WHO","NNS_CS_WHO",
"RI_LGA_IADPSG", "NNS_LGA_IADPSG", "RI_PE_IADPSG", "NNS_PE_IADPSG", "RI_CS_IADPSG", "NNS_CS_IADPSG")
for (i in vet.nomeselementos) {
ans <- eval(parse(text=i))
tabela.resumo.sa <- rbind( tabela.resumo.sa, c( i, summary(ans), quantile(ans, probs = c(alfa/2, 1 - alfa/2), names = FALSE ) ) )
}
tabela.resumo.sa <- tabela.resumo.sa[ !is.na(tabela.resumo.sa[,1]) ,]
tabela.resumo.sa <- data.frame(tabela.resumo.sa)
names(tabela.resumo.sa) <- c("Estatística/Estratégia", names(tabela.resumo.sa)[2:(length(names(tabela.resumo.sa))-2)],
paste("Percentil ",round((alfa/2)*100, digits=1),sep=""), paste("Percentil ",round((1-alfa/2)*100, digits=1),sep=""))
write.csv2( tabela.resumo.sa , paste("Summary_AS_HAPO.csv", sep=""), row.names=FALSE )
# Summary - Highest Posterior Density Interval (HPD)
vet.nomeselementos1 <- c("RI_LGA_WHO","RI_PE_WHO","RI_CS_WHO","RI_LGA_IADPSG", "RI_PE_IADPSG", "RI_CS_IADPSG")
vet.nomeselementos2 <- c("NNS_LGA_WHO", "NNS_LGA_IADPSG","NNS_PE_WHO", "NNS_PE_IADPSG", "NNS_CS_WHO", "NNS_CS_IADPSG")
vet.nomeselementos <- c(vet.nomeselementos1, vet.nomeselementos2)
for (i in vet.nomeselementos) {
print(paste("HPD Interval for ",i," | Sensitivity analysis HAPO",sep=""))
graphname <- paste("grafico_AS_HAPO_",i,".png", sep="")
png(file.path(paste(getwd(),"//saida", sep=""),graphname))
ans <- eval(parse(text=paste("plot(density(",i,"))",sep="")))
dev.off()
ans <- eval(parse(text=paste("boa.hpd(",i,", alpha = 0.05)",sep="")))
write.csv2( ans , paste("HPD Sensitivity analysis HAPO ",i,".csv", sep=""))
print( ans )
}
dev.off()
|
b48ad84de11d0785e766aed446dae5db9751610e
|
62ef84d9a05abca20217017fbaeebba3df67384f
|
/rfunctions/sensEffectRatioMod.R
|
2cf237bac0c06792636276a85258c7d08bb29843
|
[] |
no_license
|
jasa-acs/Biased-Encouragements-and-Heterogeneous-Effects-in-an-Instrumental-Variable-Study-of-Emergency-Ge...
|
b3c833501ada3ece38bdffbc97cd5fd86b9ee944
|
36e916f2c6d6fe09ddc6fec2738e9fd85500080c
|
refs/heads/master
| 2023-02-14T03:25:02.006415
| 2021-01-04T20:03:59
| 2021-01-04T20:03:59
| 325,870,516
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 34,245
|
r
|
sensEffectRatioMod.R
|
###########
#sensEffectRatio
###########
sensEffectRatio = function(index, treatment, outcome, dose, null=0, DE = "both", MO = T, ER = T, alternative = "two.sided", alpha = 0.05, Gamma.vec = 1, calculate.pval = T, continuous.relax = F)
{
PVAL = calculate.pval
require(gurobi)
require(Matrix)
ns = table(index)
ms = table(index[treatment*1==1])
N.total = sum(ns)
nostratum = length(unique(index))
treatment = 1*treatment
treatment = (1*treatment == 1)
gur = suppressWarnings(require(gurobi))
vec.111 = tapply((treatment)*outcome*(dose), index, sum)
vec.110 = tapply((treatment)*outcome*(!dose), index, sum)
vec.010 = tapply((!treatment)*outcome*(!dose), index, sum)
vec.101 = tapply((treatment)*(!outcome)*dose, index, sum)
vec.100 = tapply((treatment)*(!outcome)*(!dose), index, sum)
vec.001 = tapply((!treatment)*(!outcome)*dose, index, sum)
vec.011 = tapply((!treatment)*(outcome)*dose, index, sum)
vec.000 = tapply((!treatment)*(!outcome)*(!dose), index, sum)
V = cbind(vec.111, vec.110, vec.101, vec.100, vec.011, vec.010,vec.001, vec.000)
id = apply(V, 1, paste, collapse = "-")
num.id = sort.new(xtfrm(id))
nosymm = length(unique(num.id))
cc = table(num.id)
bb = tapply(ns, num.id, mean)
N.sr = sum(cc-1)
m.011 = vec.011+1
m.010 = vec.010+1
m.001 = vec.001+1
m.000 = vec.000+1
m.101 = vec.101 + 1
m.100 = vec.100 + 1
m.111 = vec.111 + 1
m.110 = vec.110 + 1
mult.000 = tapply(m.000, num.id, mean)
mult.001 = tapply(m.001, num.id, mean)
mult.010 = tapply(m.010, num.id, mean)
mult.011 = tapply(m.011, num.id, mean)
mult.110 = tapply(m.110, num.id, mean)
mult.111 = tapply(m.111, num.id, mean)
mult.101 = tapply(m.101, num.id, mean)
mult.100 = tapply(m.100, num.id, mean)
wATE.per.strat = (ns)*(tapply((treatment)*outcome, index, sum)/ms - tapply((1-treatment)*outcome, index, sum)/(ns-ms))
ATE.est = sum(wATE.per.strat)
wATE2.per.strat = (ns)*(tapply((treatment)*dose, index, sum)/ms - tapply((1-treatment)*dose, index, sum)/(ns-ms))
ATE2.est = sum(wATE2.per.strat)
lambdahat = ATE.est/ATE2.est
#Gamma.vec = round(Gamma.vec, 2)
null = round(null, 2)
wTE.per.strat = (tapply((treatment)*(outcome - null*dose), index, sum)/ms - tapply((1-treatment)*(outcome - null*dose), index, sum)/(ns-ms))
TE.est = sum(wTE.per.strat)
max.e = (TE.est > 0)
pvalvec = rep(0, length(Gamma.vec))
Rejectvec = rep(0, length(Gamma.vec))
kappavec = rep(0, length(Gamma.vec))
SE = 0
if(ER == F)
{
mult.po = (mult.111)*mult.110*(mult.101)*mult.100*mult.001*(mult.000)*(mult.010)*mult.011
mult.do = (mult.111)*mult.110*(mult.101)*mult.100*mult.001*(mult.000)*(mult.010)*mult.011
if(DE == "nonpositive")
{
mult.po = mult.100*mult.101*mult.010*mult.011
}
if(DE=="nonnegative")
{
mult.po = mult.111*mult.110*mult.000*mult.001
}
if(MO == T)
{
mult.do = mult.111*mult.101*mult.000*mult.010
}
mult.all = mult.po*mult.do
ns.type = tapply(ns, num.id, mean)
N.vars = sum(mult.all*(ns.type-1))
index.symm = rep(1:nosymm, mult.all*(ns.type-1))
n.types = (mult.all)
n.po = mult.po
n.do= mult.do
n.per = cc
Diff = rep(0, N.vars)
Diff2 = Diff
#V.list = vector("list", N.vars)
row.ind = rep(0, 4*N.vars+1)
col.ind = row.ind
values = row.ind
b = rep(0, nosymm + 2)
for(kk in 1:nosymm)
{
row.ind[which(index.symm==kk)] = rep(kk, (ns.type[kk]-1)*n.types[kk])
col.ind[which(index.symm==kk)] = which(index.symm==kk)
values[which(index.symm==kk)] = rep(1, (ns.type[kk]-1)*(n.types[kk]))
b[kk] = n.per[kk]
}
row.ind[(N.vars+1):(2*N.vars)] = rep(nosymm + 1, N.vars)
col.ind[(N.vars+1):(2*N.vars)] = 1:N.vars
row.ind[(2*N.vars+1):(3*N.vars)] = rep(nosymm + 2, N.vars)
col.ind[(2*N.vars+1):(3*N.vars)] = 1:N.vars
row.ind[(3*N.vars+1):(4*N.vars+1)] = rep(nosymm + 3, N.vars+1)
col.ind[(3*N.vars+1):(4*N.vars+1)] = 1:(N.vars+1)
PM = rep(0, N.vars)
PV = rep(0, N.vars)
#Gamma.vec = seq(1.2, 1.22, by = .001)
zscore = rep(0, length(Gamma.vec))
for(ee in 1:length(Gamma.vec))
{
Gamma.sens = Gamma.vec[ee]
for(kk in 1:nosymm)
{
i = which(num.id==kk)[1]
symmgroup = which(index.symm == kk)
ind = which(index==i)
treatstrat = treatment[ind]
outstrat = outcome[ind]
dosestrat = dose[ind]
dosesymm = c(rep(0, sum(treatstrat==F&dosestrat==F)), rep(1, sum(treatstrat==F& dosestrat==T)), rep(0, sum(treatstrat==T&dosestrat==F)), rep(1, sum(treatstrat==T& dosestrat==T)))
outsymm = c(sort(outstrat[treatstrat==F& dosestrat==F]), sort(outstrat[treatstrat==F& dosestrat==T]), sort(outstrat[treatstrat==T&dosestrat == F]), sort(outstrat[treatstrat==T&dosestrat == T]))
PO = matrix(0, n.po[kk], ns[i])
DO = matrix(0, n.do[kk],ns[i])
mt.011 = mult.011[kk]
mt.001 = mult.001[kk]
mt.000 = mult.000[kk]
mt.010 = mult.010[kk]
mt.110 = mult.110[kk]
mt.100 = mult.100[kk]
mt.111 = mult.111[kk]
mt.101 = mult.101[kk]
p.011 = mt.011
p.001 = mt.001
p.000 = mt.000
p.010 = mt.010
p.110 = mt.110
p.100 = mt.100
p.111 = mt.111
p.101 = mt.101
T.000 = matrix(1, mt.000-1, mt.000-1)
T.000[lower.tri(T.000)] = 0
T.000 = rbind(T.000, c(rep(0, mt.000-1)) )
T.001 = matrix(1, mt.001-1, mt.001-1)
T.001[lower.tri(T.001)] = 0
T.001 = rbind(T.001, c(rep(0, mt.001-1)) )
T.010 = matrix(1, mt.010-1, mt.010-1)
T.010[lower.tri(T.010)] = 0
T.010 = rbind(T.010, c(rep(0, mt.010-1)) )
T.011 = matrix(1, mt.011-1, mt.011-1)
T.011[lower.tri(T.011)] = 0
T.011 = rbind(T.011, c(rep(0, mt.011-1)))
T.100 = matrix(1, mt.100-1, mt.100-1)
T.100[lower.tri(T.100)] = 0
T.100 = rbind(T.100, c(rep(0, mt.100-1)) )
T.101 = matrix(1, mt.101-1, mt.101-1)
T.101[lower.tri(T.101)] = 0
T.101 = rbind(T.101, c(rep(0, mt.101-1)) )
T.110 = matrix(1, mt.110-1, mt.110-1)
T.110[lower.tri(T.110)] = 0
T.110 = rbind(T.110, c(rep(0, mt.110-1)) )
T.111 = matrix(1, mt.111-1, mt.111-1)
T.111[lower.tri(T.111)] = 0
T.111 = rbind(T.111, c(rep(0, mt.111-1)))
if(DE == "nonnegative")
{
T.100 = matrix(0, 1, mt.100-1)
p.100 = 1
T.101 = matrix(0, 1, mt.101-1)
p.101 = 1
T.011 = matrix(1, 1, mt.011-1)
p.011 = 1
T.010 = matrix(1, 1, mt.010-1)
p.010 = 1
}
if(DE == "nonpositive")
{
T.111 = matrix(1, 1, mt.111-1)
p.111 = 1
T.110 = matrix(1, 1, mt.110-1)
p.110 = 1
T.001 = matrix(0, 1, mt.001-1)
p.001 = 1
T.000 = matrix(0, 1, mt.000-1)
p.000 = 1
}
count = 1
for(ll in 1:p.000)
{
for(mm in 1:p.010)
{
for(uu in 1:p.001)
{
for(vv in 1:p.011)
{
for(ww in 1:p.100)
{
for(xx in 1:p.110)
{
for(yy in 1:p.101)
{
for(zz in 1:p.111)
{
tempvec = c(T.000[ll,], T.010[mm,], T.001[uu,], T.011[vv,], T.100[ww,], T.110[xx,], T.101[yy,], T.111[zz,])
tempvec = tempvec[!is.na(tempvec)]
PO[count,] = tempvec
count = count+1
}
}
}
}
}
}
}
}
count =1
p.011 = mt.011
p.001 = mt.001
p.000 = mt.000
p.010 = mt.010
p.110 = mt.110
p.100 = mt.100
p.111 = mt.111
p.101 = mt.101
T.000 = matrix(1, mt.000-1, mt.000-1)
T.000[lower.tri(T.000)] = 0
T.000 = rbind(T.000, c(rep(0, mt.000-1)) )
T.001 = matrix(1, mt.001-1, mt.001-1)
T.001[lower.tri(T.001)] = 0
T.001 = rbind(T.001, c(rep(0, mt.001-1)) )
T.010 = matrix(1, mt.010-1, mt.010-1)
T.010[lower.tri(T.010)] = 0
T.010 = rbind(T.010, c(rep(0, mt.010-1)) )
T.011 = matrix(1, mt.011-1, mt.011-1)
T.011[lower.tri(T.011)] = 0
T.011 = rbind(T.011, c(rep(0, mt.011-1)))
T.100 = matrix(1, mt.100-1, mt.100-1)
T.100[lower.tri(T.100)] = 0
T.100 = rbind(T.100, c(rep(0, mt.100-1)) )
T.101 = matrix(1, mt.101-1, mt.101-1)
T.101[lower.tri(T.101)] = 0
T.101 = rbind(T.101, c(rep(0, mt.101-1)) )
T.110 = matrix(1, mt.110-1, mt.110-1)
T.110[lower.tri(T.110)] = 0
T.110 = rbind(T.110, c(rep(0, mt.110-1)) )
T.111 = matrix(1, mt.111-1, mt.111-1)
T.111[lower.tri(T.111)] = 0
T.111 = rbind(T.111, c(rep(0, mt.111-1)))
if(MO == T)
{
T.100 = matrix(0, 1, mt.100-1)
p.100 = 1
T.110 = matrix(0, 1, mt.110-1)
p.110 = 1
T.011 = matrix(1, 1, mt.011-1)
p.011 = 1
T.001 = matrix(1, 1, mt.001-1)
p.001 = 1
}
for(ll in 1:p.000)
{
for(mm in 1:p.010)
{
for(uu in 1:p.001)
{
for(vv in 1:p.011)
{
for(ww in 1:p.100)
{
for(xx in 1:p.110)
{
for(yy in 1:p.101)
{
for(zz in 1:p.111)
{
tempvec = c(T.000[ll,], T.010[mm,], T.001[uu,], T.011[vv,], T.100[ww,], T.110[xx,], T.101[yy,], T.111[zz,])
tempvec = tempvec[!is.na(tempvec)]
DO[count,] = tempvec
count = count+1
}
}
}
}
}
}
}
}
count = 1
for(jj in 1:n.po[kk])
{
for(ll in 1:n.do[kk])
{
ind.jj = (((count-1)*(ns[i]-1))+1):(count*(ns[i]-1))
po.symm = PO[jj,]
do.symm = DO[ll,]
treatsymm = c(rep(F, ns[i]-ms[i]), rep(T, ms[i]))
outcontrol = outsymm*(1-treatsymm) + po.symm*(treatsymm)
outtreat = outsymm*(treatsymm) + po.symm*(1-treatsymm)
dosecontrol = dosesymm*(1-treatsymm) + do.symm*(treatsymm)
dosetreat = dosesymm*(treatsymm) + do.symm*(1-treatsymm)
sum.cont = sum(outcontrol - null*dosecontrol)/(ns[i]-1)
Q = (outtreat + outcontrol/(ns[i]-1) - null*dosetreat - null*dosecontrol/(ns[i]-1)- sum.cont)*ns[i]
if(sum(treatstrat)>1)
{
sum.cont = sum(outtreat - null*dosetreat)/(ns[i]-1)
Q = -(outtreat/(ns[i]-1) + outcontrol - null*dosetreat/(ns[i]-1) - null*dosecontrol- sum.cont)*ns[i]
}
qi = Q*max.e - Q*(!max.e)
ord = order(qi)
qi.sort = sort(qi)
eta = diff(outcontrol+outtreat - null*(dosecontrol+dosetreat))/2
taubar = mean(outtreat-outcontrol - null*(dosetreat-dosecontrol))
mu = rep(0, length(ind)-1)
sigma2 = rep(0, length(ind)-1)
theta = Gamma.sens/(1+Gamma.sens)
for(j in 1:(length(ind)-1))
{
mu[j] = (2*theta-1)*abs(eta) + taubar - (2*theta-1)*(theta*abs(taubar + abs(eta)) + (1-theta)*abs(taubar - abs(eta)))
sigma2[j] = theta*(1-theta)*(2*abs(eta) - (2*theta-1)*(abs(taubar + abs(eta))- abs(taubar - abs(eta))))^2
}
mu[abs(mu) < 1e-8] = 0
sigma2[sigma2 < 1e-8] = 0
PM[symmgroup[ind.jj]] = mu*(max.e) - mu*(!max.e)
PV[symmgroup[ind.jj]] = (sigma2)
Diff[symmgroup[ind.jj]] = sum(outtreat -outcontrol - (null*(dosetreat - dosecontrol)))
Diff2[symmgroup[count]] = sum(((dosetreat - dosecontrol)))
count = count+1
}
}
}
values[(N.vars+1):(2*N.vars)] = Diff
values[(2*N.vars+1):(3*N.vars)] = Diff2
values[(3*N.vars+1):(4*N.vars+1)] = c(-PM, 1)
b[nosymm+1] = 0
b[nosymm+2] = 1
b[nosymm+3] = 0
alpha.opt = alpha
if(alternative != "two.sided")
{
alpha.opt = 2*alpha
}
const.dir = c(rep("=", nosymm+1), ">=", "=")
model = list()
# if(Gamma.sens==1)
# {
# model$A = sparseMatrix(row.ind[1:(3*N.vars)], col.ind[1:(3*N.vars)], x=values[1:(3*N.vars)])
# model$obj = c(PV)
# model$sense = const.dir[1:(nosymm+2)]
# model$rhs = b[1:(nosymm+2)]
# model$vtype = c(rep("I", N.vars))
# if(continuous.relax == T){model$vtype = c(rep("C", N.vars))}
#
#
# model$modelsense = "max"
#
#
# solm = gurobi(model, params = list(OutputFlag = 0))
# zed = (TE.est/sqrt(solm$objval))
# kappavec[ee] = (TE.est)^2 - qchisq(1-alpha.opt, 1)*solm$objval
# SE = sqrt(solm$objval)
# x = solm$x[1:N.vars]
# tstat = zed
# pval = 0
# if(alternative == "two.sided")
# {
# pval = 2*pnorm(-abs(tstat))
# }
# if(alternative == "greater")
# {
# pval = 1 - pnorm((tstat))
# }
# if(alternative == "less")
# {
# pval = pnorm((tstat))
# }
# Reject = (pval < alpha)
# }
# if(Gamma.sens != 1)
# {
diff = 200
kappa = qchisq(1-alpha.opt, 1)
while(diff > 1e-8)
{
th = Gamma.sens/(1+Gamma.sens)
TE.est.Gamma = TE.est - sum((2*th-1)*abs(wTE.per.strat))
Plin = -2*TE.est.Gamma*PM - kappa*PV
rowind.q = 1:(N.vars+1)
colind.q = 1:(N.vars+1)
values.q = c(rep(0, N.vars),1)
Q = sparseMatrix(rowind.q, colind.q, x=values.q)
model$A = sparseMatrix(row.ind, col.ind, x=values)
model$obj = c(Plin,0)
model$Q = Q
model$sense = const.dir
model$rhs = b
model$vtype = c(rep("I", N.vars), "C")
if(continuous.relax == T){model$vtype = c(rep("C", N.vars), "C")}
model$lb = c(rep(0, N.vars), -Inf)
model$modelsense = "min"
solm = gurobi(model, params = list(OutputFlag = 0))
x = solm$x[1:N.vars]
kappa.new = (TE.est.Gamma - sum(PM*x))^2/sum(PV*x)
diff = abs(kappa.new - kappa)
pval = 0
if(PVAL == F)
{
diff = 0
Reject = (kappa.new > kappa)
}
kappavec[ee] = (TE.est.Gamma - sum(PM*x))^2 - qchisq(1-alpha.opt, 1)*sum(PV*x)
kappa = kappa.new
}
zed = sqrt((TE.est.Gamma - sum(PM*x))^2/sum(PV*x))
if(alternative == "less")
{
zed = -zed
}
zscore[ee] = zed
tstat = zed
if(alternative == "two.sided")
{
pval = 2*pnorm(-abs(tstat))
}
if(alternative == "greater")
{
pval = 1 - pnorm((tstat))
}
if(alternative == "less")
{
pval = pnorm((tstat))
}
if(sign(TE.est.Gamma - sum(PM*x))!=sign(TE.est))
{
Reject = F
pval = 0.5
kappavec[ee] = -10
if(alternative == "two.sided")
{
pval = 1
kappavec[ee] = -10
}
}
if(alternative == "greater" & sign(TE.est.Gamma - sum(PM*x)) < 0)
{
pval = .5
kappavec[ee] = -10
}
if(alternative == "less" & sign(TE.est.Gamma - sum(PM*x)) > 0)
{
pval = .5
kappavec[ee] = -10
}
Reject = (pval < alpha)
}
pvalvec[ee] = pval
Rejectvec[ee] = Reject
#}
}
if(ER == T)
{
mult.all = (mult.101*(mult.101+1)/2)*(mult.111*(mult.111+1)/2)*(mult.010*(mult.010+1)/2)*(mult.000*(mult.000+1)/2)*(mult.100*(mult.100+1)/2)*(mult.110*(mult.110+1)/2)*(mult.011*(mult.011+1)/2)*(mult.001*(mult.001+1)/2)
if(MO == T)
{
mult.all = (mult.101*(mult.101+1)/2)*(mult.111*(mult.111+1)/2)*(mult.010*(mult.010+1)/2)*(mult.000*(mult.000+1)/2)
if(DE == "nonpositive")
{
mult.all = (mult.111)*(mult.101*(mult.101+1)/2)*(mult.000)*(mult.010*(mult.010+1)/2)
}
if(DE=="nonnegative")
{
mult.all = (mult.101)*(mult.111*(mult.111+1)/2)*(mult.010)*(mult.000*(mult.000+1)/2)
}
}
if(MO == F)
{
mult.all = (mult.101*(mult.101+1)/2)*(mult.111*(mult.111+1)/2)*(mult.010*(mult.010+1)/2)*(mult.000*(mult.000+1)/2)*(mult.100*(mult.100+1)/2)*(mult.110*(mult.110+1)/2)*(mult.011*(mult.011+1)/2)*(mult.001*(mult.001+1)/2)
if(DE == "nonpositive")
{
mult.all = (mult.111)*(mult.101*(mult.101+1)/2)*(mult.000)*(mult.010*(mult.010+1)/2)*mult.001*(mult.011*(mult.011+1)/2)*mult.110*(mult.100*(mult.100+1)/2)
}
if(DE=="nonnegative")
{
mult.all = (mult.101)*(mult.111*(mult.111+1)/2)*(mult.010)*(mult.000*(mult.000+1)/2)*mult.011*(mult.001*(mult.001+1)/2)*mult.100*(mult.110*(mult.110+1)/2)
}
}
ns.type = tapply(ns, num.id, mean)
N.vars = sum(mult.all*(ns.type-1))
index.symm = rep(1:nosymm, mult.all*(ns.type-1))
n.types = (mult.all)
mult.po= mult.all
mult.do = mult.all
n.po = mult.po
n.do= mult.do
n.per = cc
Diff = rep(0, N.vars)
Diff2 = Diff
#V.list = vector("list", N.vars)
row.ind = rep(0, 3*N.vars+1)
col.ind = row.ind
values = row.ind
b = rep(0, nosymm + 2)
for(kk in 1:nosymm)
{
row.ind[which(index.symm==kk)] = rep(kk, (ns.type[kk]-1)*n.types[kk])
col.ind[which(index.symm==kk)] = which(index.symm==kk)
values[which(index.symm==kk)] = rep(1, (ns.type[kk]-1)*(n.types[kk]))
b[kk] = n.per[kk]
}
row.ind[(N.vars+1):(2*N.vars)] = rep(nosymm + 1, N.vars)
col.ind[(N.vars+1):(2*N.vars)] = 1:N.vars
row.ind[(2*N.vars+1):(3*N.vars)] = rep(nosymm + 2, N.vars)
col.ind[(2*N.vars+1):(3*N.vars)] = 1:N.vars
row.ind[(3*N.vars+1):(4*N.vars+1)] = rep(nosymm + 3, N.vars+1)
col.ind[(3*N.vars+1):(4*N.vars+1)] = 1:(N.vars+1)
PM = rep(0, N.vars)
PV = rep(0, N.vars)
zscore = rep(0, length(Gamma.vec))
for(ee in 1:length(Gamma.vec))
{
Gamma.sens = Gamma.vec[ee]
for(kk in 1:nosymm)
{
i = which(num.id==kk)[1]
symmgroup = which(index.symm == kk)
ind = which(index==i)
treatstrat = treatment[ind]
outstrat = outcome[ind]
dosestrat = dose[ind]
dosesymm = c(rep(0, sum(treatstrat==F&dosestrat==F)), rep(1, sum(treatstrat==F& dosestrat==T)), rep(0, sum(treatstrat==T&dosestrat==F)), rep(1, sum(treatstrat==T& dosestrat==T)))
outsymm = c(sort(outstrat[treatstrat==F& dosestrat==F]), sort(outstrat[treatstrat==F& dosestrat==T]), sort(outstrat[treatstrat==T&dosestrat == F]), sort(outstrat[treatstrat==T&dosestrat == T]))
PO = matrix(0, n.po[kk], ns[i])
DO = matrix(0, n.po[kk],ns[i])
mt.011 = mult.011[kk]
mt.001 = mult.001[kk]
mt.000 = mult.000[kk]
mt.010 = mult.010[kk]
mt.110 = mult.110[kk]
mt.100 = mult.100[kk]
mt.111 = mult.111[kk]
mt.101 = mult.101[kk]
p.011 = mt.011
p.001 = mt.001
p.000 = mt.000
p.010 = mt.010
p.110 = mt.110
p.100 = mt.100
p.111 = mt.111
p.101 = mt.101
D.000 = matrix(1, mt.000-1, mt.000-1)
D.000[lower.tri(D.000)] = 0
D.000 = rbind(D.000, c(rep(0, mt.000-1)) )
D.010 = matrix(1, mt.010-1, mt.010-1)
D.010[lower.tri(D.010)] = 0
D.010 = rbind(D.010, c(rep(0, mt.010-1)) )
D.001 = matrix(1, mt.001-1, mt.001-1)
D.001[lower.tri(D.001)] = 0
D.001 = rbind(D.001, c(rep(0, mt.001-1)) )
D.011 = matrix(1, mt.011-1, mt.011-1)
D.011[lower.tri(D.011)] = 0
D.011 = rbind(D.011, c(rep(0, mt.011-1)))
D.100 = matrix(1, mt.100-1, mt.100-1)
D.100[lower.tri(D.100)] = 0
D.100 = rbind(D.100, c(rep(0, mt.100-1)) )
D.110 = matrix(1, mt.110-1, mt.110-1)
D.110[lower.tri(D.110)] = 0
D.110 = rbind(D.110, c(rep(0, mt.110-1)) )
D.101 = matrix(1, mt.101-1, mt.101-1)
D.101[lower.tri(D.101)] = 0
D.101 = rbind(D.101, c(rep(0, mt.101-1)) )
D.111 = matrix(1, mt.111-1, mt.111-1)
D.111[lower.tri(D.111)] = 0
D.111 = rbind(D.111, c(rep(0, mt.111-1)))
if(MO == T)
{
D.100 = matrix(0, 1, mt.100-1)
p.100 = 1
D.110 = matrix(0, 1, mt.110-1)
p.110 = 1
D.011 = matrix(1, 1, mt.011-1)
p.011 = 1
D.001 = matrix(1, 1, mt.001-1)
p.001 = 1
}
count = 1
for(ll in 1:p.000)
{
for(mm in 1:p.010)
{
for(uu in 1:p.001)
{
for(vv in 1:p.011)
{
for(ww in 1:p.100)
{
for(xx in 1:p.110)
{
for(yy in 1:p.101)
{
for(zz in 1:p.111)
{
T.000 = matrix(1, p.000-ll, mt.000-ll)
T.000[lower.tri(T.000)] = 0
T.000 = rbind(T.000, c(rep(0, mt.000-ll)))
F.000 = matrix(0, (p.000-ll+1), (ll-1))
T.000 = cbind(F.000, T.000)
T.010 = matrix(1, p.010-mm, mt.010-mm)
T.010[lower.tri(T.010)] = 0
T.010 = rbind(T.010, c(rep(0, mt.010-mm)))
F.010 = matrix(1, (p.010-mm+1), (mm-1))
T.010 = cbind(F.010, T.010)
T.001 = matrix(1, uu-1, uu-1)
T.001[lower.tri(T.001)] = 0
T.001 = rbind(T.001, c(rep(0, uu-1)))
F.001 = matrix(0, (uu), (mt.001-uu))
T.001 = cbind(F.001, T.001)
if(MO == T)
{
T.001 = matrix(0, 1, mt.001-1)
}
T.011 = matrix(1, vv-1, vv-1)
T.011[lower.tri(T.011)] = 0
T.011 = rbind(T.011, c(rep(0, vv-1)))
F.011 = matrix(1, (vv), (mt.011-vv))
T.011 = cbind(F.011, T.011)
if(MO == T)
{
T.011 = matrix(1, 1, mt.011-1)
}
T.100 = matrix(1, p.100-ww, mt.100-ww)
T.100[lower.tri(T.100)] = 0
T.100 = rbind(T.100, c(rep(0, mt.100-ww)))
F.100 = matrix(0, (p.100-ww+1), (ww-1))
T.100 = cbind(F.100, T.100)
if(MO == T)
{
T.100 = matrix(0, 1,mt.100-1)
}
T.110 = matrix(1, p.110-xx, mt.110-xx)
T.110[lower.tri(T.110)] = 0
T.110 = rbind(T.110, c(rep(0, mt.110-xx)))
F.110 = matrix(1, (p.110-xx+1), (xx-1))
T.110 = cbind(F.110, T.110)
if(MO == T)
{
T.110 = matrix(1, 1, mt.110-1)
}
T.101 = matrix(1, yy-1, yy-1)
T.101[lower.tri(T.101)] = 0
T.101 = rbind(T.101, c(rep(0, yy-1)))
F.101 = matrix(0, (yy), (mt.101-yy))
T.101 = cbind(F.101, T.101)
T.111 = matrix(1, zz-1, zz-1)
T.111[lower.tri(T.111)] = 0
T.111 = rbind(T.111, c(rep(0, zz-1)))
F.111 = matrix(1, (zz), (mt.111-zz))
T.111 = cbind(F.111, T.111)
if(DE == "nonnegative")
{
T.100 = matrix(0, 1, mt.100-1)
T.101 = matrix(0, 1, mt.101-1)
T.011 = matrix(1, 1, mt.011-1)
T.010 = matrix(1, 1, mt.010-1)
}
if(DE == "nonpositive")
{
T.111 = matrix(1, 1, mt.111-1)
T.110 = matrix(1, 1, mt.110-1)
T.001 = matrix(0, 1, mt.001-1)
T.000 = matrix(0, 1, mt.000-1)
}
dosevec = c(D.000[ll,], D.010[mm,], D.001[uu,], D.011[vv,], D.100[ww,], D.110[xx,], D.101[yy,], D.111[zz,])
dosevec = dosevec[!is.na(dosevec)]
for(lll in 1:nrow(T.000))
{
for(mmm in 1:nrow(T.010))
{
for(uuu in 1:nrow(T.001))
{
for(vvv in 1:nrow(T.011))
{
for(www in 1:nrow(T.100))
{
for(xxx in 1:nrow(T.110))
{
for(yyy in 1:nrow(T.101))
{
for(zzz in 1:nrow(T.111))
{
DO[count,] = dosevec
tempvec = c(T.000[lll,], T.010[mmm,], T.001[uuu,], T.011[vvv,], T.100[www,], T.110[xxx,], T.101[yyy,], T.111[zzz,])
tempvec = tempvec[!is.na(tempvec)]
PO[count,] = tempvec
count = count+1
}}}}}}}}}}}}}}}}
count = 1
for(jj in 1:n.po[kk])
{
ind.jj = (((jj-1)*(ns[i]-1))+1):(jj*(ns[i]-1))
po.symm = PO[jj,]
do.symm = DO[jj,]
treatsymm = c(rep(F, ns[i]-ms[i]), rep(T, ms[i]))
outcontrol = outsymm*(1-treatsymm) + po.symm*(treatsymm)
outtreat = outsymm*(treatsymm) + po.symm*(1-treatsymm)
dosecontrol = dosesymm*(1-treatsymm) + do.symm*(treatsymm)
dosetreat = dosesymm*(treatsymm) + do.symm*(1-treatsymm)
sum.cont = sum(outcontrol - null*dosecontrol)/(ns[i]-1)
Q = (outtreat + outcontrol/(ns[i]-1) - null*dosetreat - null*dosecontrol/(ns[i]-1)- sum.cont)*ns[i]
if(sum(treatstrat)>1)
{
sum.cont = sum(outtreat - null*dosetreat)/(ns[i]-1)
Q = -(outtreat/(ns[i]-1) + outcontrol - null*dosetreat/(ns[i]-1) - null*dosecontrol- sum.cont)*ns[i]
}
qi = Q*max.e - Q*(!max.e)
ord = order(qi)
qi.sort = sort(qi)
eta = diff(outcontrol+outtreat - null*(dosecontrol+dosetreat))/2
taubar = mean(outtreat-outcontrol - null*(dosetreat-dosecontrol))
mu = rep(0, length(ind)-1)
sigma2 = rep(0, length(ind)-1)
theta = Gamma.sens/(1+Gamma.sens)
for(j in 1:(length(ind)-1))
{
mu[j] = (2*theta-1)*abs(eta) + taubar - (2*theta-1)*(theta*abs(taubar + abs(eta)) + (1-theta)*abs(taubar - abs(eta)))
sigma2[j] = theta*(1-theta)*(2*abs(eta) - (2*theta-1)*(abs(taubar + abs(eta))- abs(taubar - abs(eta))))^2
}
mu[abs(mu) < 1e-8] = 0
sigma2[sigma2 < 1e-8] = 0
PM[symmgroup[ind.jj]] = mu*(max.e) - mu*(!max.e)
PV[symmgroup[ind.jj]] = (sigma2)
Diff[symmgroup[ind.jj]] = sum(outtreat -outcontrol - (null*(dosetreat - dosecontrol)))
Diff2[symmgroup[count]] = sum(((dosetreat - dosecontrol)))
count = count+1
}
}
values[(N.vars+1):(2*N.vars)] = Diff
values[(2*N.vars+1):(3*N.vars)] = Diff2
values[(3*N.vars+1):(4*N.vars+1)] = c(-PM, 1)
b[nosymm+1] = 0
b[nosymm+2] = 1
b[nosymm+3] = 0
alpha.opt = alpha
if(alternative != "two.sided")
{
alpha.opt = 2*alpha
}
const.dir = c(rep("=", nosymm+1), ">=", "=")
model = list()
if(Gamma.sens==1)
{
model$A = sparseMatrix(row.ind[1:(3*N.vars)], col.ind[1:(3*N.vars)], x=values[1:(3*N.vars)])
model$obj = c(PV)
model$sense = const.dir[1:(nosymm+2)]
model$rhs = b[1:(nosymm+2)]
model$vtype = c(rep("I", N.vars))
if(continuous.relax == T){model$vtype = c(rep("C", N.vars))}
model$modelsense = "max"
solm = gurobi(model, params = list(OutputFlag = 0))
zed = (TE.est/sqrt(solm$objval))
x = solm$x[1:N.vars]
SE = sqrt(solm$objval)
kappavec[ee] = (TE.est)^2 - qchisq(1-alpha.opt, 1)*solm$objval
tstat = zed
pval = 0
if(alternative == "two.sided")
{
pval = 2*pnorm(-abs(tstat))
}
if(alternative == "greater")
{
pval = 1 - pnorm((tstat))
}
if(alternative == "less")
{
pval = pnorm((tstat))
}
Reject = (pval < alpha)
}
if(Gamma.sens != 1)
{
diff = 200
kappa = qchisq(1-alpha.opt, 1)
while(diff > 1e-8)
{
th = Gamma.sens/(1+Gamma.sens)
TE.est.Gamma = TE.est - sum((2*th-1)*abs(wTE.per.strat))
Plin = -2*TE.est.Gamma*PM - kappa*PV
rowind.q = 1:(N.vars+1)
colind.q = 1:(N.vars+1)
values.q = c(rep(0, N.vars),1)
Q = sparseMatrix(rowind.q, colind.q, x=values.q)
model$A = sparseMatrix(row.ind, col.ind, x=values)
model$obj = c(Plin,0)
model$Q = Q
model$sense = const.dir
model$rhs = b
model$vtype = c(rep("I", N.vars), "C")
if(continuous.relax == T){model$vtype = c(rep("C", N.vars+1))}
model$lb = c(rep(0, N.vars), -Inf)
model$modelsense = "min"
solm = gurobi(model, params = list(OutputFlag = 0))
x = solm$x[1:N.vars]
kappa.new = (TE.est.Gamma - sum(PM*x))^2/sum(PV*x)
kappavec[ee] = (TE.est.Gamma - sum(PM*x))^2 - qchisq(1-alpha.opt, 1)*sum(PV*x)
diff = abs(kappa.new - kappa)
pval = 0
if(PVAL == F)
{
diff = 0
Reject = kappa.new > kappa
}
kappa = kappa.new
}
zed = sqrt((TE.est.Gamma - sum(PM*x))^2/sum(PV*x))
if(alternative == "less")
{
zed = -zed
}
zscore[ee] = zed
tstat = zed
if(alternative == "two.sided")
{
pval = 2*pnorm(-abs(tstat))
}
if(alternative == "greater")
{
pval = 1 - pnorm((tstat))
}
if(alternative == "less")
{
pval = pnorm((tstat))
}
if(sign(TE.est.Gamma - sum(PM*x))!=sign(TE.est))
{
Reject = F
pval = 0.5
kappavec[ee] = -10
if(alternative == "two.sided")
{
pval = 1
kappavec[ee] = -10
}
}
if(alternative == "greater" & sign(TE.est.Gamma - sum(PM*x)) < 0)
{
pval = .5
kappavec[ee] = -10
}
if(alternative == "less" & sign(TE.est.Gamma - sum(PM*x)) > 0)
{
pval = .5
kappavec[ee] = -10
}
Reject = (pval < alpha)
}
pvalvec[ee] = pval
Rejectvec[ee] = Reject
}
}
if(PVAL == F)
{
return(list(Gamma.vec = Gamma.vec, Reject = Rejectvec, lambdahat = lambdahat, kappa = kappavec))
}
if(PVAL == T)
{
return(list(Gamma.vec = Gamma.vec, pval = pvalvec, lambdahat = lambdahat))
}
}
sensEffectRatio2 = function(Gamma.vec, index, treatment, outcome, dose, null = 0, DE = "both", MO = T, ER = T, alternative = "two.sided", alpha = 0.05, continuous.relax = F)
{
sensEffectRatio(index, treatment, outcome, dose, null, DE, MO, ER, alternative, alpha, Gamma.vec = Gamma.vec, calculate.pval = F, continuous.relax)$kappa
}
|
55883d7d658865914f93f348ac8437505f3e54fc
|
a61f94187639c226c06164ecb92924076d27bf4c
|
/R/rc.R
|
2f33bddc915b7f5839bd434ebe8318b478bc173a
|
[] |
no_license
|
DevinOrman/mlbstats
|
90b7c53b3f0846df34664507660f9457ebe7760c
|
11a10adeeba2db2e065f733a102cfb963fa8fb1e
|
refs/heads/master
| 2020-05-17T11:41:20.979656
| 2019-04-26T20:37:56
| 2019-04-26T20:37:56
| 183,688,780
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 269
|
r
|
rc.R
|
#' RUNS CREATED FUNCTION
#'
#' This function measures how many runs a batter has contributed
#' @param x Dataset containing batting statistics
#' @keywords rc
#' @export
#' @examples
#' rc()
rc <- function(x){
RC <- x$TB * (x$H + x$BB)/(x$AB + x$BB)
}
|
4d12babe3c1de1821b6f7ec37a3bb42a78111b54
|
d68441b6311721a84d0210c371a1a94b2eb5f261
|
/R/bin_smooth_median.R
|
17d83dfca9928883561bec2ba35c873a40e08873
|
[] |
no_license
|
jasdumas/dumas
|
0e787cb29037cbfac331af108cff0f28c758b513
|
84aedfdd0e095e3a20d07877120a86e7b5d64f8b
|
refs/heads/master
| 2020-04-06T05:37:36.930368
| 2017-07-17T19:24:24
| 2017-07-17T19:24:24
| 38,554,253
| 3
| 2
| null | null | null | null |
UTF-8
|
R
| false
| false
| 377
|
r
|
bin_smooth_median.R
|
## ---- Smoothing function - median ----- ##
#' Bin smoothing by median
#'
#' @param x a numeric vector or list of numbers
#' @param bins a numeric vector of how many bins
#'
#' @return a list
#' @export
#'
#' @examples bin_smooth_median(x = c(21, 15, 26, 26, 28, 29), bins=2)
bin_smooth_median <- function(x, bins) {
lapply(x, function(x){ rep(median(x), times = bins) })
}
|
5f81a65ae5de56a03b4e5af00b9e4661c1f523dc
|
6b799b4098ca2a7d9878bfe7ea79c42d1a526c18
|
/Date formats and tests of significance no answers.R
|
1a9dcafb4a9a0d5048d584e7f8ad8822a4c8e7f9
|
[] |
no_license
|
SaraH545/SecondaryDataClass
|
11f2fa69d0b41a9b5ddb89ae7a4e35de1bb049c1
|
002f42d160f5cc2ccfc0d01aee3cb34738a729d7
|
refs/heads/master
| 2020-03-12T17:25:27.902499
| 2018-04-23T19:19:57
| 2018-04-23T19:19:57
| 130,735,371
| 0
| 1
| null | 2018-04-23T18:41:34
| 2018-04-23T17:52:26
|
R
|
UTF-8
|
R
| false
| false
| 1,881
|
r
|
Date formats and tests of significance no answers.R
|
##Date Formats
#Convert character variables to dates (https://www.statmethods.net/input/dates.html)
strDates <- c("01/05/1965", "08/16/1975")
dates <- as.Date(strDates, "%m/%d/%Y")
#INDEPENDENT ACTIVITY: Convert the string dates to abbreviated month, two digit year
#(HINT: Use link above for help)
#Chi square test from summary data (using in class smoking by gender example)
table1<-matrix(nrow=2,ncol=2,c(68,70,230,876))
chisq.test(table1)
#Chi square test from individual level data (see frequency and correlations activity)
#INDEPENDENT ACTIVITY: Create breaks for the percent below poverty variable at 10, 20, and 30 inclusive at upper range
#Is the distribution of percent below poverty categories by county independent in Indiana and Michigan?
#INDEPENDENT ACTIVITY: Is the overall distribution of black and white individuals different by state?
#ttest example (long format): Test if the mean county area is different in metro countries vs. nonmetro counties.
#Use a two-sample, unpaired, one-sided t-test with alpha=0.05 https://www.statmethods.net/stats/ttest.html
t.test(midwest$area~midwest$inmetro)
#Paired ttest example (Wide format): Test if the asian population is larger than the American Indian population, by county
t.test(midwest$popasian,midwest$popamerindian,paired=TRUE,alternative ="greater")
#INDEPENDENT ACTIVITY: Test if, by county, the mean percent below poverty level is significantly different from 15%
#Regression analysis http://www.cyclismo.org/tutorial/R/linearLeastSquares.html
#Example: Is the percent below poverty level related to the percent of the population that is black, whether or not the county is in a metro area, state, and the area of county?
midwest$percblack<-midwest$popblack/midwest$poptotal
reg<-lm(data=midwest, formula=percbelowpoverty~percblack+inmetro+area+state)
summary(reg)
|
aa5f74d5fb813b9e44cd8550089b6f591ab60507
|
45c63420097a1a5047693e7ee25502ad03afa6aa
|
/man/convert_dates_r_to_twfy.Rd
|
83ab69b38d4391b97b69fe46f3bd29e216ca2bab
|
[] |
no_license
|
jblumenau/twfyR
|
2f08fb7c8cd9a013d4024ed8c52daeacf15f2aaf
|
5b6b14164e60d0d297f1460d43e9099fa9eec081
|
refs/heads/master
| 2021-01-12T02:50:32.057012
| 2019-10-23T11:25:43
| 2019-10-23T11:25:43
| 78,113,610
| 6
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 360
|
rd
|
convert_dates_r_to_twfy.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{convert_dates_r_to_twfy}
\alias{convert_dates_r_to_twfy}
\title{convert_dates_r_to_twfy}
\usage{
convert_dates_r_to_twfy(x)
}
\arguments{
\item{x}{R date object to convert}
}
\value{
Character object
}
\description{
Generic function to convert R dates to twfy dates
}
|
852df6e3434dfeebb536f7e44ea3f2b292499ded
|
4ac98b6f1473ed8fcfb9de05951c33d51559dd73
|
/man/regroup.read_table.Rd
|
e95fa3fc5cfbfaebe09b0368d83638c1337c91b2
|
[] |
no_license
|
stephenshank/RegressHaplo
|
4331b082618a61073fcbb9564eaa8a17296a0e9f
|
cd55f2cc9ca540a2b18eedc4bd3a6e432541487a
|
refs/heads/master
| 2020-04-19T07:11:04.600592
| 2017-08-25T13:37:46
| 2017-08-25T13:37:46
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 646
|
rd
|
regroup.read_table.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read_table.R
\name{regroup.read_table}
\alias{regroup.read_table}
\title{Merges identical read over an edited read table}
\usage{
regroup.read_table(df)
}
\arguments{
\item{df}{a read_table object}
}
\value{
a read_table object
}
\description{
Merges identical read over an edited read table
}
\details{
After removing columns for positions that are
not of interest, a read table can contain multiple rows
corresponding to read groups that are identical at the remaining positions.
This functions joins those reads and returns a read_table
with unique read groups.
}
|
d4e029856ca255f454aab8269ea0e0d2b5035990
|
c838300b1609d3abd37b45179f960416be3d2d7b
|
/R/s.s.test.R
|
876bbc6f88d6f492516ce369620e1cf3fb5c9159
|
[] |
no_license
|
kennylouie/kdevtools
|
2ab5c07a975c5093c619d8e3778bd93450e38d70
|
bef5361aacb4ef3a72b2d142eaaeac7721441945
|
refs/heads/master
| 2021-09-10T02:14:56.956855
| 2018-03-20T17:12:19
| 2018-03-20T17:12:19
| 125,908,564
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 4,561
|
r
|
s.s.test.R
|
#' Summary statistics by group
#'
#' Summary and statistical comparison of group characteristics
#' @importFrom car leveneTest
#' @param dat dataframe with desired summary statistics to be calculated
#' @param samplelabels the name of the column in which has the group parameter you are interested in
#' @param ignore columns to ignore or not use
#' @keywords microarray
#' @export
#' @examples
#' s.s.test()
s.s.test <- function(dat, samplelabels, ignore) {
# remove desired columns not needed in stat summary
if (!missing(ignore)) {
dat <- dat[,-ignore]
}
# making sure no character columns
for (i in 1:dim(dat)[2]) {
if (is.character(dat[,i])) {
dat[,i] <- as.factor(dat[,i])
}
}
# making sure that if data was subsetted, then factor columns are not hiding any levels
for (i in 1:dim(dat)[2]) {
if (is.factor(dat[,i])) {
dat[,i] <- as.factor(as.character(dat[,i]))
}
}
# remove columns with only 1 unique value
dat <- dat[,sapply(sapply(dat, unique), length) > 1]
# creating output table
if (sum(sapply(dat, is.factor)) == 0) {
maxlvl <- 2
} else {
maxlvl <- max(sapply(sapply(dat[,sapply(dat, is.factor)], levels), length))
}
ind <- match(samplelabels, names(dat)) #find which column is samplelabels
for (i in 1:dim(dat)[2]) { #repeat for each column
output.tmp <- data.frame(factor = NA,
grouping = NA,
total = NA,
pval = NA,
test = NA) #generate a temp table to store summary
output.tmp[1:length(levels(dat[,samplelabels])), "factor"] <- rep(as.character(names(dat)[i]), length(levels(dat[,samplelabels])))
if (names(dat)[i] != samplelabels) { #you don't want to do this for the sample group column as it would be useles
if (is.factor(dat[,i])) { #factors are summarised differently than numerics/ints
tab.tmp <- table(dat[,c(ind, i)]) #summarise the counts for each level of this factor
output.tmp[1:length(levels(dat[,samplelabels])), "grouping"] <- as.character(rownames(tab.tmp)) #grabbing the samplegroup names and storing them in the temp
for (j in 1:dim(tab.tmp)[2]) {
output.tmp[,paste0("stat", j)] <- tab.tmp[,j]
} #paste columns into the temp table
if (j+1 <= maxlvl) {
for (l in (j+1):maxlvl) {
output.tmp[,paste0("stat", l)] <- NA #generate NA columns to match the max so that cbind will work later
}
}
output.tmp[,"total"] <- rowSums(output.tmp[,c(6:dim(output.tmp)[2])], na.rm = T) #summarize total for each sample group
f.tmp <- fisher.test(tab.tmp) #fisher test
output.tmp[,"pval"] <- f.tmp$p.value
output.tmp[,"test"] <- "fishertest"
} else {
dat.subset <- dat[!is.na(dat[,i]),] #filter out NAs
dat.mean <- aggregate(dat.subset[,i], by = list(dat.subset[,samplelabels]), FUN = mean)
dat.sd <- aggregate(dat.subset[,i], by = list(dat.subset[,samplelabels]), FUN = sd)
output.tmp[1:length(levels(dat[,samplelabels])), "grouping"] <- as.character(dat.mean[,1])
output.tmp[,"stat1"] <- dat.mean[,2]
output.tmp[,"stat2"] <- dat.sd[,2]
for (l in (1+2):maxlvl) {
output.tmp[,paste0("stat", l)] <- NA
} #generate NA columns to match the max so that cbind will work later
tab.tmp <- table(dat.subset[,samplelabels])
output.tmp[,"total"] <- tab.tmp
n.test <- shapiro.test(dat.subset[,i])
l.test <- leveneTest(dat.subset[,i] ~ dat.subset[,samplelabels])
if ((n.test$p.value > 0.05) & (l.test[,"Pr(>F)"][1]) > 0.05) {
f <- formula(paste0(names(dat.subset)[i], " ~ ", samplelabels))
output.tmp[,"pval"] <- summary(aov(f, data = dat.subset))[[1]]["Pr(>F)"][1,]
output.tmp[,"test"] <- "anovatest"
} else {
output.tmp[,"pval"] <- kruskal.test(dat.subset[,i], dat.subset[,samplelabels])$p.value
output.tmp[,"test"] <- "kruskaltest"
}
}
} else {
tab.tmp <- table(dat[,samplelabels])
output.tmp[,"grouping"] <- names(tab.tmp)
for (l in 1:maxlvl) {
output.tmp[,paste0("stat", l)] <- NA
} #generate NA columns to match the max so that cbind will work later
}
if (!"output" %in% ls()) {
output <- output.tmp
} else {
output <- rbind(output, output.tmp)
}
}
return(output)
}
|
c1a519090be54bba87eaffd35637a06c8733dd3b
|
6f2e5eee9737dbfdcac5e917e9eff9c28d2ad8ae
|
/man/kinship.Rd
|
593fefe3fc95eecfc4bd3ab685a74947da3a896f
|
[] |
no_license
|
oywpan/alphaSimHlpR-1
|
b12bba3b433c40230e6971c931a586e22005653a
|
cf17441d15cd2f1e32f21efedccd8023518bb1be
|
refs/heads/master
| 2022-04-09T07:10:08.866640
| 2020-03-17T16:18:52
| 2020-03-17T16:18:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 226
|
rd
|
kinship.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/alphaSimHlpR.R
\name{kinship}
\alias{kinship}
\title{Title}
\usage{
kinship(M, type)
}
\arguments{
\item{type}{}
}
\value{
}
\description{
Title
}
|
5b40cc69b18e1f08479d0a0cfe6bc343c86d991a
|
9c246553377432d7130b9d07de4b82d2adf203f1
|
/inst/doc/MCPModGeneral-Vignette.R
|
ba188dbf0957030078db8286ff5696c31a264fb5
|
[] |
no_license
|
cran/MCPModGeneral
|
edfeca44adb3b304c8ad37d3b81e7d7defe2e717
|
2924fc0a062748a8dca24cf2645f9c1d9422731f
|
refs/heads/master
| 2020-12-22T01:04:58.231614
| 2020-02-19T16:50:04
| 2020-02-19T16:50:04
| 236,624,361
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 7,249
|
r
|
MCPModGeneral-Vignette.R
|
## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----setup, include = FALSE, fig.width = 3, fig.height = 3---------------
library(DoseFinding)
library(MCPModGeneral)
## ----powMCTGen, fig.height=3, fig.width=5--------------------------------
dose.vec = c(0, 5, 10, 20, 30, 40)
models.full = Mods(doses = dose.vec, linear = NULL,
sigEmax = rbind(c(9, 4), c(20, 3)),
emax = 1.25, quadratic = -0.044/2.667,
placEff = 0, maxEff = 2)
plot(models.full)
## ----powMCTGen2, include = TRUE------------------------------------------
## Look at the power for each possible DR-curve
powMCTGen(30, "negative binomial", "log", modelPar = 0.1,
Ntype = "arm", alpha = 0.05, altModels = models.full, verbose = T)
## ----eval=FALSE----------------------------------------------------------
# powMCTGen(180, "negative binomial", "log", modelPar = 0.1,
# Ntype = "total", alpha = 0.05, altModels = models.full, verbose = T)
## ----eval=FALSE----------------------------------------------------------
# powMCTGen(c(30,30,30,30,30,30), "negative binomial", "log", modelPar = 0.1,
# Ntype = "actual", alpha = 0.05, altModels = models.full, verbose = T)
## ----eval=FALSE----------------------------------------------------------
# powMCTGen(30, "binomial", "probit",
# Ntype = "arm", alpha = 0.05, altModels = models.full)
## ------------------------------------------------------------------------
powMCTGen(30, "binomial", "probit",
Ntype = "arm", alpha = 0.05, doses = c(0, 1, 2, 36, 38, 40),
altModels = models.full, verbose = TRUE)
## ------------------------------------------------------------------------
## Now consider power at some theoretical DR-values
powMCTGen(30, "negative binomial", "log", modelPar = 0.1,
theoResp = c(0, 0.2, 1.8), doses = c(0, 20, 40),
alpha = 0.05, altModels = models.full)
## ------------------------------------------------------------------------
## Can also check type-1 error
powMCTGen(30, "negative binomial", "log", modelPar = 0.01, theoResp = rep(0, 5),
doses = c(0, 50, 10, 20, 30),
alpha = 0.05, altModels = models.full)
## ------------------------------------------------------------------------
sampSizeMCTGen("binomial", "logit", upperN = 50, Ntype = "arm",
altModels = models.full, alpha = 0.05, alRatio = c(3/2, 1/2, 1, 1, 1, 1),
sumFct = "min", power = 0.8)
## ------------------------------------------------------------------------
sampSizeMCTGen("negative binomial", "log", modelPar = 0.1, upperN = 50, Ntype = "arm",
altModels = models.full, alpha = 0.05,
sumFct = "max", power = 0.8, verbose = T)
## ------------------------------------------------------------------------
sampSizeMCTGen("negative binomial", "log", modelPar = 0.1, upperN = 100, Ntype = "total",
alRatio = c(3/2, 1/2, 1),
theoResp = c(0, 0.2, 1.8), doses = c(0, 20, 40),
altModels = models.full, alpha = 0.05)
## ----fig.height=3, fig.width=5-------------------------------------------
data(migraine)
migraine$pfrat = migraine$painfree / migraine$ntrt
migraine
models = Mods(linear = NULL, emax = 10, quadratic = c(-0.004), doses = migraine$dose)
plot(models)
## ----fig.height=3, fig.width=5-------------------------------------------
mu.S = prepareGen(family = "binomial", link = "logit", w = "ntrt", dose = "dose",
resp = "pfrat", data = migraine)
mcp.hand = MCPMod(dose = mu.S$data$dose, resp = mu.S$data$resp, models = models,
S = mu.S$S, Delta = 0.2, type = "general")
plot(mcp.hand)
mcp.hand
## ------------------------------------------------------------------------
mcp.gen = MCPModGen("binomial", "logit", returnS = F, w = "ntrt", dose = "dose",
resp = "pfrat", data = migraine, models = models, Delta = 0.2)
mcp.gen
## ------------------------------------------------------------------------
## Simulate some negative binomial data according to one of the models
set.seed(188)
mean.vec = getResp(models)[,2]
dose.dat = c()
resp.dat = c()
gender.dat = c()
for(i in 1:length(migraine$dose)){
gender.tmp = rbinom(300, 1, prob = 0.3)
gender.dat = c(gender.dat, gender.tmp)
dose.dat = c(dose.dat, rep(migraine$dose[i], 300))
resp.dat = c(resp.dat, rnbinom(300, mu = exp(mean.vec[i] + 5*gender.tmp), size = 1))
}
nb.dat = data.frame(dose = dose.dat, resp = resp.dat, gender = gender.dat)
nb.dat[sample(1:nrow(nb.dat), 5),]
## ----fig.height=3, fig.width=5-------------------------------------------
mcp.nb1 = MCPModGen("negative binomial", link = "log", returnS = T,
dose = "dose", resp = "resp", data = nb.dat, models = models, Delta = 0.6)
mcp.nb2 = MCPModGen("negative binomial", link = "log", returnS = T,
dose = dose.dat, resp = resp.dat, models = models, Delta = 0.6)
mcp.nb3 = MCPModGen("negative binomial", link = "log", returnS = T, placAdj = T,
dose = "dose", resp = "resp", data = nb.dat, models = models, Delta = 0.6)
mcp.nb4 = MCPModGen("negative binomial", link = "log", returnS = T, placAdj = T,
dose = dose.dat, resp = resp.dat, models = models, Delta = 0.6)
names(mcp.nb1)
mcp.nb1$data
mcp.nb1$MCPMod$doseEst
mcp.nb4$MCPMod$doseEst
plot(mcp.nb1$MCPMod)
plot(mcp.nb4$MCPMod)
## ----fig.height=3, fig.width=5-------------------------------------------
mcp.covars = MCPModGen("negative binomial", link = "log", returnS = F, addCovars = ~ factor(gender),
dose = "dose", resp = "resp", data = nb.dat, models = models, Delta = 0.6)
mcp.covars
plot(mcp.covars)
## ------------------------------------------------------------------------
TD(models, Delta = 0.6)[2]
mcp.nb1$MCPMod$doseEst[mcp.nb1$MCPMod$selMod]
mcp.covars$doseEst[mcp.covars$selMod]
## ----fig.height=3, fig.width=5-------------------------------------------
set.seed(1786)
doses = c(0, 0.1, 0.5, 0.75, 1)
n.vec = c(30, 20, 23, 19, 32)
n.doses = length(doses)
models = Mods(doses = doses, linear = NULL, emax = 0.1, exponential = 0.2,
quadratic = -0.75, placEff = 1, maxEff = -0.3)
## Perform power-analysis
powMCTGen(n.vec, "binomial", "risk ratio", altModels = models, placEff = 0.9,
Ntype = "actual")
## Simulate the data according to the exponential curve
means = getResp(models)[,3]*0.9
cbind(Dose = doses, Means = means)
resp.dat = c()
for(i in 1:n.doses){
resp.dat = c(resp.dat, rbinom(1, size = n.vec[i], prob = means[i]))
}
bin.dat = data.frame(dose = doses, resp = resp.dat/n.vec, w = n.vec)
## Fit using the package
mod.pack = MCPModGen("binomial", "risk ratio", returnS = F, w = "w", dose = "dose", resp = "resp",
data = bin.dat, models = models, Delta = 0.1)
plot(mod.pack)
## Look at the MED estimate
mod.pack$doseEst[mod.pack$selMod]
TD(models, Delta = 0.1, direction = "decreasing")[3]
|
742f57bee0cc258d6d0ec1ddb7eb0b979940ffcf
|
8866f2576324045f7f57bf02b87433bd3ed34145
|
/R/ci_heatmap.R
|
4159e8b46bd8dada772d33a0f732c1682519b870
|
[] |
no_license
|
cran/rock
|
31ba91c6be5bff97c1659b3a8c3e5fbe6644f285
|
61999cb18c02680719a96b8ec3d0f33010849270
|
refs/heads/master
| 2022-12-26T21:02:05.960658
| 2022-12-13T11:30:02
| 2022-12-13T11:30:02
| 236,884,462
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 7,274
|
r
|
ci_heatmap.R
|
#' Create a heatmap showing issues with items
#'
#' When conducting cognitive interviews, it can be useful to quickly inspect
#' the code distributions for each item. These heatmaps facilitate that
#' process.
#'
#' @param x The object with the parsed coded source(s) as resulting from a
#' call to [rock::parse_source()] or [rock::parse_sources()].
#' @param nrmSpec Optionally, an imported Narrative Response Model
#' specification, as imported with [rock::ci_import_nrm_spec()], which will
#' then be used to obtain the item labels.
#' @param language If `nrmSpec` is specified, the language to use.
#' @param itemOrder,itemLabels Instead of specifying an NRM specification,
#' you can also directly specify the item order and item labels. `itemOrder`
#' is a character vector of item identifiers, and `itemLabels` is a named
#' character vector of item labels, where each value's name is the
#' corresponding item identifier. If `itemLabels` is provided but `itemOrder`
#' is not, the order of the `itemLabel` is used.
#' @param wrapLabels Whether to wrap the labels; if not `NULL`, the
#' number of character to wrap at.
#' @param itemIdentifier The column identifying the items; the class instance
#' identifier prefix, e.g. if item identifiers are specified as
#' `[[uiid:familySize_7djdy62d]]`, the `itemIdentifier` to pass here
#' is `"uiid"`.
#' @param codingScheme The coding scheme, either as a string if it represents
#' one of the cognitive interviewig coding schemes provided with the `rock`
#' package, or as a coding scheme resulting from a call
#' to [rock::create_codingScheme()].
#' @param itemlab,codelab,freqlab Labels to use for the item and code axes
#' and for the frequency color legend (`NULL` to omit the label).
#' @param plotTitle The title to use for the plot
#' @param fillScale Convenient way to specify the fill scale (the colours)
#' @param theme Convenient way to specify the [ggplot2::ggplot()] theme.
#'
#' @return The heatmap as a ggplot2 plot.
#' @export
#'
#' @examples examplePath <- file.path(system.file(package="rock"), 'extdata');
#' parsedCI <- rock::parse_source(
#' file.path(examplePath,
#' "ci_example_1.rock")
#' );
#'
#' rock::ci_heatmap(parsedCI,
#' codingScheme = "peterson");
ci_heatmap <- function(x,
nrmSpec = NULL,
language = nrmSpec$defaultLanguage,
wrapLabels = 80,
itemOrder = NULL,
itemLabels = NULL,
itemIdentifier = "uiid",
codingScheme = "peterson",
itemlab = NULL,
codelab = NULL,
freqlab = "Count",
plotTitle = "Cognitive Interview Heatmap",
fillScale = ggplot2::scale_fill_viridis_c(),
theme = ggplot2::theme_minimal()) {
if (!inherits(x, c("rock_parsedSource", "rock_parsedSources"))) {
stop("As `x`, pass one or more parsed sources (as resulting from ",
"a call to `rock::parse_source()` or `rock::parse_sources()`.");
}
if (is.character(codingScheme) && (length(codingScheme) == 1)) {
codingScheme <- get0(paste0("codingScheme_", codingScheme));
} else if (is.character(codingScheme) && (length(codingScheme) > 1)) {
codingScheme <- create_codingScheme(
id = "adHoc_codingScheme",
label = "Ad Hoc Coding Scheme",
codes = codingScheme
);
} else if (is.null(codingScheme)) {
codingScheme <- create_codingScheme(
id = "adHoc_codingScheme",
label = "Ad Hoc Coding Scheme",
codes = x$convenience$codingLeaves
);
}
if (!inherits(codingScheme, "rock_codingScheme")) {
stop("As `codingScheme`, pass either a codingScheme as created by ",
"a call to `rock::create_codingScheme()`, or the name of a ",
"coding scheme that exists in the `rock` package.");
}
if (!is.null(x$codeProcessing)) {
nrOfCodes <-
length(x$codeProcessing$ci$leafCodes);
} else {
nrOfCodes <- length(
names(x$inductiveCodeTrees$ci$children)
);
}
nrOfItems <-
length(stats::na.omit(unique(x$mergedSourceDf[, itemIdentifier])));
if (nrOfItems == 0) {
stop("No items were coded (or no valid item identifiers were ",
"specified)!");
}
if (nrOfCodes == 0) {
stop("No Cognitive Interviewing codes were found!");
}
if ((nrOfCodes*nrOfItems) < 2) {
stop("Only one item ('",
vecTxtQ(stats::na.omit(unique(x$mergedSourceDf[, itemIdentifier]))),
"') was coded with one code ('",
x$codeProcessing$ci$leafCodes,
"')!");
}
mergedSourceDf <- x$mergedSourceDf;
usedCodes <- intersect(
codingScheme$codes,
names(mergedSourceDf)
);
if (length(usedCodes) == 0) {
stop("None of the codes in coding scheme ", codingScheme$label,
" was used for the coded source(s)!");
return(invisible(NULL));
}
codeFrequencyTable <-
do.call(
rbind,
by(
data = mergedSourceDf[, usedCodes],
INDICES = mergedSourceDf[, itemIdentifier],
FUN = colSums
)
);
tidyCodeFrequencies <-
data.frame(
rep(rownames(codeFrequencyTable), ncol(codeFrequencyTable)),
rep(colnames(codeFrequencyTable), each=nrow(codeFrequencyTable)),
as.vector(codeFrequencyTable)
);
names(tidyCodeFrequencies) <- c(itemIdentifier, "code", "frequency");
### For convenience
newItemCol <- tidyCodeFrequencies[, itemIdentifier];
if (!is.null(nrmSpec)) {
validItemLabels <-
nrmSpec$items[[language]][
nrmSpec$itemIds_sorted %in%
newItemCol
];
} else {
if (is.null(itemOrder)) {
if (is.null(itemLabels)) {
itemOrder <- sort(unique(newItemCol));
} else {
itemOrder <- names(itemLabels);
}
}
if (is.null(itemLabels)) {
validItemLabels <-
stats::setNames(itemOrder, nm = itemOrder);
} else {
validItemLabels <-
itemLabels[itemOrder];
}
}
if (any(!(newItemCol %in% names(validItemLabels)))) {
validItemLabels <-
c(validItemLabels,
stats::setNames(
unique(newItemCol[!(newItemCol %in% names(validItemLabels))]),
nm = unique(newItemCol[!(newItemCol %in% names(validItemLabels))])
)
);
}
if (!is.null(wrapLabels)) {
validItemLabels <-
wrapVector(
validItemLabels,
wrapLabels
);
}
newItemCol <-
factor(
newItemCol,
levels = rev(names(validItemLabels)),
labels = rev(validItemLabels),
ordered = TRUE
);
tidyCodeFrequencies[, itemIdentifier] <-
newItemCol;
heatMap <-
rock::heatmap_basic(
data = tidyCodeFrequencies,
x = "code",
y = itemIdentifier,
fill = "frequency",
xLab = codelab,
yLab = itemlab,
fillLab = freqlab,
plotTitle = plotTitle,
fillScale = fillScale,
theme = theme
);
return(heatMap);
}
|
4d55897b692a549e4f08254df625659c5d7b4f00
|
da93a36d25fbf1f3c3072624d4b1cccbac3c127b
|
/R_scripts/chromHMM_block_potential.R
|
3c3327919d30abbe25db0c61ff442a86140376a8
|
[] |
no_license
|
hzauleibowen/TE_landscape
|
9a86db98d03c8d31e4ccba88fa22a11826bd21e4
|
52ed632ad84f6003c698cffbfc0321829ea57307
|
refs/heads/master
| 2023-05-08T03:21:45.733823
| 2020-06-10T19:20:33
| 2020-06-10T19:20:33
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 4,207
|
r
|
chromHMM_block_potential.R
|
# Creates a combined dataframe with the potential for TEs to be in each chromHMM state
# Using the standard rules, requiring overlap with the center of a 200bp bin,
# Or requiring overlap with the center of a chromHMM block
## block_potential: Number of samples each TE is in each chromHMM state, overlapping chromHMM block center
## summit_potential: Number of samples each TE is in each chromHMM state, overlapping chromHMM 200bp bin center
## state_sample_count_rules: Number of TEs in state per sample, all 3 rules, plus ratio of new to original results
## potential_ever: Proportion of TEs ever in each state, all 3 rules, plus ratio of new to original results
# Requiring overlap with chromHMM block center
## Number of TEs in state per sample
print("Load block per sample")
state_sample_count_blocks = read.table("chromHMM/block/rmsk_TE_block_summit_counts.txt",sep='\t',
col.names=c("State","Sample","Count"))
state_sample_count_blocks[1905,] = c("3_TxFlnk","E002",0)
state_sample_count_blocks$Count = as.numeric(state_sample_count_blocks$Count)
## Proportion of TEs ever in each state
print("Block ever")
### Number of samples each TE is in each chromHMM state
block_potential = read.table("chromHMM/block/rmsk_TE_block_potential.txt",sep = '\t',
col.names=c(TE_coordinates[c(1:4,6,5,7)],"State","Samples"))
block_potential_ever = ddply(block_potential,.(State),summarise,Ever=length(State[which(Samples > 0)])/NUM_TE)
# Requiring overlap with chromHMM 200bp bin center
## Number of TEs in state per sample
print("Load 200bp bin per sample")
state_sample_count_summit = read.table("chromHMM/state_sample_counts_summit_only.txt",sep='\t',
col.names=c("Sample","State","Count"))
state_sample_count_summit[1905,] = c("E002","3_TxFlnk",0)
state_sample_count_summit$Count = as.numeric(state_sample_count_summit$Count)
## Proportion of TEs ever in each state
print("Summit ever")
### Number of samples each TE is in each chromHMM state,
### Filtered to only TEs that overlap the center of a 200bp bin center
summit_potential = chromHMM_TE_state[which(chromHMM_TE_state$Category == "summit"),]
### Number of TEs in each state at each number of samples
summit_potential_dist = sample_distribution(summit_potential,c(8:22),sample_counts["All","chromHMM"])
summit_potential_dist = melt(summit_potential_dist,id.var="Samples",variable.name="State",value.name="Count")
summit_potential_ever = ddply(summit_potential_dist,.(State),summarise,Ever=sum(Count[which(Samples > 0)])/NUM_TE)
# Combine dataframes for all 3 rules
## Number of TEs in state per sample
print("Combine per sample")
state_sample_count_rules = merge(merge(state_sample_count[,c("State","Sample","Count")],
state_sample_count_blocks,by=c("State","Sample")),
state_sample_count_summit,by=c("State","Sample"))
colnames(state_sample_count_rules)[3:5] = c("Count","Block","Summit")
state_sample_count_rules = melt(state_sample_count_rules[,c("State","Sample","Count","Block","Summit")],id.vars=c("State","Sample","Count"),
variable.name="Category",value.name="Count.Filter")
### Divide number of TEs in state per sample using new rule by number using standard rule
state_sample_count_rules$Ratio = state_sample_count_rules$Count.Filter/state_sample_count_rules$Count
rm(list=c("state_sample_count_blocks","state_sample_count_summit"))
## Proportion of TEs ever in each state
print("Combine ever")
potential_ever = merge(merge(chromHMM_TE_state_dist_stats[,c("Proportion_ever","State")],block_potential_ever,by="State"),
summit_potential_ever,by="State")
colnames(potential_ever)[3:4] = c("Block","Summit")
potential_ever = melt(potential_ever,id.vars=c("State","Proportion_ever"),
variable.name="Category",value.name="Proportion_ever.Filter")
### Divide proportion of TEs ever in state using new rule by number using standard rule
potential_ever$Ratio = potential_ever$Proportion_ever.Filter/potential_ever$Proportion_ever
rm(list=c("block_potential_ever","summit_potential_dist","summit_potential_ever"))
|
7da6f4dfe178f7e2f0960500614317924728bd40
|
d4acf50c38fa67affec3cf9feaaa0d0ab3fbe083
|
/basic api and NPL copy.R
|
5c894968907e02d602b4d0857bd5c256969324b3
|
[] |
no_license
|
crimono/group2_project
|
b0fbab38e0cbacdd1860b868bfbb96908db1ac62
|
f7d683cc868aada0944492938981860a9676a4d5
|
refs/heads/master
| 2020-04-08T12:25:32.707091
| 2018-12-19T19:00:01
| 2018-12-19T19:00:01
| 159,346,902
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 3,716
|
r
|
basic api and NPL copy.R
|
library("rtweet")
library("SentimentAnalysis")
library("plyr")
library("sentimentr")
#state dataset built in r in order to get the center of each state
#compute the radius and build the geocode string for the twitter download
usa <- as.data.frame(state.x77)
for (i in 1:50){
usa$x[i] <- state.center$x[i]
usa$y[i] <- state.center$y[i]
}
usa$Radius <- sqrt(usa$Area/3.14)
usa$Miles <- paste0(usa$Radius , "mi")
usa$geocode <- paste0(usa$y ,",", usa$x,",", usa$Miles)
#delete hawaii because almost no tweets there
rownames(usa)[11]
usa <- usa[-11,]
#----------
#Gathering all tweets in one data frame
#solution 1
# rows_per_state <- 1000
# twitter_data_group <- NULL
#
# for (i in 1:5) {
#
# if(is.null(twitter_data_group)) {
# twitter_data_group<- search_tweets(n = 1000, geocode = usa$geocode[i] ,
# lang = "en",
# include_rts = FALSE)
# twitter_data_group$state <- rownames(usa)[i]
#
# } else {
#
# tmp <- search_tweets(n = 1000, geocode = usa$geocode[i] ,
# lang = "en",
# include_rts = FALSE)
# tmp$state <- names(usa)[i]
#
# twitter_data_group <- rbind(twitter_data_group, tmp)
#
# }
#
#
# }
#solution2
# twitter_data_group <- list()
# for (i in 1:5) {
#
# twitter_data_group[[i]] <- search_tweets(n = 1000, geocode = usa$geocode[i] ,
# lang = "en",
# token = NULL,
# include_rts = FALSE,
# retryonratelimit = FALSE)
# twitter_data_group[[i]]$state <- rownames(usa)[i]
# }
# twitter_data <- rbind.fill(twitter_data_group)
# unique(twitter_data$state)
#----------
# Filtering dataset
# Keep only the useful columns
twitter_data_filtered <- twitter_data[, c(1, 3, 4, 5, 6, 13)]
as.data.frame(twitter_data_filtered)
#Take out the favorite_counts larger than 3*sd(favorite_count)
fav_restricted <- function(fav_limit)
twitter_data_filtered$happiness <- sentiment_by(twitter_data_filtered$text)
#----------
# Plot the frequency of the tweets of the last 9 days
ts_plot(tw, "3 hours") +
ggplot2::theme_minimal() +
ggplot2::theme(plot.title = ggplot2::element_text(face = "bold")) +
ggplot2::labs(
x = NULL, y = NULL,
title = "Frequency of #rstats Twitter statuses from past 9 days",
subtitle = "Twitter status (tweet) counts aggregated using three-hour intervals",
caption = "\nSource: Data collected from Twitter's REST API via rtweet"
)
#----------
# Plotting the data on a US map
tw <- lat_lng(tw)
## plot state boundaries
par(mar = c(0, 0, 0, 0))
maps::map("state", lwd = .25)
with(tw, points(lng, lat, pch = 20, cex = .75, col = rgb(0, .3, .7, .75)))
#----------
#sentiment analysis
sentiment <- analyzeSentiment(tw$text)
sentiment$SentimentQDAP <= -0.4
sentiment$SentimentQDAP[780]
max(sentiment$SentimentQDAP)
documents <- c("which")
analyzeSentiment(documents)$SentimentQDAP
tw$text[375]
##################################
## random sample for 30 seconds (default)
rt <- stream_tweets("")
#Stream all geo enabled tweets from London for 60 seconds.
## stream tweets from london for 60 seconds
rt <- stream_tweets(lookup_coords("california, US"), timeout = 30)
#Stream all tweets mentioning realDonaldTrump or Trump for a week.
## stream london tweets for a week (60 secs x 60 mins * 24 hours * 7 days)
stream_tweets(
"realdonaldtrump,trump",
timeout = 60 * 60 * 24 * 7,
file_name = "tweetsabouttrump.json",
parse = FALSE
)
## read in the data as a tidy tbl data frame
djt <- parse_stream("tweetsabouttrump.json")
|
28aa2b7714b1f21106c256b856166e86d2aacea5
|
cb4abb6553d4697cefdc10b4de027f83fafdceb7
|
/2.2.r
|
e57c2e965df5664bdbec6d0aab13106de4843b2d
|
[] |
no_license
|
royb3/statistiekMetR
|
f90b4a0bd00bb7495637106365dcdd1697aa549b
|
0df60a4fa661020d58f489b7b92095694d8388e2
|
refs/heads/master
| 2021-01-10T22:04:17.351092
| 2015-10-29T07:37:11
| 2015-10-29T07:37:11
| 42,578,771
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,127
|
r
|
2.2.r
|
#2.2a
nValue2a <- 2*30
kValue2a <- 20+15
answer2a <- factorial(nValue2a) / factorial(nValue2a - kValue2a)
print(paste("2a = ", format(answer2a)))
#2.2b
nValue2b <- 2*30
kValue2b <- 20+15
answer2b <- factorial(nValue2b) / (factorial(kValue2b) * factorial(nValue2b - kValue2b))
print(paste("2b = ", format(answer2b)))
#2.2c
n1Value2c <- 30
n2Value2c <- 30
k1Value2c <- 20
k2Value2c <- 15
answer2c <- (factorial(n1Value2c) / (factorial(k1Value2c) * factorial(n1Value2c - k1Value2c))) + (factorial(n2Value2c) / (factorial(k2Value2c) * factorial(n2Value2c - k2Value2c)))
print(paste("2c = ", format(answer2c)))
#2.2d
n1Value2d <- 30
n2Value2d <- 30
k1Value2d <- 35
k2Value2d <- k1Value2d - n1Value2d
answer2d <- (factorial(k1Value2d) - factorial(k2Value2d)) * (factorial(n2Value2d) / factorial(n2Value2d - k2Value2d))
print(paste("2d = ", format(answer2d)))
#2.2e
n1Value2e <- 25
n2Value2e <- 30
k1Value2e <- 30
k2Value2e <- k1Value2e - n1Value2e
answer2e <- factorial(n1Value2e) * (factorial(k1Value2e) - factorial(k2Value2e)) * (factorial(n2Value2e) / factorial(n2Value2e - k2Value2e))
print(paste("2e = ", format(answer2e)))
|
f71ee827edf4bdcaa68feec402903ed000766ed9
|
4c38de2cc0b8cb8372a4d54a28ba7b1c4c572f75
|
/Code/Twitter_Data.R
|
f5fad11fb873f474a79dc091b459a23957fd9917
|
[] |
no_license
|
kalaamlabs/Streaming-Analytics-using-Hive
|
3c8258ff19c8f0c450f6bbdaaa47e6230502cc67
|
e8a8d1ec575a29f08bdf820f558a053ef03a4dfc
|
refs/heads/master
| 2021-05-14T16:54:44.637606
| 2016-10-12T17:55:16
| 2016-10-12T17:55:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 2,331
|
r
|
Twitter_Data.R
|
setwd("C:\")
#devtools::install_version("httr", version="0.6.0", repos="http://cran.us.r-project.org")
#install.packages("httr")
library(RCurl)
library(ROAuth)
library(streamR)
library(twitteR)
library(base64enc)
library(httr)
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
#my_oauth$handshake(cainfo="cacert.pem")
# Configuration for twitter
outFile<- "tweets_sample_search_nw.json"
# Twitter configuration
requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
consumerKey <- "VpTHLu545XeINpVWqrK7c1Llo"
consumerSecret <- "GWk6gvVg7NSBTYOASDIncghUKYKrkeefwFc10IwRzu4UWBAFHf"
oauth_token <- "274318371-YRmazd56HdJwFUDYpPaJazVB7MicWd3EnlMIrdua"
oauth_token_secret <- "tk6GB35e47hmnmtXMAImk6CmYMUdEsHaWg9wfV8eCrzBf"
my_oauth <- OAuthFactory$new( consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=requestURL,
accessURL=accessURL, authURL=authURL)
my_oauth$handshake(cainfo="cacert.pem")
#registerTwitterOAuth(my_oauth)
setup_twitter_oauth(consumerKey, consumerSecret, oauth_token, oauth_token_secret)
# Run Twitter Search. Format is searchTwitter("Search Terms", n=100, lang="en", geocode="lat,lng", also accepts since and until).
tweets <- searchTwitter("#SuicideSquad", n=9999, lang="en", since="2016-08-01")
# Transform tweets list into a data frame
tweets.df <- twListToDF(tweets)
# Use the searchTwitter function to only get tweets within 50 miles of Los Angeles
tweets_geolocated <- searchTwitter("'Suicide Squad' OR #SuicideSquad", n=100, lang="en", geocode='34.04993,-118.24084,50mi', since="2016-08-01")
tweets_geoolocated.df <- twListToDF(tweets_geolocated)
# Get all tweets
sampleStream( file=outFile, oauth=my_oauth )
|
dd03d69499f485c4553540b968383534c4411fb6
|
2ef7bff5de5b8ba586c21057524eb5823e763197
|
/R/predict.dsm.R
|
272a453cfde311c8a83f01d937c87da476459891
|
[] |
no_license
|
dill/dsm
|
3ec6fa21a979d378b70627b3dc686d40abd48b65
|
cc8f82b89ae6c6091d0ad1b27094ba0bdd351554
|
refs/heads/master
| 2021-01-18T12:18:08.019145
| 2014-02-18T16:12:40
| 2014-02-18T16:12:40
| 3,394,162
| 2
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,813
|
r
|
predict.dsm.R
|
#' Predict from a fitted density surface model
#'
#' Make predictions outside (or inside) the covered area.
#'
#' @param object a fitted \code{\link{dsm}} object as produced by \code{dsm()}.
#' @param newdata spatially referenced covariates e.g. altitude, depth,
#' distance to shore, etc. Note covariates in this dataframe must have names
#' *identical* to variable names used in fitting the DSM.
#' @param off.set area of each of the cells in the prediction grid. Ignored if
#' their is already a column in \code{newdata} called \code{off.set}.
#' @param type what scale should the results be on. The default is
#' \code{"response"}, see \code{\link{predict.gam}} for an explanation of other
#' options (usually not necessary).
#' @param \dots any other arguments passed to \code{\link{predict.gam}}.
#' @return predicted values on the response scale (density/abundance).
#'
#' @S3method predict dsm
#' @method predict dsm
#' @aliases predict.dsm
#'
#' @author David L. Miller
predict.dsm <- function(object, newdata=NULL, off.set=NULL,
type="response",...){
if("gamm" %in% class(object)){
object <- object$gam
}
if(is.null(newdata)){
newdata <- object$data
}
# if we don't have a density model, then set the offset
if(!(c(object$formula[[2]]) %in% c("D","presence","density"))){
if(is.null(newdata$off.set)){
if(is.null(off.set)){
stop("You must supply off.set in data or as an argument.")
}
newdata$off.set <- off.set
}
# apply the link function
linkfn <- object$family$linkfun
newdata$off.set <- linkfn(newdata$off.set)
}
# remove the dsm class
class(object) <- class(object)[class(object)!="dsm"]
# actually do the predict call
result<-predict(object, newdata, type=type,...)
return(result)
}
|
49363cef69bea0e8eb319789d27c8478c5db1e74
|
3af91945083aa604efc778ea52a17ad60766948b
|
/matthew_Patient-overlap-jcedited.R
|
8fa818f58a891281712586d4c0e59ed9b5483775
|
[] |
no_license
|
cjieming/R_codes
|
fa08dd1f25b22e4d3dec91f4fb4e598827d7492f
|
5b2bcf78dc217bc606c22f341e1978b5a1246e0c
|
refs/heads/master
| 2020-04-06T03:53:50.030658
| 2019-06-30T07:31:35
| 2019-06-30T07:31:35
| 56,031,249
| 0
| 2
| null | null | null | null |
UTF-8
|
R
| false
| false
| 2,892
|
r
|
matthew_Patient-overlap-jcedited.R
|
#################################################################
## this script is adapted from Matthew Kan's script in plotting
## Patient-overlap in AD-studies
setwd("/Users/jiemingchen/Documents/transplantation/a_donor/immport")
library(RImmPort)
library(DBI)
library(sqldf)
library(plyr)
library(RMySQL)
library(dplyr)
## input data
mydata = read.table("studies_overlapping_samples.txt", header = T, sep = "\t", stringsAsFactors = FALSE)
## preparing the dataset
studies = as.data.frame(unique(mydata$STUDYID), stringsAsFactors = FALSE ); names(studies) = "id"
studies$size = apply(studies, 1, function(x) nrow(mydata[mydata$STUDYID == x,]))
studies_subj = lapply(studies$id, function(x) mydata[mydata$STUDYID == x,]$USUBJID)
names(studies_subj) = studies$id
## form overlapping matrix of overlapping number of individuals
a = lapply(studies_subj, function(x) lapply(studies_subj, function(y) length(intersect(x,y))))
b = do.call(cbind, a) ## note that this is a 2D matrix
a_p = lapply(studies_subj, function(x) lapply(studies_subj, function(y) length(intersect(x,y))/length(x)*100 ))
b_p = do.call(cbind, a_p) ## note that this is a 2D matrix
##############################
## plot
## Square Pie function
squarePie <- function(pct, col="black", col.grid="#e0e0e0", col.border="black", main="") {
if (pct > 100) {
pct <- 100
warning("Percentage value, pct, should be an integer between 0 and 100")
} else if (pct < 0) {
pct <- 0
warning("Percentage value, pct, should be an integer between 0 and 100.")
}
# Round to nearest integer
pct <- round(pct)
# x- and y-coordinates of rows and columns
x_row <- 1:10
y_col <- 1:10
# put together full coordinate vectors
x <- rep(x_row, 10)
y <- rep(y_col, each=10)
# set colors
fill_col <- c(rep(col, pct), rep("#ffffff", 100-pct))
# plot
plot(0, 0, type="n", xlab="", ylab="", main=main, xlim=c(0, 11), ylim=c(0, 10.5), asp=1, bty="n", axes=FALSE)
symbols (x, y, asp=1, squares=rep(1,100), inches=FALSE, add=TRUE, bg=fill_col, fg=col.grid, lwd=0.5)
rect(.5, .5, 10.5, 10.5, lwd=2, border=col.border)
}
## Generating a matrix of square Pis
x11(type="cairo")
par(mfrow = c(nrow(studies), nrow(studies)), mar = c(0, 0, 0, 0))
mapply(squarePie, b_p, col.grid=NA, col="#007CBE", col.border="#B4B9BF")
## original code cant weave the coloring of diag vs nondiag into mapply
## for later improvements?
# for(i in 1:10) {
# for(j in 1:10) {
# if (i!=j) {
# border_color = "#B4B9BF"
# squarePie(percentage_overlap[i, j], col.grid=NA, col="#007CBE", col.border=border_color)
# } else {
# border_color = "#000000"
# squarePie(percentage_overlap[i, j], col.grid=NA, col="#e0e0e0", col.border=border_color)
# }
# if (overlaps[i, j] > 0) {
# text(5.5, 5.5, overlaps[i, j], font=2, cex=1.5, family = "Roboto")
# }
# }
# }
|
883029ff91ede28a0b888e6de497b0c3e7e169c2
|
3edd74c94cfb00593982abd66986897a8b35c350
|
/man/djqpd.Rd
|
f890cc8bbdb2371385b51223b135e428bb3a943a
|
[
"MIT"
] |
permissive
|
bobbyingram/rjqpd
|
f83abad29998e71eb4c655a9ead406165ade2cfd
|
ddcbf480393eb1bf2739cd28638d799f1cd6323c
|
refs/heads/master
| 2022-12-24T14:02:11.375062
| 2020-09-28T20:17:13
| 2020-09-28T20:17:13
| 289,718,873
| 2
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 636
|
rd
|
djqpd.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/djqpd.R
\name{djqpd}
\alias{djqpd}
\title{Density function of Johnson Quantile-Parameterised Distribution.}
\usage{
djqpd(x, params)
}
\arguments{
\item{x}{vector of quantiles}
\item{params}{jqpd object created using \code{jqpd()}}
}
\value{
A numeric vector of density values corresponding to the x quantile
vector
}
\description{
Density function of Johnson Quantile-Parameterised Distribution.
}
\examples{
x <- c(0.32, 0.40, 0.60)
params <- jqpd(x, lower = 0, upper = 1, alpha = 0.1)
iles <- seq(0.01, 0.99, 0.01)
density <- djqpd(x = iles, params)
}
|
3df852dba069971ba2510eb11879f18083e09b34
|
520246ced10aa690003c1c4658480b43bfdd38cf
|
/server.R
|
12886bdfcda480d6f64286ecdb0c096c8d2ad1a0
|
[] |
no_license
|
DNAReplicationLab/plotGenome
|
aa95873aff602009d542b055edac3c55d6a27fe7
|
f521dcbc4691bb918b2e8166168745545fccbb02
|
refs/heads/master
| 2020-03-28T10:50:07.258601
| 2018-11-08T15:22:21
| 2018-11-08T15:22:21
| 148,150,123
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 71,162
|
r
|
server.R
|
library(shiny)
library(ggplot2)
library(colourpicker)
source("plotGenomeFunctions.R")
load("www/plotGenome.RData")
options(shiny.maxRequestSize=30*1024^2,shiny.trace=F,shiny.fullstacktrace=F,shiny.testmode=F)
function(input,output,session) {
## initialise reactive values here
names <- reactiveValues(
bed = NULL,
plot = NULL,
currentRatio = NULL,
ratio = data.frame(name.rep=character(),name.nonRep=character(),name=character(),stringsAsFactors=F)
)
DFs <- reactiveValues(
bed = NULL,
rep = list(),
nonRep = list(),
ratio = NULL,
ratios2add = data.frame(
name.rep=character(),
name.nonRep=character()
),
ratios = NULL,
guide = data.frame(
order=integer(),
name.rep=character(),
name.nonRep=character(),
raw=logical(),
smooth=logical(),
color=character(),
stringsAsFactors=F
),
stats = NULL,
lines = NULL,
circles = NULL,
rectangles = NULL,
pointers = NULL,
Lines = NULL,
Circles = NULL,
Rectangles = NULL,
Pointers = NULL
)
plots <- reactiveValues(coveragePlot = NULL, ratioPlot = NULL, genomePlot = NULL, statsPlot = NULL)
toggles <- reactiveValues(
bedCtrlsIn = F,
bedEdited = F,
coverage = F,
isExampleCoverage = F,
ratioCtrlsIn = F,
isExampleRatio = F,
plotCtrlsIn = F,
isExamplePlot = F,
isExampleStats = F,
coverageRegion = F,
plotRegion = F,
statSelectIn = F,
statsCtrlsIn = F,
statsRegion = F
)
values <- reactiveValues(
newRatioFactor = NULL,
oldRatioFactor = NULL,
availableRatios = NULL,
#~ plotFeatures = c("vLine"="lines","Circle"="circles","Rectangle"="rectangles","Pointer"="pointers"),
#~ statsPlotFeatures = c("vLine"="Lines","Circle"="Circles","Rectangle"="Rectangles","Pointer"="Pointers"),
i = NULL
)
######################################################## COVERAGE TAB ################################################################
#~ ~~~~~~~~~~~~~~~~~~~~~~ BED: Load bed ~~~~~~~~~~~~~~~~~~~~~~~~
observeEvent(input$bedFile, {
if (!is.null(input$bedFile)) {
## direct action
names$bed <- gsub("\\.bed$","",input$bedFile$name)
DFs$bed <- loadBed(input$bedFile$datapath,fname=names$bed)
toggles$bedCtrlsIn <-F
if (toggles$coverage == T) { toggles$coverage <- F }
if (toggles$isExampleCoverage == T) { toggles$isExampleCoverage <- F }
## changes to the side panel
removeUI(selector='#analyseButton')
removeUI(selector='#resetBed')
insertUI(selector='#analyseOrReset',where="afterBegin",ui=actionButton("analyseButton","Analyse"))
## changes to the main panel
removeUI(selector='#coverageDescription')
plots$coveragePlot <- NULL
insertUI(selector='#coverageMain',where="afterBegin",ui=tableOutput("bedContent"))
}
})
## outputs
output$bedContent <- renderTable(DFs$bed[1:7,])
#~ ~~~~~~~~~~~~~~~~~~~~ BED: Load example ~~~~~~~~~~~~~~~~~~~~~~~
observeEvent(input$exampleCoverage, {
removeUI(selector='#coverageDescription')
toggles$isExampleCoverage <- T
if (toggles$bedCtrlsIn == F) toggles$bedCtrlsIn <- T
})
#~ ~~~~~~~~~~~~~~~~~~~~ BED: Analyse bed ~~~~~~~~~~~~~~~~~~~~~~~~
observeEvent(input$analyseButton, {
if (toggles$bedCtrlsIn == F) toggles$bedCtrlsIn <- T
})
#~ ~~~~~~~~~~~~~~~~~~ BED: Interface toggle ~~~~~~~~~~~~~~~~~~~~~
observeEvent(toggles$bedCtrlsIn, {
if (toggles$bedCtrlsIn == T) {
if (toggles$coverage == T) { toggles$coverage <- F }
if (toggles$isExampleCoverage == T) {
DFs$bed <- example[["bed"]]
names$bed <- "Dbf4_S"
}
## changes to the side panel
#~ removeUI(selector='#tmpCoverageSide')
removeUI(selector='#analyseButton')
removeUI(selector='#exampleCoverageDiv')
insertUI(selector='#coverageSide',where="beforeEnd",ui=HTML(
"<div id='bedSideCtrls'>
<div id='rmChr'>
<hr>
<div class='myTooltip'><label>Remove chromosome</label><span class='myTooltiptext'>
This allows you to remove all data from individual chromosomes
</span></div>
<div class='description'>Mitochondrial DNA is usually excluded from analysis.</div>
<div style='padding-left:10px;'>
<div id='rmChrInputDiv' class='inline' style='width:30%;margin-bottom:-5px;min-width:75px;'></div>
<div id='rmChrButtonDiv' class='inline'></div>
</div>
</div>
<div id='rmMax'>
<hr>
<div class='myTooltip'><label>Remove max value</label><span class='myTooltiptext'>
Use this to remove one or more top outliers
</span></div>
<div class='description'>Remove individual outlier(s) with highest score.</div>
<div style='padding-left:10px;'>
<div id='rmMaxTimesInput' class='inline' style='width:20%;min-width:50px;'></div>
<div id='rmMaxButton' class='inline'></div>
</div>
</div>
<div id='rmOutliersDiv'>
<hr>
<div class='myTooltip'><label>Remove outliers (IQR)</label><span class='myTooltiptext'>
Only use this if data is noisy for all the chromosomes
</span></div>
<div class='description'>
Outliers (highlighted in grey) are either 3×IQR (interquartile range) or more above the third quartile
or 3×IQR or more below the first quartile.<br>
<b>Do not use</b> if only a few chromosomes appear noisy.<br>
<b>Do not use</b> more than once.
</div>
<div id='rmOutliers' style='padding-left:10px;'></div>
</div>
<div id='rmOutliersManDiv'>
<hr>
<div class='myTooltip'><label>Remove outliers (manual)</label><span class='myTooltiptext'>
Typically, values less than 0.25*<b>median</b> are removed
</span></div>
<div class='description'>
Specify minimum and/or maximum proportion of dataset median (pink line across) each bin should have.
Bins that contain fewer than Min*Median or more that Max*Median reads per bin will be discarded.
</div>
<div id='rmOutliersManMin' class='inline' style='padding-left:10px;width:20%;'></div>
<div id='rmOutliersManMax' class='inline' style='padding-left:5px;width:20%;'></div>
<div id='rmOutliersManBtn' class='inline' style='padding-left:20px;width:40%;'></div>
</div>
<div>
<div id='scatterPlotButtonDiv' style='text-align: center;'><hr></div>
</div>
</div>"
))
insertUI(selector='#rmChrInputDiv',where="beforeEnd",ui=uiOutput("chrRmOutput"))
insertUI(selector='#rmChrButtonDiv',where="beforeEnd",ui=actionButton("rmChrButton","Remove chromosome"))
insertUI(selector='#rmMaxTimesInput',where="beforeEnd",ui=textInput("rmMaxTimes",NULL,1,width="90%"))
insertUI(selector='#rmMaxButton',where="beforeEnd",ui=actionButton("rmMaxButton","Remove max values"))
insertUI(selector='#rmOutliers',where="beforeEnd",ui=actionButton("rmOutButton","Remove outliers"))
insertUI(selector='#rmOutliersManMin',where="afterBegin",ui=textInput(
"rmOutliersManMinInput",NULL,NULL,width="90%",placeholder="Min"
))
insertUI(selector='#rmOutliersManMax',where="afterBegin",ui=textInput(
"rmOutliersManMaxInput",NULL,NULL,width="90%",placeholder="Max"
))
insertUI(selector='#rmOutliersManBtn',where="afterBegin",ui=actionButton("rmOutliersManButton","Remove outliers"))
insertUI(
selector='#scatterPlotButtonDiv',
where="beforeEnd",
ui=actionButton("scatterPlotButton","Switch to scatter plot view")
)
## changes to the main panel
removeUI(selector='#bedContent')
insertUI(selector='#coverageMain',where="afterBegin",ui=HTML("
<div id='bedMainCtrls'>
<div id='coveragePlotDiv'></div>
<div id='outlierInfoDiv' style='text-align:center;padding-left:5%;max-width:1000px;'>
<div id='outlierDiv'><label>Hover over datapoints to display their properties</label></div>
</div>
</div>
"))
insertUI(
selector='#coveragePlotDiv',
where="afterBegin",
ui=plotOutput(
"coveragePlot",
hover=hoverOpts(id="outliers"),
width="100%",
height=500
)
)
insertUI(selector='#outlierDiv',where="beforeEnd",ui=verbatimTextOutput("outlierInfo"))
insertUI(selector='#bedMainCtrls',where="beforeEnd",ui=HTML(
"<div id='saveBedDiv'>
<div id='saveBedFurther' class='inline''>
<b style='display:block;padding: 20px;'>Save the data for further analysis:</b>
<div id='bedSaveSelect' class='inline' style='width:20%;min-width:100px;'></div>
<div id='bedSaveName' class='inline' style='width:30%;min-width:100px;'></div>
<div id='bedSaveButton' class='inline'></div>
</div>
<div class='inline'>
<b style='display:block;padding: 20px;'>Save data locally:</b>
<div id='downloadCoveragePlot' class='inline'></div>
</div>
</div>"))
insertUI(
selector='#bedSaveSelect',
where="afterBegin",
ui=selectInput("bedType",NULL,c("Sample type"="","Replicating"="rep","Non-replicating"="nonRep"))
)
insertUI(selector='#bedSaveName',where="afterBegin",ui=textInput("bedName",NULL,names$bed))
insertUI(selector='#bedSaveButton',where="afterBegin",ui=actionButton("saveBed","Save data"))
insertUI(selector='#downloadCoveragePlot',where="afterBegin",ui=downloadButton("downloadCoveragePlot","Download plot"))
insertUI(selector='#downloadCoveragePlot',where="beforeEnd",ui=downloadButton("downloadCoverageCSV","Download data"))
names$plot <- names$bed
## direct action
plots$coveragePlot <- gplotBed(DFs$bed,plotting=F)
} else {
removeUI(selector='#bedSideCtrls')
removeUI(selector='#bedMainCtrls')
}
})
## outputs
output$coveragePlot <- renderPlot(plots$coveragePlot)
output$outlierInfo <- renderPrint({
nearPoints(DFs$bed,input$outliers,threshold=10,maxpoints=1)
})
#~ ~~~~~~~~~~~~~~~~ BED: Cleanse bed ~~~~~~~~~~~~~~~~~~
observeEvent(input$rmChrButton, {
if (input$chrRm!="") {
DFs$bed <- rmChr(DFs$bed,input$chrRm)
if (toggles$bedEdited == F) {
#~ insertUI(selector='#loadBedDiv',where="afterEnd",ui=HTML("<div id='resetBedDiv' class='inline' style='padding-top:25px;'></div>"))
insertUI(selector='#analyseOrReset',where="afterBegin",ui=actionButton("resetBed","Reset"))
toggles$bedEdited <- T
}
if (toggles$coverage == F) {
plots$coveragePlot <- gplotBed(DFs$bed)
} else {
plots$coveragePlot <- plotCoverage(DFs$bed)
}
}
})
## outputs
output$chrRmOutput <- renderUI({
chrList <- levels(DFs$bed$chrom)
selectInput("chrRm",NULL,c("Select"="",chrList),width="90%")
})
observeEvent(input$rmMaxButton, {
if (input$rmMaxTimes!="") {
DFs$bed <- rmMax(DFs$bed,input$rmMaxTimes)
if (toggles$bedEdited == F) {
#~ insertUI(selector='#loadBedDiv',where="afterEnd",ui=HTML("<div id='resetBedDiv' class='inline' style='padding-top:25px;'></div>"))
insertUI(selector='#analyseOrReset',where="afterBegin",ui=actionButton("resetBed","Reset"))
toggles$bedEdited <- T
}
if (toggles$coverage == F) {
plots$coveragePlot <- gplotBed(DFs$bed)
} else {
plots$coveragePlot <- plotCoverage(DFs$bed)
}
}
})
observeEvent(input$rmOutButton, {
DFs$bed <- rmOutliers(DFs$bed)
if (toggles$bedEdited == F) {
#~ insertUI(selector='#loadBedDiv',where="afterEnd",ui=HTML("<div id='resetBedDiv' class='inline' style='padding-top:25px;'></div>"))
insertUI(selector='#analyseOrReset',where="afterBegin",ui=actionButton("resetBed","Reset"))
toggles$bedEdited <- T
}
if (toggles$coverage == F) {
plots$coveragePlot <- gplotBed(DFs$bed)
} else {
plots$coveragePlot <- plotCoverage(DFs$bed)
}
})
observeEvent(input$rmOutliersManButton, {
if (input$rmOutliersManMinInput!="" & input$rmOutliersManMaxInput=="") {
DFs$bed <- rmOutliersMan(DFs$bed,loLim=input$rmOutliersManMinInput)
}
if (input$rmOutliersManMinInput=="" & input$rmOutliersManMaxInput!="") {
DFs$bed <- rmOutliersMan(DFs$bed,hiLim=input$rmOutliersManMaxInput)
}
if (input$rmOutliersManMinInput!="" & input$rmOutliersManMaxInput!="") {
DFs$bed <- rmOutliersMan(DFs$bed,loLim=input$rmOutliersManMinInput,hiLim=input$rmOutliersManMaxInput)
}
if (toggles$bedEdited == F) {
insertUI(selector='#analyseOrReset',where="afterBegin",ui=actionButton("resetBed","Reset"))
toggles$bedEdited <- T
}
if (toggles$coverage == F) {
plots$coveragePlot <- gplotBed(DFs$bed)
} else {
plots$coveragePlot <- plotCoverage(DFs$bed)
}
})
#~ ~~~~~~~~~~~~~~~~ BED: Box/Scatter plot switch ~~~~~~~~~~~~~~~~~~
observeEvent(input$scatterPlotButton, {
## changes to the side panel
removeUI(selector='#scatterPlotButton')
removeUI(selector='#rmMax')
removeUI(selector='#rmOutliersDiv')
insertUI(
selector="#scatterPlotButtonDiv",
where="beforeBegin",
ui=HTML(
"<div id='coverageRegion'>
<hr>
<div class='myTooltip'><label>Select region to plot</label><span class='myTooltiptext'>
Focus on a chromosome or a smaller reagion
</span></div>
<div style='padding-left:10px;'>
<div id='coverageChrDiv' class='inline' style='width:20%;'></div>
<div id='coverageChrStartDiv' class='inline' style='width:25%;'></div>
<div id='coverageChrEndDiv' class='inline' style='width:25%;'></div>
<div id='coverageRegionButtonDiv' class='inline'></div>
</div>
<div style='padding-left:10px;'>
<div id='resetRegion' class='inline'></div>
</div>
</div>"
)
)
insertUI(selector="#coverageChrDiv",where="afterBegin",ui=uiOutput('coverageChrOut',width="90%"))
insertUI(
selector="#coverageChrStartDiv",
where="afterBegin",
ui=textInput('coverageChrStart',NULL,NULL,width="95%",placeholder='Start')
)
insertUI(
selector="#coverageChrEndDiv",
where="afterBegin",
ui=textInput('coverageChrEnd',NULL,NULL,width="95%",placeholder='End')
)
insertUI(selector="#coverageRegionButtonDiv",where="afterBegin",ui=actionButton('coverageRegionButton',"Plot region"))
insertUI(
selector="#scatterPlotButtonDiv",
where="beforeEnd",
ui=actionButton('boxPlotButton',"Switch to box plot view")
)
## changes to the main panel
removeUI(selector='#coveragePlot')
removeUI(selector='#outlierDiv')
insertUI(
selector='#bedMainCtrls',
where="afterBegin",
ui=plotOutput(
"coveragePlot",
width=990,
height=1200
)
)
## direct action
plots$coveragePlot <- plotCoverage(DFs$bed,plotting=F)
toggles$coverage <- T
})
observeEvent(input$boxPlotButton, {
## changes to the side panel
removeUI(selector='#coverageRegion')
removeUI(selector='#boxPlotButton')
insertUI(selector="#rmChr", where="afterEnd", ui=HTML("
<div id='rmMax'>
<hr>
<div class='myTooltip'><label>Remove max value</label><span class='myTooltiptext'>
Use this to remove one or more top outliers
</span></div>
<div class='description'>Remove individual outlier(s) with highest score.</div>
<div style='padding-left:10px;'>
<div id='rmMaxTimesInput' class='inline' style='width:20%;min-width:50px;'></div>
<div id='rmMaxButton' class='inline'></div>
</div>
</div>
<div id='rmOutliersDiv'>
<hr>
<div class='myTooltip'><label>Remove outliers (IQR)</label><span class='myTooltiptext'>
Only use this if data is noisy for all the chromosomes
</span></div>
<div class='description'>
Outliers (highlighted in grey) are either 3×IQR (interquartile range) or more above the third quartile
or 3×IQR or more below the first quartile.<br>
<b>Do not use</b> if only a few chromosomes appear noisy.<br>
<b>Do not use</b> more than once.
</div>
<div id='rmOutliers' style='padding-left:10px;'></div>
</div>
"))
insertUI(selector='#rmMaxTimesInput',where="beforeEnd",ui=textInput("rmMaxTimes",NULL,1,width="90%"))
insertUI(selector='#rmMaxButton',where="beforeEnd",ui=actionButton("rmMaxButton","Remove max values"))
insertUI(selector='#rmOutliers',where="beforeEnd",ui=actionButton("rmOutButton","Remove outliers"))
insertUI(
selector='#scatterPlotButtonDiv',
where="beforeEnd",
ui=actionButton("scatterPlotButton","Switch to scatter plot view")
)
## changes to the main panel
removeUI(selector='#coveragePlot')
insertUI(
selector='#coveragePlotDiv',
where="afterBegin",
ui=plotOutput(
"coveragePlot",
hover=hoverOpts(id="outliers"),
width="100%",
height=500
)
)
insertUI(selector='#outlierInfoDiv',where="afterBegin",ui=HTML("
<div id='outlierDiv'><label>Hoover over datapoints to display their properties</label></div>
"))
insertUI(selector='#outlierDiv',where="beforeEnd",ui=verbatimTextOutput("outlierInfo"))
## direct action
plots$coveragePlot <- gplotBed(DFs$bed,plotting=F)
toggles$coverage <- F
toggles$coverageRegion <- F
})
#~ ~~~~~~~~~~~~~~~~ Region plotting ~~~~~~~~~~~~~~~~~~
observeEvent(input$coverageChrIn, {
if (input$coverageChrIn!="") {
chrom <- input$coverageChrIn
chromEnd <- max(DFs$bed$chromEnd[DFs$bed$chrom == chrom])
updateTextInput(session,'coverageChrStart',value=0)
updateTextInput(session,'coverageChrEnd',value=chromEnd)
}
})
observeEvent(input$coverageRegionButton, {
req(input$coverageChrIn,input$coverageChrStart,input$coverageChrEnd)
region <- paste0(input$coverageChrIn,":",input$coverageChrStart,"-",input$coverageChrEnd)
if (toggles$coverageRegion==F) {
removeUI(selector='#coveragePlot')
insertUI(
selector='#bedMainCtrls',
where="afterBegin",
ui=plotOutput(
"coveragePlot",
width="70%",
height=300
)
)
insertUI(selector="#resetRegion",where="afterBegin",ui=actionButton('resetRegionButton',"Reset view"))
}
plots$coveragePlot <- plotCoverage(DFs$bed,region=region,plotting=F)
toggles$coverageRegion <- T
})
observeEvent(input$resetRegionButton, {
#~ updateSelectInput(session,'coverageChrIn',selected="")
#~ updateTextInput(session,'coverageChrStart',value="")
#~ updateTextInput(session,'coverageChrEnd',value="")
removeUI(selector='#resetRegionButton')
removeUI(selector='#coveragePlot')
insertUI(
selector='#bedMainCtrls',
where="afterBegin",
ui=plotOutput(
"coveragePlot",
width=990,
height=1200
)
)
## direct action
plots$coveragePlot <- plotCoverage(DFs$bed,plotting=F)
toggles$coverageRegion <- F
})
## outputs
output$coverageChrOut <- renderUI({
chrList <- levels(DFs$bed$chrom)
selectInput("coverageChrIn",NULL,c("Chr"="",chrList))
})
#~ ~~~~~~~~~~~~~~~~ Reset bed ~~~~~~~~~~~~~~~~~~
observeEvent(input$resetBed, {
## changes to the side panel
removeUI(selector='#resetBed')
## update reactive values
toggles$bedEdited <- F
## direct action
if (toggles$isExampleCoverage == T) {
names$bed <- "Dbf4_S"
DFs$bed <- example[["bed"]]
} else {
DFs$bed <- loadBed(input$bedFile$datapath,fname=names$bed)
}
if (toggles$coverage == F ) {
plots$coveragePlot <- gplotBed(DFs$bed,plotting=F)
} else {
plots$coveragePlot <- plotCoverage(DFs$bed,plotting=F)
}
})
#~ ~~~~~~~~~~~~~~~~ Save bed ~~~~~~~~~~~~~~~~~~
observeEvent(input$saveBed, {
req(input$bedType,input$bedName)
names$bed <- input$bedName
sampleName <- input$bedName
DFs$bed$name <- rep(sampleName,dim(DFs$bed)[1])
if (input$bedType == 'rep') {
DFs$rep[[sampleName]] <- DFs$bed
## add inteface to the ratio tab if we have one of each, rep and non-rep
if (length(names(DFs$rep))==1 & length(names(DFs$nonRep)) >= 1) {
insertUI(selector='#ratioSide',where="afterBegin",ui=HTML("<div id='ratioSelectorDiv' style='padding-bottom:20px;'></div>"))
insertUI(selector="#ratioSelectorDiv",where="afterBegin",ui=uiOutput('nonRepSamples'))
insertUI(selector="#ratioSelectorDiv",where="afterBegin",ui=uiOutput('repSamples'))
}
}
if (input$bedType == 'nonRep') {
DFs$nonRep[[sampleName]] <- DFs$bed
## add inteface to the ratio tab if we have one of each, rep and non-rep
if (length(names(DFs$nonRep))==1 & length(names(DFs$rep)) >= 1) {
insertUI(selector='#ratioSide',where="afterBegin",ui=HTML("<div id='ratioSelectorDiv' style='padding-bottom:20px;'></div>"))
insertUI(selector="#ratioSelectorDiv",where="afterBegin",ui=uiOutput('nonRepSamples'))
insertUI(selector="#ratioSelectorDiv",where="afterBegin",ui=uiOutput('repSamples'))
}
}
removeUI(selector='#bedSideCtrls')
removeUI(selector='#resetBed')
removeUI(selector='#saveBedFurther')
## update reactive values
toggles$bedEdited <- F
toggles$coverage <- F
toggles$coverageRegion <- F
})
## outputs
output$downloadCoveragePlot <- downloadHandler(
filename = function() {
if (toggles$coverageRegion==F) {
paste0(names$bed, '_RawReads.pdf')
} else {
region <- paste0(input$coverageChrIn,"_",input$coverageChrStart,"-",input$coverageChrEnd)
paste0(names$bed,'_',region,'_RawReads.pdf')
}
},
content = function(file) {
if (toggles$coverage == F) {
ggsave(file, plot=plots$coveragePlot, device=cairo_pdf, width = 40, height = 20, units = "cm")
} else {
if (toggles$coverageRegion==F) {
ggsave(file, plot=plots$coveragePlot, device=cairo_pdf, width = 25, height = 35, units = "cm")
} else {
ggsave(file, plot=plots$coveragePlot, device=cairo_pdf, width = 30, height = 12, units = "cm")
}
}
}
)
output$downloadCoverageCSV <- downloadHandler(
filename = function() {
if (toggles$coverageRegion==F) {
paste0(names$bed, '_RawReads.tsv')
} else {
region <- paste0(input$coverageChrIn,"_",input$coverageChrStart,"-",input$coverageChrEnd)
paste0(names$bed,'_',region,'_RawReads.tsv')
}
},
content = function(file) {
fileContent <- DFs$bed
fileContent$name <- rep(input$bedName,dim(DFs$bed)[1])
if (toggles$coverageRegion==F) {
write.table(fileContent,file=file,sep="\t",col.names=T,row.names=F,quote=F)
} else {
fileContent <- subset(
fileContent,
chrom==input$coverageChrIn & chromStart>=input$coverageChrStart & chromEnd<=input$coverageChrEnd
)
write.table(fileContent,file=file,sep="\t",col.names=T,row.names=F,quote=F)
}
})
####################################################### RATIO TAB ###################################################################
observeEvent(input$repBed, {
if (input$nonRepBed!="" && input$repBed!="") {
removeUI(selector='#makeRatioButton')
insertUI(selector="#nonRepSamples",where="afterEnd",ui=actionButton('makeRatioButton',"Make ratio"))
}
})
output$repSamples <- renderUI({
repSampleList <- names(DFs$rep)
selectInput("repBed","Select samples to calculate ratio:",c("Replicating"="",repSampleList),width="75%")
})
observeEvent(input$nonRepBed, {
if (input$repBed!="" && input$nonRepBed!="") {
removeUI(selector='#makeRatioButton')
insertUI(selector="#nonRepSamples",where="afterEnd",ui=actionButton('makeRatioButton',"Make ratio"))
}
})
output$nonRepSamples <- renderUI({
nonRepSampleList <- names(DFs$nonRep)
selectInput("nonRepBed",NULL,c("Non-replicating"="",nonRepSampleList),width="75%")
})
observeEvent(input$ratioFile, {
if (!is.null(input$ratioFile)) {
DFs$ratio <- read.table(input$ratioFile$datapath,sep=",",header=T,colClasses=
c("factor","integer","integer","factor","factor","numeric","factor"))
plots$ratioPlot <- gplotRatio(DFs$ratio$ratio,plotting=F)
if (toggles$isExampleRatio == T) {
toggles$isExampleRatio <- F
insertUI('#saveRatioFurther',"afterBegin",ui=HTML("<b style='display:block;padding: 20px;'>Save the ratio for plotting:</b>"))
insertUI('#saveRatioBut',"afterBegin",ui=actionButton("saveRatioButton","Save ratio"))
}
if (toggles$ratioCtrlsIn == T) {
updateTextInput(session,"loLimInput",value="")
updateTextInput(session,"hiLimInput",value="")
values$newRatioFactor <- as.numeric(DFs$ratio$ratioFactor[1])
updateTextInput(session,"ratioFactor",value=as.character(DFs$ratio$ratioFactor[1]))
} else {
toggles$ratioCtrlsIn <- T
}
}
})
observeEvent(input$exampleRatio, {
toggles$isExampleRatio <- T
toggles$ratioCtrlsIn <- T
})
observeEvent(input$makeRatioButton, {
req(input$nonRepBed,input$repBed)
removeUI(selector='#makeRatioButton')
DFs$ratio <- makeRatio(DFs$rep[[input$repBed]],DFs$nonRep[[input$nonRepBed]])
plots$ratioPlot <- gplotRatio(DFs$ratio$ratio,plotting=F)
if (toggles$isExampleRatio == T) {
toggles$isExampleRatio <- F
insertUI('#saveRatioFurther',"afterBegin",ui=HTML("<b style='display:block;padding: 20px;'>Save the ratio for plotting:</b>"))
insertUI('#saveRatioBut',"afterBegin",ui=actionButton("saveRatioButton","Save ratio"))
}
if (toggles$ratioCtrlsIn == T) {
updateTextInput(session,"loLimInput",value="")
updateTextInput(session,"hiLimInput",value="")
values$newRatioFactor <- 1.000
updateTextInput(session,"ratioFactor",value="1.000")
} else {
toggles$ratioCtrlsIn <- T
}
})
observeEvent(DFs$ratio, {
names$currentRatio <- c(as.character(DFs$ratio$name.rep[1]),as.character(DFs$ratio$name.nonRep[1]))
},ignoreInit=T)
observeEvent(toggles$ratioCtrlsIn, {
if (toggles$ratioCtrlsIn == T) {
removeUI('#ratioDescription')
if (toggles$isExampleRatio == T) {
DFs$ratio <- example[["ratio"]]
}
ratioFactor <- as.character(DFs$ratio$ratioFactor[1])
## changes to the side panel
removeUI(selector='#makeRatioButton')
removeUI(selector='#exampleRatioDiv')
insertUI(
selector='#ratioSide',
where="afterEnd",
ui=HTML("
<div id='ratioSideCtrls'>
<div id='ratioTrimDiv'>
<hr>
<div class='myTooltip'><label>Trim the ratio</label><span class='myTooltiptext'>
Use before automatic normalisation. 0.5-1.5 is a safe starting point
</span></div>
<div class='description'>
Some genomic regions may exhibit high variability in sequencing depth.
Exclude them by trimming the ratio values.
</div>
<div style='padding-left:10px;'>
<div id='loLimDiv' class='inline' style='width:30%;'></div>
<div id='hiLimDiv' class='inline' style='width:30%;'></div>
<div id='trimButtonDiv' class='inline' style='padding-left:10px;'></div>
</div>
</div>
<div id='autoNormDiv'>
<hr>
<div class='myTooltip'><label>Automatic normalisation</label><span class='myTooltiptext'>
Use with trimmed full range S phase samples
</span></div>
<div class='description'>
This fits the data on a scale of one to two, while minimising the sum of the outliers.
</div>
<div id='autoNormBtn' style='padding-left:10px;'></div>
</div>
<div id='maNormDiv'>
<hr>
<div class='myTooltip'><label>Manual normalisation</label><span class='myTooltiptext'>
Use with asynchronous or early S phase cell samples
</span></div>
<div class='description'>
If the automatic normalisation was used, it will show the calculated value.
</div>
<div style='padding-left:10px;'>
<div id='maNormField' class='inline' style='width:30%;'></div>
<div id='maNormButton' class='inline'></div>
</div>
</div>
</div>
")
)
insertUI(selector="#loLimDiv",where="afterBegin",ui=textInput('loLimInput',NULL,placeholder="Low limit"))
insertUI(selector="#hiLimDiv",where="afterBegin",ui=textInput('hiLimInput',NULL,placeholder="High limit"))
insertUI(selector="#trimButtonDiv",where="afterBegin",ui=actionButton('trimRatioButton',"Trim"))
insertUI(selector="#autoNormBtn",where="afterBegin",ui=actionButton('normaliseButton',"Auto normalise"))
insertUI(selector="#maNormField",where="afterBegin",ui=textInput('ratioFactor',NULL,ratioFactor,width="90%"))
insertUI(selector="#maNormButton",where="afterBegin",ui=actionButton('maNormButton',"Update"))
values$newRatioFactor <- as.numeric(ratioFactor)
## changes to the main panel
insertUI(
selector='#ratioMain',
where="afterBegin",
ui=HTML(paste0("
<div id='ratioMainCtrls'>
<div id='ratioPlotDiv'></div>
<div id='saveRatioDiv' style='padding: 1cm 0.5cm;'>
<div id='saveRatioFurther' class='inline' style='padding-right:2cm;'>",
if (toggles$isExampleRatio == F) {
paste0("<b style='display:block;padding: 20px;'>Save the ratio for plotting:</b>") },
"<div id='saveRatioBut'></div>
</div>
<div class='inline'><b style='display:block;padding: 20px;'>Save data locally:</b>
<div id='downloadRatio' class='inline'></div>
</div>
</div>
</div>
"))
)
insertUI(selector='#ratioPlotDiv',where="afterBegin",ui=plotOutput("plotHist",width="80%",height=500))
plots$ratioPlot <- gplotRatio(DFs$ratio$ratio,plotting=F)
if (toggles$isExampleRatio != T) {
insertUI(selector='#saveRatioBut',where="afterBegin",ui=actionButton("saveRatioButton","Save ratio"))
}
insertUI(selector='#downloadRatio',where="afterBegin",ui=downloadButton("downloadRatioPlot","Download plot"))
insertUI(selector='#downloadRatio',where="beforeEnd",ui=downloadButton("downloadRatioCSV","Download data"))
} else {
removeUI(selector='#ratioSideCtrls')
removeUI(selector='#ratioMainCtrls')
}
})
output$plotHist <- renderPlot(plots$ratioPlot)
observeEvent(input$trimRatioButton, {
req(input$loLimInput,input$hiLimInput)
loLim <- as.numeric(input$loLimInput)
hiLim <- as.numeric(input$hiLimInput)
DFs$ratio <- trimRatio(DFs$ratio,loLim,hiLim)
if ("tmpRatio" %in% colnames(DFs$ratio)) {
plots$ratioPlot <- gplotRatio(DFs$ratio$tmpRatio,plotting=F)
} else {
plots$ratioPlot <- gplotRatio(DFs$ratio$ratio,plotting=F)
}
})
observeEvent(input$normaliseButton, {
DFs$ratio <- normaliseRatio(DFs$ratio,replace=F)
plots$ratioPlot <- gplotRatio(DFs$ratio$tmpRatio,plotting=F)
values$oldRatioFactor <- values$newRatioFactor
values$newRatioFactor <- as.numeric(attributes(DFs$ratio)$comment)
updateTextInput(session,"ratioFactor",value=values$newRatioFactor)
updateTextInput(session,"loLimInput",value=round(values$newRatioFactor*as.numeric(input$loLimInput)/values$oldRatioFactor,2))
updateTextInput(session,"hiLimInput",value=round(values$newRatioFactor*as.numeric(input$hiLimInput)/values$oldRatioFactor,2))
})
observeEvent(input$maNormButton, {
values$oldRatioFactor <- values$newRatioFactor
values$newRatioFactor <- as.numeric(input$ratioFactor)
DFs$ratio <- normaliseRatio(DFs$ratio,rFactor=input$ratioFactor,replace=F)
plots$ratioPlot <- gplotRatio(DFs$ratio$tmpRatio,plotting=F)
updateTextInput(session,"loLimInput",value=round(values$newRatioFactor*as.numeric(input$loLimInput)/values$oldRatioFactor,2))
updateTextInput(session,"hiLimInput",value=round(values$newRatioFactor*as.numeric(input$hiLimInput)/values$oldRatioFactor,2))
})
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ changes to the PLOT tab ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##
observeEvent(input$examplePlot, {
toggles$isExamplePlot <- T
if (toggles$plotCtrlsIn == F) toggles$plotCtrlsIn <- T
DFs$ratios <- example[["ratios"]]
DFs$guide <- example[["guide"]]
})
## Inserting plotting interface either after first ratio in or when using example plot
observeEvent(toggles$plotCtrlsIn, {
if (toggles$plotCtrlsIn == T) {
removeUI(selector='#examplePlotDiv')
insertUI(selector='#samples',where="afterBegin",ui=HTML("
<div class='myTooltip' style='padding-bottom:15px;'><ctrlH>Samples</ctrlH>
<span class='myTooltiptext'>This area controls appearance of individual samples</span>
</div>
<div id='sampleArea' style='padding-left:10px;'></div>
"))
insertUI(
selector='#sampleArea',
where="afterEnd",
ui=HTML("
<hr>
<div id='plotElements'>
<div class='myTooltip'><ctrlH>Additional features</ctrlH>
<span class='myTooltiptext'>Add features to the plot using your data in bed format</span>
</div>
<div style='padding:15px 10px;'>
<div id='selectElement' class='inline' style='width:35%;'></div>
<div id='uploadElement' class='inline' style='width:60%;padding-left:15px;'></div>
<div id='plotFeaturesDiv'></div>
</div>
</div>
<hr>
<div style='padding-bottom:15px;'>
<div class='myTooltip'><ctrlH>Smoothing controls</ctrlH>
<span class='myTooltiptext'>Noisy data may benefit from adding a smoother</span>
</div>
<div id='ratioSmoothControls' style='padding:15px 10px 15px 10px;'>
<div id='groupDiv' class='inline' style='width:35%;'>
<div class='inline myTooltip' style='padding-top:7px;'><label>Group size:</label>
<span class='myTooltiptext'>Minimum number of bins in a group</span>
</div>
<div id='smoothGroup' class='inline' style='width:40%;'></div>
</div>
<div id='splitDiv' class='inline' style='width:30%;padding-left:10px;'>
<div class='inline myTooltip' style='padding-top:7px;'><label>Split:</label>
<span class='myTooltiptext'>Number of missing bins along a chromosome to initiate a new group</span>
</div>
<div id='smoothSplit' class='inline' style='width:40%;'></div>
</div>
<div id='smoothBtn' class='inline' style='width:25%;'></div>
</div>
</div>
<hr>
<div>
<div class='myTooltip'><ctrlH>Plotting controls</ctrlH>
<span class='myTooltiptext'>Choose the appearance of the plot</span>
</div>
<div id='plottingCtrls' style='padding:10px;'>
<div id='plotRegionDiv' style='padding-bottom:10px;'>
<div id='plotRegion'>
<b>Select region to plot</b><br>
<div>
<div id='plotChrDiv' class='inline' style='width:20%;'></div>
<div id='plotChrStartDiv' class='inline' style='width:23%;'></div>
<div id='plotChrEndDiv' class='inline' style='width:23%;'></div>
<div id='resetPlotRegionDiv' class='inline' style='width:28%;'></div>
</div>
</div>
</div>
<div id='geomInputDiv' class='inline' style='width:45%;'>
<div style='padding-top:5px;'><b>Plot type:</b></div>
<div id='geomDiv' style='padding-right:10px;width:80%;'></div>
</div>
<div id='plotLimits' class='inline' style='width:45%;'>
<div style='padding-top:5px;'><b><i>y</i> axis limits:</b></div>
<div>
<div id='plotLim1' class='inline' style='width:45%;'></div>
<div id='plotLim2' class='inline' style='width:45%;'></div>
</div>
</div>
<div id='plotGenomeBtnDiv' style='padding-top:20px;text-align:center;'></div>
</div>
</div>
")
)
insertUI(selector="#selectElement",where="afterBegin",ui=selectInput('plotFeatures',NULL,
c("Choose type:"="","vLine"="lines","Circle"="circles","Rectangle"="rectangles","Pointer"="pointers")))
insertUI(selector="#uploadElement",where="afterBegin",ui=fileInput(
'plotFeaturesFile',NULL,multiple=F,accept=".bed",buttonLabel = "Browse...", placeholder="No file selected"
))
insertUI(selector="#smoothGroup",where="afterBegin",ui=textInput('group',NULL,4))
insertUI(selector="#smoothSplit",where="afterBegin",ui=textInput('split',NULL,5))
insertUI(selector="#smoothBtn",where="afterBegin",ui=actionButton('smoothButton',"Apply smoothing"))
insertUI(selector="#plotChrDiv",where="afterBegin",ui=uiOutput('plotChrOut',width="90%"))
insertUI(
selector="#plotChrStartDiv",
where="afterBegin",
ui=textInput('plotChrStart',NULL,NULL,width="95%",placeholder='Start')
)
insertUI(
selector="#plotChrEndDiv",
where="afterBegin",
ui=textInput('plotChrEnd',NULL,NULL,width="95%",placeholder='End')
)
insertUI(selector='#resetPlotRegionDiv',where="afterBegin",ui=actionButton("resetPlotRegion","Reset region"))
insertUI(selector="#geomDiv",where="afterBegin",ui=selectInput(
'geomInput',
NULL,
c("scatter"='geom_point',"polygon"='geom_ribbon',"bar"='geom_segment'),
selected='scatter')
)
insertUI(
selector="#plotLim1",
where="afterBegin",
ui=textInput('plotLimLow',NULL,1,width="95%",placeholder='From')
)
insertUI(
selector="#plotLim2",
where="afterBegin",
ui=textInput('plotLimHi',NULL,2,width="95%",placeholder='To')
)
insertUI(selector="#plotGenomeBtnDiv",where="afterBegin",ui=actionButton('plotGenomeButton'," Plot "))
}
})
observeEvent(input$saveRatioButton, {
if (toggles$isExampleRatio == T) toggles$isExampleRatio <- F
if (toggles$plotCtrlsIn == F) toggles$plotCtrlsIn <- T
## direct action
if ("tmpRatio" %in% colnames(DFs$ratio)) {
DFs$ratio$ratio <- round(DFs$ratio$tmpRatio,3)
DFs$ratio$tmpRatio <- NULL
}
#~ if (toggles$isExampleRatio == T) {
#~ names$ratio[nrow(names$ratio)+1,] <- c("Dbf4_S","Dbf4_G2","Dbf4_S (Dbf4_G2)")
#~ } else {
names$ratio[nrow(names$ratio)+1,] <- c(DFs$ratio$name.rep[1],DFs$ratio$name.nonRep[1],paste0(DFs$ratio$name.rep[1]," (",DFs$ratio$name.nonRep[1],")"))
#~ }
DFs$ratio$group <- paste("NA")
DFs$ratio$splineSmooth <- paste("NA")
DFs$ratio$ratioFactor <- as.character(round(values$newRatioFactor,3))
DFs$ratio$ratioFactor <- factor(DFs$ratio$ratioFactor,levels=unique(DFs$ratio$ratioFactor))
DFs$ratios <- rbind(DFs$ratios,DFs$ratio)
values$availableRatios <- unique(paste0(as.character(DFs$ratios$name.rep)," (",as.character(DFs$ratios$name.nonRep),")"))
#~ comment(DFs$ratio) <- as.character(round(values$newRatioFactor,3))
DFs$ratios2add <- unique(DFs$ratio[,c("name.rep","name.nonRep")])
#~ if (values$i > 1) {
#~ for (i in 1:values$i-1) {
#~ updateSelectInput(session,paste0('orderInput',i),choices=c(seq(1,values$i),NA),selected=i)
#~ }
#~ }
## changes to the side panel
toggles$ratioCtrlsIn <- F
## changes to the main panel
#~ removeUI(selector='#ratioPlotDiv')
#~ removeUI(selector='#saveRatioFurther')
})
observeEvent(values$i, {
if (values$i ==2) {
if (toggles$statSelectIn == F) toggles$statSelectIn <- T
}
})
output$downloadRatioPlot <- downloadHandler(
filename = function() { paste0(names$currentRatio[1],'_(',names$currentRatio[2],')_RatioHist.pdf') },
content = function(file) {
ggsave(file, plot=plots$ratioPlot, device=cairo_pdf, width = 30, height = 15, units = "cm")
}
)
output$downloadRatioCSV <- downloadHandler(
filename = function() { paste0(names$currentRatio[1],'_(',names$currentRatio[2],')_Ratio.csv') },
content = function(file) {
ratioData <- DFs$ratio
ratioData$ratioFactor <- as.character(round(values$newRatioFactor,3))
ratioData$ratioFactor <- factor(ratioData$ratioFactor,levels=unique(ratioData$ratioFactor))
if ("tmpRatio" %in% colnames(ratioData)) {
ratioData$ratio <- round(ratioData$tmpRatio,3)
ratioData$tmpRatio <- NULL
}
write.table(ratioData,file=file,sep=",",col.names=T,row.names=F,quote=F)
}
)
###########################################################~~~~~~~~~~~~################################################################
########################################################### PLOT TAB ################################################################
###########################################################~~~~~~~~~~~~################################################################
observeEvent(input$plotFile, {
if (!is.null(input$plotFile)) {
if (toggles$isExamplePlot == T) toggles$isExamplePlot <- F
if (toggles$plotCtrlsIn == F) { toggles$plotCtrlsIn <- T }
#~ warning(paste0(input$plotFile$datapath))
plotFileContent <- read.table(input$plotFile$datapath,sep=",",header=T,colClasses=c("factor","integer","integer","factor","factor","numeric","factor","integer","numeric"))
# c("chrom","chromStart","chromEnd","name.rep","name.nonRep","ratio","ratioFactor","group","splineSmooth")
samples <- unique(plotFileContent[,c("name.rep","name.nonRep")])
samples$name <- paste0(as.character(samples[,1])," (",as.character(samples[,2]),")")
names$ratio <- rbind(names$ratio,samples)
DFs$ratios2add <- unique(plotFileContent[,c("name.rep","name.nonRep")])
DFs$ratios <- rbind(DFs$ratios,plotFileContent)
}
})
observeEvent(input$examplePlot, {
toggles$isExamplePlot <- T
if (toggles$plotCtrlsIn == F) toggles$plotCtrlsIn <- T
DFs$ratios <- subset(example[["ratios"]],select=c(1:9))
DFs$ratios2add <- unique(DFs$ratios[,c("name.rep","name.nonRep")])
#~ insertUI(selector='#plotMain',where="afterBegin",ui=plotOutput('plotGenomeOut',width=990,height=1200))
#~ plots$genomePlot <- plotGenome(DFs$ratios,plotting=F,guide=DFs$guide,geom="geom_point")
})
observeEvent(DFs$ratios2add, {
if (nrow(DFs$ratios2add) != 0) {
if (is.null(values$i)) values$i <- as.integer(0)
for (i in 1:nrow(DFs$ratios2add)) {
## generate/add to the guide dataframe for plotting
colors = c("#7F7F7F","#00688B","#CD8500","#6E8B3D","#8B3A62","#551A8B","#CD0000","#CDCD00")
DFs$guide[as.integer(values$i)+i,] <- c(
as.integer(as.integer(values$i)+i),
as.character(DFs$ratios2add$name.rep[i]),
as.character(DFs$ratios2add$name.nonRep[i]),
as.logical(TRUE),
as.logical(FALSE),
as.character(colors[as.integer(values$i)+i])#,
#~ as.numeric(DFs$ratios2add$ratioFactor[i])
)
## changes to the PLOT tab
insertUI(selector='#sampleArea',where="beforeEnd",ui=HTML(paste0("
<div id='ratioDiv",as.integer(values$i)+i,"' style='color:#696969;padding-bottom:10px;'>
<b
style='display:block;padding-bottom:10px;color:#000000;'>
<i>",as.character(DFs$ratios2add$name.rep[i])," (",as.character(DFs$ratios2add$name.nonRep[i]),")</i>
</b>","
<div id='orderDiv",as.integer(values$i)+i,"' class='inline' style='width:15%;'>
<div id='tmpOrderDiv",as.integer(values$i)+i,"'></div>
</div>
<div class='inline'><b style='display:block;padding-left:10px;'>Data</b>
<div class='inline'>
<div id='rawDiv",as.integer(values$i)+i,"' class='inline' style='padding-left:10px;'></div>
<div class='inline' style='display:inline-block;padding-top:12px;'>Raw</div>
</div>
<div class='inline'>
<div id='smoothDiv",as.integer(values$i)+i,"' class='inline' style='padding-left:12px;'></div>
<div id='smoothie",as.integer(values$i)+i,"' class='inline' style='display:inline-block;padding-top:12px;'>
<div id='rmSmooth",as.integer(values$i)+i,"'",
if (toggles$isExamplePlot!=T) {paste0(" style='text-decoration:line-through;'")},
">Smooth
</div>
</div>
</div>
</div>
<div class='inline'><b style='display:block;padding-left:10px;'>Colour</b>
<div id='colorDiv",as.integer(values$i)+i,"' style='padding-top:5px;padding-left:10px;'> </div>
</div>
</div>")
)
)
insertUI(selector=paste0('#tmpOrderDiv',as.integer(values$i)+i),where="afterBegin",ui=selectInput(
paste0('orderInput',as.integer(values$i)+i),
"Order",
c(seq(1,as.integer(values$i)+i),NA),
selected=as.integer(values$i)+i)
)
insertUI(selector=paste0('#rawDiv',as.integer(values$i)+i),where="afterBegin",ui=checkboxInput(
paste0('rawInput',as.integer(values$i)+i),
NULL,
TRUE)
)
insertUI(selector=paste0('#smoothDiv',as.integer(values$i)+i),where="afterBegin",ui=checkboxInput(
paste0('smoothInput',as.integer(values$i)+i),
NULL,
FALSE)
)
insertUI(selector=paste0('#colorDiv',as.integer(values$i)+i),where="afterBegin",ui=colourInput(
paste0('colorInput',as.integer(values$i)+i),
NULL,
paste(colors[as.integer(values$i)+i])
)
)
}
if (as.integer(values$i)+nrow(DFs$ratios2add) > 1) {
k <- (as.integer(as.integer(values$i)+nrow(DFs$ratios2add)))
for (j in 1:(k-1)) {
#~ lapply(1:k,function(j) {
removeUI(paste0("#tmpOrderDiv",j))
insertUI(paste0("#orderDiv",j),"afterBegin",HTML(paste0("<div id='tmpOrderDiv",j,"'></div>")))
insertUI(paste0("#tmpOrderDiv",j),"afterBegin",
selectInput(paste0('orderInput',j),"Order",c(seq(1,k),NA),selected=j))
#~ warning(paste("Updating orderInput",j,"to have",k+1,"choices"))
#~ updateSelectInput(session,paste0("orderInput",j),choices=c(seq(1,k),NA),selected=j)
#~ }
#~ })
#~ for (j in 1:(k+1)) {
#~ warning(paste("Updating checkInput",j,"to TRUE"))
#~ updateCheckboxInput(session,paste0("smoothInput",j),TRUE)
}
}
if (toggles$isExamplePlot != T) {
if (as.integer(values$i) < 2 & as.integer(values$i) + i > 2) {
if (toggles$statSelectIn == F) toggles$statSelectIn <- T
}
values$i <- as.integer(values$i) + i
}
}
})
observeEvent(input$plotFeaturesFile, {
if (input$plotFeatures!="") {
filePath <- input$plotFeaturesFile$datapath
feature_str <- paste0("DFs$",input$plotFeatures,"<-loadBed(filePath)")
eval(parse(text=feature_str))
str <- paste0("featureName <- levels(DFs$",input$plotFeatures,"$name)[1]")
eval(parse(text=str))
features <- c("lines","circles","rectangles","pointers")
colours <- c("#00FF00","#FFFFFF","#FF0000","#FF7F00")
removeUI(paste0("#",input$plotFeatures))
insertUI('#plotFeaturesDiv',"beforeEnd",ui=HTML(paste0("
<div class='inline'>
<div id='",input$plotFeatures,"' class='inline' style='max-width:75%;padding-left:10px;'></div>
<div id='colour",input$plotFeatures,"' class='inline' style='max-width:25%;padding-left:10px;'></div>
</div>"
)))
insertUI(paste0("#",input$plotFeatures),"afterBegin",checkboxInput(paste(input$plotFeatures),paste(featureName),TRUE))
insertUI(paste0("#colour",input$plotFeatures),"afterBegin",colourInput(
paste0(input$plotFeatures,"ColourInput"),NULL,colours[match(input$plotFeatures,features)],showColour = "background",palette = "limited"))
#~ values$plotFeatures <- values$plotFeatures[-which(values$plotFeatures==input$plotFeatures)]
}
})
observeEvent(input$plotChrIn, {
if (input$plotChrIn!="") {
chrom <- input$plotChrIn
chromEnd <- max(DFs$ratios$chromEnd[DFs$ratios$chrom == chrom])
updateTextInput(session,'plotChrStart',value=0)
updateTextInput(session,'plotChrEnd',value=chromEnd)
toggles$plotRegion <- T
}
})
observeEvent(input$resetPlotRegion, {
updateSelectInput(session,'plotChrIn',selected="")
updateTextInput(session,'plotChrStart',value="")
updateTextInput(session,'plotChrEnd',value="")
toggles$plotRegion <- F
})
observeEvent(input$plotGenomeButton, {
req(DFs$ratios,DFs$guide,input$plotLimLow,input$plotLimHi)
removeUI(selector='#plotGenomeOut')
removeUI(selector='#downloadButtons')
removeUI(selector='#plotDescription')
## direct action: read inputs
DFs$guide$order <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.integer(input[[paste0("orderInput",i)]])
})) #order
DFs$guide$raw <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.logical(input[[paste0("rawInput",i)]])
})) #raw
DFs$guide$smooth <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.logical(input[[paste0("smoothInput",i)]])
})) #smooth
DFs$guide$color <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.character(input[[paste0("colorInput",i)]])
})) #color
ylims <- c(as.numeric(input$plotLimLow),as.numeric(input$plotLimHi))
## direct action: create plot object
## check if region is selected
plotString <- "plots$genomePlot <- plotGenome(DFs$ratios,plotting=F,guide=DFs$guide,geom=input$geomInput,ylims=ylims"
if (input$plotChrIn!="") {
plotString <- paste0(plotString,",region='",input$plotChrIn,":",input$plotChrStart,"-",input$plotChrEnd,"'")
}
if (!is.null(DFs$lines)) {
if (input$lines) {
plotString <- paste0(plotString,",lines=DFs$lines,colourLines=input$linesColourInput")
}
}
if (!is.null(DFs$circles)) {
if (input$circles) {
plotString <- paste0(plotString,",circles=DFs$circles,colourCircles=input$circlesColourInput")
}
}
if (!is.null(DFs$rectangles)) {
if (input$rectangles) {
plotString <- paste0(plotString,",rectangles=DFs$rectangles,colourRectangles=input$rectanglesColourInput")
}
}
if (!is.null(DFs$pointers)) {
if (input$pointers) {
plotString <- paste0(plotString,",pointers=DFs$pointers,colourPointers=input$pointersColourInput")
}
}
plotString <- paste0(plotString,")")
eval(parse(text=plotString))
## changes to side panel
## changes to main panel
if (input$plotChrIn == "") {
insertUI(selector='#plotMain',where="afterBegin",ui=plotOutput('plotGenomeOut',width=990,height=1200))
} else {
insertUI(selector='#plotMain',where="afterBegin",ui=plotOutput('plotGenomeOut',width='70%',height=300))
}
insertUI(selector='#plotGenomeOut',where="afterEnd",ui=tags$div(id = 'downloadButtons'))
insertUI(selector='#downloadButtons',ui=downloadButton("downloadPlot","Download plot"))
insertUI(selector='#downloadButtons',ui=downloadButton("downloadCSV","Download data"))
})
observeEvent(input$smoothButton, {
req(DFs$ratios,input$group,input$split)
regionChr <- input$plotChrIn
DFs$ratios<-smoothRatio(DFs$ratios,groupMin=as.integer(input$group),split=as.integer(input$split))
updateSelectInput(session,'plotChrIn',selected=regionChr)
for (i in 1:values$i) {
removeUI(selector=paste0("#rmSmooth",i))
insertUI(selector=paste0("#smoothie",i),where="afterBegin",ui=HTML(paste0(
"<div id='smooth>",i,"'>Smooth</div>"
)))
}
})
######################################### outputs #############################################
output$plotGenomeOut <- renderPlot(plots$genomePlot)
#~ output$plotFeaturesOut <- renderUI({
#~ choices <- values$plotFeatures
#~ selectInput('plotFeatures',NULL,c("Choose type:"="","vLine"="lines","Circle"="circles","Rectangle"="rectangles","Pointer"="pointers"))
#~ })
output$plotChrOut <- renderUI({
chrList <- levels(DFs$ratios$chrom)
selectInput("plotChrIn",NULL,c("Chr"="",chrList))
})
output$downloadCSV <- downloadHandler(
filename = function() {
if (toggles$plotRegion==F) {
paste0('ratiosData.csv')
} else {
region <- paste0(input$plotChrIn,"_",input$plotChrStart,"-",input$plotChrEnd)
paste0('ratiosData_',region,'.csv')
}
},
content = function(file) {
fileContent <- data.frame(
chrom=factor(),chromStart=integer(),chromEnd=integer(),
name.rep=factor(),name.nonRep=factor(),ratio=numeric(),
group=integer(),splineSmooth=numeric()
)
guide <- DFs$guide
guide <- guide[order(guide$order,na.last = T),]
rownames(guide) <- 1:nrow(guide)
samples <- length(na.omit(guide$order))
for (i in 1:samples) {
rep <- guide$name.rep[i]
nonRep <- guide$name.nonRep[i]
currentRatio <- DFs$ratios[DFs$ratios$name.rep==rep & DFs$ratios$name.nonRep==nonRep,]
fileContent <- rbind(fileContent,currentRatio)
warning(dfHead(fileContent))
}
if (toggles$plotRegion==F) {
write.table(fileContent,file=file,sep=",",col.names=T,row.names=F,quote=F)
} else {
fileContent <- subset(
fileContent,chrom==input$plotChrIn & chromStart>=input$plotChrStart & chromEnd<=input$plotChrEnd
)
write.table(fileContent,file=file,sep=",",col.names=T,row.names=F,quote=F)
}
}
)
output$downloadPlot <- downloadHandler(
filename = function() {
if (toggles$plotRegion==F) {
paste0('ratiosPlot.pdf')
} else {
region <- paste0(input$plotChrIn,"_",input$plotChrStart,"-",input$plotChrEnd)
paste0('ratiosPlot_',region,'.pdf')
}
},
content = function(file) {
if (toggles$plotRegion==F) {
ggsave(file, plot=plots$genomePlot, device=cairo_pdf, width = 35, height = 50, units = "cm")
} else {
ggsave(file, plot=plots$genomePlot, device=cairo_pdf, width = 30, height = 12, units = "cm")
}
}
)
#################################################~~~~~~~~~~~~~###############################################################
################################################# STATS TAB ###############################################################
#################################################~~~~~~~~~~~~~###############################################################
## STATS: load sample data
observeEvent(input$exampleStats, { ## change relevant toggles and populate DFs$stats
toggles$isExampleStats <- T
DFs$stats <- example[["ratios"]]
},ignoreInit=T)
# add select ratio ui
observeEvent(toggles$statSelectIn, {
insertUI(selector='#statsSide',where="afterBegin",ui=HTML("<div id='statsSelectDiv'></div>"))
insertUI(selector='#statsSelectDiv',where="afterBegin",ui=uiOutput("firstRatioOut"))
insertUI(selector='#statsSelectDiv',where="beforeEnd",ui=uiOutput("secondRatioOut"))
},ignoreInit=T)
## STATS: render select ratio ui
output$firstRatioOut <- renderUI({
selectInput('firstRatioIn',"Select ratios to calculate stats:",c("First ratio"="",names$ratio$name),width="75%")
})
output$secondRatioOut <- renderUI({
selectInput("secondRatioIn",NULL,c("Second ratio"="",names$ratio$name),width="75%")
})
observeEvent(input$firstRatioIn, {
if (input$firstRatioIn != "") {
updateSelectInput(session,'secondRatioIn',choices=c("Second ratio"="",names$ratio$name[-which(names$ratio$name==input$firstRatioIn)]),selected=input$secondRatioIn)
} else {
updateSelectInput(session,'secondRatioIn',choices=c("Second ratio"="",names$ratio$name),selected=input$secondRatioIn)
}
})
observeEvent(input$secondRatioIn, {
if (input$secondRatioIn != "") {
updateSelectInput(session,'firstRatioIn',choices=c("First ratio"="",names$ratio$name[-which(names$ratio$name==input$secondRatioIn)]),selected=input$firstRatioIn)
} else {
updateSelectInput(session,'firstRatioIn',choices=c("First ratio"="",names$ratio$name),selected=input$firstRatioIn)
}
})
observeEvent({
input$firstRatioIn
input$secondRatioIn
} ,{
if (input$firstRatioIn != "" & input$secondRatioIn != "") {
insertUI(selector='#statsSelectDiv',where="beforeEnd",ui=actionButton('calcStats',"Calculate"))
} else {
removeUI(selector='#calcStats')
}
})
observeEvent(input$calcStats, {
ratios <- subset(names$ratio,name==input$firstRatioIn)
ratios[2,] <- subset(names$ratio,name==input$secondRatioIn)
DFs$stats <- ratioStats(
subset(DFs$ratios,name.rep==ratios[1,1] & name.nonRep==ratios[1,2]),
subset(DFs$ratios,name.rep==ratios[2,1] & name.nonRep==ratios[2,2]),
names = ratios$name
)
removeUI('#calcStats')
})
observeEvent(DFs$stats, {
ratioNames <- unique(DFs$stats[,c(as.character("name.rep"),as.character("name.nonRep"))])
ratioNames$name <- paste0(ratioNames$name.rep," (",ratioNames$name.nonRep,")")
if (toggles$statsCtrlsIn == F) {
## changes to the STATS side panel
removeUI(selector='#statsDescription')
removeUI(selector='#exampleStatsDiv')
insertUI(selector='#statSamples',where="afterBegin",ui=HTML("
<div class='myTooltip' style='padding-bottom:15px;'><ctrlH>Samples</ctrlH>
<span class='myTooltiptext'>This area contains individual sample controls</span>
</div>
<div id='statsSampleArea' style='padding-left:10px;'></div>
"))
insertUI(
selector='#statSamples',
where="afterEnd",
ui=HTML("
<div id='statsPlotElements'>
<div class='myTooltip'><ctrlH>Additional features</ctrlH>
<span class='myTooltiptext'>Enchance plot with your data (must be in bed format)</span>
</div>
<div style='padding:15px 10px;'>
<div id='statSelectElement' class='inline' style='width:35%;'></div>
<div id='statsUploadElement' class='inline' style='width:60%;padding-left:15px;'></div>
<div id='statsPlotFeaturesDiv'></div>
</div>
</div>
<div>
<div class='myTooltip'><ctrlH>Plotting controls</ctrlH>
<span class='myTooltiptext'>Choose the appearance of the plot</span>
</div>
<div id='statsPlottingCtrls' style='padding:10px;'>
<div id='statsPlotRegionDiv' style='padding-bottom:10px;'>
<div id='statsPlotRegion'>
<b>Select region to plot</b><br>
<div>
<div id='statsPlotChrDiv' class='inline' style='width:20%;'></div>
<div id='statsPlotChrStartDiv' class='inline' style='width:23%;'></div>
<div id='statsPlotChrEndDiv' class='inline' style='width:23%;'></div>
<div id='statsResetPlotRegionDiv' class='inline' style='width:28%;'></div>
</div>
</div>
</div>
<div id='statsGeomInputDiv' class='inline' style='width:45%;'>
<div style='padding-top:5px;'><b>Plot type:</b></div>
<div id='statsGeomDiv' style='padding-right:10px;width:80%;'></div>
</div>
<div id='statsPlotLimits' class='inline' style='width:45%;'>
<div style='padding-top:5px;'><b>y limits:</b></div>
<div>
<div id='statsPlotLim1' class='inline' style='width:45%;'></div>
<div id='statsPlotLim2' class='inline' style='width:45%;'></div>
</div>
</div>
<div id='statsPlotGenomeBtnDiv' style='padding-top:20px;text-align:center;'></div>
</div>
</div>
")
)
insertUI(selector="#statSelectElement",where="afterBegin",ui=selectInput('statsPlotFeatures',NULL,
c("Choose type:"="","vLine"="Lines","Circle"="Circles","Rectangle"="Rectangles","Pointer"="Pointers")))
insertUI(selector="#statsUploadElement",where="afterBegin",ui=fileInput(
'statsPlotFeaturesFile',NULL,multiple=F,accept=".bed",buttonLabel = "Browse...", placeholder="No file selected"
))
insertUI(selector="#statsPlotChrDiv",where="afterBegin",ui=uiOutput('statsPlotChrOut',width="90%"))
insertUI(
selector="#statsPlotChrStartDiv",
where="afterBegin",
ui=textInput('statsPlotChrStart',NULL,NULL,width="95%",placeholder='Start')
)
insertUI(
selector="#statsPlotChrEndDiv",
where="afterBegin",
ui=textInput('statsPlotChrEnd',NULL,NULL,width="95%",placeholder='End')
)
insertUI(selector='#statsResetPlotRegionDiv',where="afterBegin",ui=actionButton("statsResetPlotRegion","Reset region"))
insertUI(selector="#statsGeomDiv",where="afterBegin",ui=selectInput(
'statsGeomInput',
NULL,
c("scatter"='geom_point',"polygon"='geom_ribbon',"bar"='geom_segment'),
selected='scatter')
)
insertUI(
selector="#statsPlotLim1",
where="afterBegin",
ui=textInput('statsPlotLimLow',NULL,1,width="95%",placeholder='From')
)
insertUI(
selector="#statsPlotLim2",
where="afterBegin",
ui=textInput('statsPlotLimHi',NULL,2,width="95%",placeholder='To')
)
insertUI(selector="#statsPlotGenomeBtnDiv",where="afterBegin",ui=actionButton('statsPlotGenomeButton'," Plot "))
## Populate the samples div
insertUI(selector='#statsSampleArea',where="beforeEnd",ui=HTML(paste0("
<div id='statsRatioDiv1' style='color:#696969;padding-bottom:10px;'>
<div id='statsSampleName1' style='padding-bottom:10px;color:#000000;font-style:italic;font-weight: bold'>
<div id='statsSample1'>",
ratioNames$name.rep[1]," (",ratioNames$name.nonRep[1],")
</div>
</div>
<div id='statsOrderDiv1' class='inline' style='width:15%;'> </div>
<div class='inline'><b style='display:block;padding-left:10px;'>Data</b>
<div class='inline'>
<div id='statsRawDiv1' class='inline' style='padding-left:10px;'></div>
<div class='inline' style='display:inline-block;padding-top:12px;'>Raw</div>
</div>
<div class='inline'>
<div id='statSmoothDiv1' class='inline' style='padding-left:12px;'></div>
<div id='statSmoothie1' class='inline' style='display:inline-block;padding-top:12px;'>
<div id='statsRmSmooth1'>Smooth</div>
</div>
</div>
</div>
<div class='inline'><b style='display:block;padding-left:10px;'>Colour</b>
<div id='statsColorDiv1' style='padding-top:5px;padding-left:10px;'> </div>
</div>
</div>
<div id='statsRatioDiv2' style='color:#696969;padding-bottom:10px 0;'>
<div id='statsSampleName2' style='padding-bottom:10px;color:#000000;font-style:italic;font-weight: bold'>
<div id='statsSample2'>",
ratioNames$name.rep[2]," (",ratioNames$name.nonRep[2],")
</div>
</div>
<div id='statsOrderDiv2' class='inline' style='width:15%;'> </div>
<div class='inline'><b style='display:block;padding-left:10px;'>Data</b>
<div class='inline'>
<div id='statsRawDiv2' class='inline' style='padding-left:10px;'></div>
<div class='inline' style='display:inline-block;padding-top:12px;'>Raw</div>
</div>
<div class='inline'>
<div id='statSmoothDiv2' class='inline' style='padding-left:12px;'></div>
<div id='statSmoothie2' class='inline' style='display:inline-block;padding-top:12px;'>
<div id='statsRmSmooth2'>Smooth</div>
</div>
</div>
</div>
<div class='inline'><b style='display:block;padding-left:10px;'>Colour</b>
<div id='statsColorDiv2' style='padding-top:5px;padding-left:10px;'> </div>
</div>
</div>")
)
)
insertUI(selector='#statsOrderDiv1',where="afterBegin",ui=selectInput('statsOrderInput1',"Order",c(1,2),selected=1))
insertUI(selector='#statsOrderDiv2',where="afterBegin",ui=selectInput('statsOrderInput2',"Order",c(1,2),selected=2))
insertUI(selector='#statsRawDiv1',where="afterBegin",ui=checkboxInput('statsRawInput1',NULL,TRUE))
insertUI(selector='#statsRawDiv2',where="afterBegin",ui=checkboxInput('statsRawInput2',NULL,TRUE))
insertUI(selector='#statSmoothDiv1',where="afterBegin",ui=checkboxInput('statSmoothInput1',NULL,FALSE))
insertUI(selector='#statSmoothDiv2',where="afterBegin",ui=checkboxInput('statSmoothInput2',NULL,FALSE))
insertUI(selector='#statsColorDiv1',where="afterBegin",ui=colourInput('statsColorInput1',NULL,"#7F7F7F"))
insertUI(selector='#statsColorDiv2',where="afterBegin",ui=colourInput('statsColorInput2',NULL,"#00688B"))
## changes to the STATS main panel
insertUI(selector='#statsMain',where="afterBegin",ui=HTML("<div id='statsPlot'> <div>"))
insertUI(selector='#statsPlot',where="afterBegin",ui=plotOutput('statsPlotOut',width=990,height=1200))
insertUI(selector='#statsPlot',where="afterEnd",ui=HTML("<div id='statsDownloadButtons'></div>"))
insertUI(selector='#statsDownloadButtons',ui=downloadButton("downloadStatsPlot","Download plot"))
insertUI(selector='#statsDownloadButtons',ui=downloadButton("downloadStatsCSV","Download data"))
toggles$statsCtrlsIn <- T
} else {
removeUI(selector='#statsSample1')
removeUI(selector='#statsSample1')
insertUI(
selector='#statsSampleName1',
where="afterBegin",
ui=HTML(paste0("<div id='statsSample1'>",ratioNames$name.rep[1]," (",ratioNames$name.nonRep[1],")</div>")
))
insertUI(
selector='#statsSampleName2',
where="afterBegin",
ui=HTML(paste0("<div id='statsSample2'>",ratioNames$name.rep[2]," (",ratioNames$name.nonRep[2],")</div>")
))
}
## construct guide DF
DFs$guide = data.frame(
order=as.integer(c(1,2)),
name.rep=ratioNames$name.rep,
name.nonRep=ratioNames$name.nonRep,
raw=as.logical(c(TRUE,TRUE)),
smooth=as.logical(c(FALSE,FALSE)),
color=as.character(c("#7F7F7F","#00688B")),
stringsAsFactors=F
)
## Initial plot
plots$statsPlot <- plotGenome(DFs$stats,guide=DFs$guide,plotting=F,geom="geom_point")
},ignoreInit=T)
output$statsPlotChrOut <- renderUI({
chrList <- levels(DFs$stats$chrom)
selectInput("statsPlotChrIn",NULL,c("Chr"="",chrList))
})
output$statsPlotOut <- renderPlot(plots$statsPlot)
observeEvent(input$statsPlotFeaturesFile, {
if (input$statsPlotFeatures!="") {
filePath <- input$statsPlotFeaturesFile$datapath
feature_str <- paste0("DFs$",input$statsPlotFeatures,"<-loadBed(filePath)")
eval(parse(text=feature_str))
str <- paste0("featureName <- levels(DFs$",input$statsPlotFeatures,"$name)[1]")
eval(parse(text=str))
features <- c("Lines","Circles","Rectangles","Pointers")
colours <- c("#00FF00","#FFFFFF","#FF0000","#FF7F00")
removeUI(paste0("#stats",input$statsPlotFeatures))
#~ insertUI('#statsPlotFeaturesDiv',"beforeEnd",ui=HTML(paste0("
#~ <div id='stats",input$statsPlotFeatures,"' class='inline' style='max-width:45%;padding-left:10px;'></div>"
#~ )))
#~ insertUI(paste0("#stats",input$statsPlotFeatures),"afterBegin",checkboxInput(paste0("stats",input$statsPlotFeatures),paste(featureName),TRUE))
insertUI('#statsPlotFeaturesDiv',"beforeEnd",ui=HTML(paste0("
<div class='inline'>
<div id='stats",input$statsPlotFeatures,"' class='inline' style='max-width:75%;padding-left:10px;'></div>
<div id='statsColour",input$statsPlotFeatures,"' class='inline' style='max-width:25%;padding-left:10px;'></div>
</div>"
)))
insertUI(paste0("#stats",input$statsPlotFeatures),"afterBegin",checkboxInput(paste0("stats",input$statsPlotFeatures),paste(featureName),TRUE))
insertUI(paste0("#statsColour",input$statsPlotFeatures),"afterBegin",colourInput(
paste0("stats",input$statsPlotFeatures,"ColourInput"),NULL,colours[match(input$statsPlotFeatures,features)],showColour = "background",palette = "limited"))
#~ values$statsPlotFeatures <- values$statsPlotFeatures[-which(values$statsPlotFeatures==input$statsPlotFeatures)]
}
})
observeEvent(input$statsPlotChrIn, {
if (input$statsPlotChrIn!="") {
chrom <- input$statsPlotChrIn
chromEnd <- max(DFs$stats$chromEnd[DFs$stats$chrom == chrom])
updateTextInput(session,'statsPlotChrStart',value=0)
updateTextInput(session,'statsPlotChrEnd',value=chromEnd)
toggles$statsRegion <- T
}
})
observeEvent(input$statsResetPlotRegion, {
updateSelectInput(session,'statsPlotChrIn',selected="")
updateTextInput(session,'statsPlotChrStart',value="")
updateTextInput(session,'statsPlotChrEnd',value="")
toggles$statsRegion <- F
})
observeEvent(input$statsPlotGenomeButton, {
req(DFs$stats,input$statsPlotLimLow,input$statsPlotLimHi)
removeUI(selector='#statsPlotOut')
ratioNames <- unique(DFs$stats[,c("name.rep","name.nonRep")])
DFs$guide$name.rep <- as.character(ratioNames$name.rep)
DFs$guide$name.nonRep <- as.character(ratioNames$name.nonRep)
## direct action: read inputs
DFs$guide$order <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.integer(input[[paste0("statsOrderInput",i)]])
})) #order
DFs$guide$raw <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.logical(input[[paste0("statsRawInput",i)]])
})) #raw
DFs$guide$smooth <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.logical(input[[paste0("statSmoothInput",i)]])
})) #smooth
DFs$guide$color <- unlist(lapply(1:nrow(DFs$guide),function(i) {
as.character(input[[paste0("statsColorInput",i)]])
})) #color
ylims <- c(as.numeric(input$statsPlotLimLow),as.numeric(input$statsPlotLimHi))
## direct action: create plot object
plotString <- "plots$statsPlot <- plotGenome(DFs$stats,plotting=F,guide=DFs$guide,geom=input$statsGeomInput,ylims=ylims"
if (input$statsPlotChrIn!="") {
insertUI(selector='#statsPlot',where="afterBegin",ui=plotOutput('statsPlotOut',width='70%',height=300))
plotString <- paste0(plotString,",region='",input$statsPlotChrIn,":",input$statsPlotChrStart,"-",input$statsPlotChrEnd,"'")
} else {
insertUI(selector='#statsPlot', where="afterBegin", ui=plotOutput('statsPlotOut',width=990,height=1200))
}
if (!is.null(DFs$Lines)) {
if (input$statsLines) {
plotString <- paste0(plotString,",lines=DFs$Lines,colourLines=input$statsLinesColourInput")
}
}
if (!is.null(DFs$Circles)) {
if (input$statsCircles) {
plotString <- paste0(plotString,",circles=DFs$Circles,colourCircles=input$statsCirclesColourInput")
}
}
if (!is.null(DFs$Rectangles)) {
if (input$statsRectangles) {
plotString <- paste0(plotString,",rectangles=DFs$Rectangles,colourRectangles=input$statsRectanglesColourInput")
}
}
if (!is.null(DFs$Pointers)) {
if (input$statsPointers) {
plotString <- paste0(plotString,",pointers=DFs$Pointers,colourPointers=input$statsPointersColourInput")
}
}
plotString <- paste0(plotString,")")
eval(parse(text=plotString))
## changes to side panel
## changes to main panel
})
#~ output$statsPlotFeaturesOut <- renderUI({
#~ choices <- values$statsPlotFeatures
#~ selectInput('statsPlotFeatures',NULL,c("Choose type:"="","vLine"="Lines","Circle"="Circles","Rectangle"="Rectangles","Pointer"="Pointers"))
#~ })
output$downloadStatsPlot <- downloadHandler(
filename = function() {
if (toggles$statsRegion==F) {
paste0('statsPlot.pdf')
} else {
region <- paste0(input$statsPlotChrIn,"_",input$statsPlotChrStart,"-",input$statsPlotChrEnd)
paste0('statsPlot_',region,'.pdf')
}
},
content = function(file) {
if (toggles$statsRegion==F) {
ggsave(file, plot=plots$statsPlot, device=cairo_pdf, width = 35, height = 50, units = "cm")
} else {
ggsave(file, plot=plots$statsPlot, device=cairo_pdf, width = 30, height = 12, units = "cm")
}
}
)
output$downloadStatsCSV <- downloadHandler(
filename = function() {
if (toggles$statsRegion==F) {
paste0('statsData.csv')
} else {
region <- paste0(input$statsPlotChrIn,"_",input$statsPlotChrStart,"-",input$statsPlotChrEnd)
paste0('statsData_',region,'.csv')
}
},
content = function(file) {
fileContent <- data.frame(
chrom=factor(),chromStart=integer(),chromEnd=integer(),
name.rep=factor(),name.nonRep=factor(),ratio=numeric(),
group=integer(),splineSmooth=numeric(),p.value=numeric()
)
guide <- DFs$guide
guide <- guide[order(guide$order,na.last = T),]
rownames(guide) <- 1:nrow(guide)
samples <- length(na.omit(guide$order))
for (i in 1:samples) {
rep <- guide$name.rep[i]
nonRep <- guide$name.nonRep[i]
currentRatio <- DFs$stats[DFs$stats$name.rep==rep & DFs$stats$name.nonRep==nonRep,]
fileContent <- rbind(fileContent,currentRatio)
warning(dfHead(fileContent))
}
if (toggles$statsRegion==F) {
write.table(fileContent,file=file,sep=",",col.names=T,row.names=F,quote=F)
} else {
fileContent <- subset(
fileContent,chrom==input$statsPlotChrIn & chromStart>=input$statsPlotChrStart & chromEnd<=input$statsPlotChrEnd
)
write.table(fileContent,file=file,sep=",",col.names=T,row.names=F,quote=F)
}
}
)
####################################### end of outputs ########################################
}
#~ output$downloadZIP <- downloadHandler(
#~ filename = function() {
#~ paste0(values$tCourseName, ".zip")
#~ },
#~ content = function(fname) {
#~ fs <- c()
#~ tmpdir <- tempdir()
#~ setwd(tempdir())
#~ for (sampleName in values$tCourseSamples) {
#~ path <- paste0(sampleName,".csv")
#~ fs <- c(fs, path)
#~ write.table(values$ratioDFs[[sampleName]],file=path,sep=",",col.names=T,row.names=F,quote=F)
#~ }
#~ zip(zipfile=fname, files=fs)
#~ },
#~ contentType = "application/zip"
#~ )
|
120aa7acca0c11b6b6d04d716244fd24208e9af6
|
b1a059096bb0205bf316ad14125ea8f7ebda51d8
|
/lib/feature2.R
|
c4937c6c9f003aebd258aefac2ea8c8a1e407b25
|
[] |
no_license
|
TZstatsADS/Fall2018-Proj3-Sec2-grp5
|
bf251ac90b49d21a40a5b8ee9d42a1140e3f6b87
|
65cf18bf6a27307e9fe09864e203e13c32877812
|
refs/heads/master
| 2020-03-31T23:10:38.749169
| 2018-11-23T08:05:06
| 2018-11-23T08:05:06
| 152,645,139
| 1
| 2
| null | null | null | null |
UTF-8
|
R
| false
| false
| 8,898
|
r
|
feature2.R
|
#############################################################
### Construct features and responses for training images###
#############################################################
### Authors: Chengliang Tang/Tian Zheng
### Project 3
# feature with 9*9
# helper function to get the value for the neighbor 8 pixels - central pixel
#get_pixel_value <- function(All_value, Given_Row_Index, Given_Col_Index){
# if( Given_Row_Index <= 0 | Given_Row_Index > nrow(All_value) | Given_Col_Index <= 0 | Given_Col_Index > ncol(All_value) ){
# return(NA)
# }
#
# else{
# return(All_value[Given_Row_Index, Given_Col_Index])
# }
#}
# Helper function get feature value
Extract_Feature <- function(LR_Image, HR_Image, Color_Chanel, Sample_Size){
LR_image_data_chanel <- LR_Image[ , , Color_Chanel]
HR_image_data_chanel <- HR_Image[ , , Color_Chanel]
### step 1. sample n_points from imgLR
Sample_Points <- sample(c(1:length(LR_image_data_chanel)), Sample_Size)
# Sample_Points <- c(1:1000)
Result_LR_Neighbor_value <- matrix(nrow = Sample_Size, ncol = 24)
Result_sub_pixels <- matrix(nrow = Sample_Size, ncol = 4)
##################### Distance matrix
## 5*5
D <- matrix(0,ncol = 5,nrow = 5)
for (i in 1:5){
for (j in 1:5){
D[i,j] <- sqrt((i-3)^2 + (j-3)^2)
}
}
## 9*9
# D <- matrix(0,ncol = 9,nrow = 9)
# for (i in 1:9){
# for (j in 1:9){
# k[i,j] <- sqrt((i-5)^2 + (j-5)^2)
# }
# }
### step 2. for each sampled point in imgLR,
### step 2.1. save (the neighbor 8 pixels - central pixel) in featMat
### tips: padding zeros for boundary points
### step 2.2. save the corresponding 4 sub-pixels of imgHR in labMat
for (index in c(1:Sample_Size)) {
Row_Index <- arrayInd(Sample_Points[index], dim(LR_image_data_chanel))[1]
Col_Index <- arrayInd(Sample_Points[index], dim(LR_image_data_chanel))[2]
###################### get neighbour pixel value
# 5*5
Fivematrix <- matrix(NA,nrow=5,ncol=5)
Fivematrix[max(4-Row_Index,1):min(3+nrow(LR_image_data_chanel)-Row_Index,5),max(4-Col_Index,1):min(3+ncol(LR_image_data_chanel)-Col_Index,5)] <- LR_image_data_chanel[max(Row_Index-2,1):min(Row_Index+2,nrow(LR_image_data_chanel)),max(Col_Index-2,1):min(Col_Index+2,ncol(LR_image_data_chanel))]
# 9*9
# Ninematrix <- matrix(NA,nrow=9,ncol=9)
# Ninematrix[max(6-Row_Index,1):min(5+nrow(LR_image_data_chanel)-Row_Index,9),max(6-Col_Index,1):min(5+ncol(LR_image_data_chanel)-Col_Index+2,9)]
# <- LR_image_data_chanel[max(Row_Index-4,1):min(Row_Index+4,nrow(LR_image_data_chanel)),max(Col_Index-4,1):min(Col_Index+4,ncol(LR_image_data_chanel))]
# LR_up_left <- get_pixel_value(LR_image_data_chanel, Row_Index-1, Col_Index-1)
# LR_left <- get_pixel_value(LR_image_data_chanel, Row_Index, Col_Index-1)
# LR_bottom_left <- get_pixel_value(LR_image_data_chanel, Row_Index+1, Col_Index-1)
# LR_up <- get_pixel_value(LR_image_data_chanel, Row_Index-1, Col_Index)
# LR_center <- get_pixel_value(LR_image_data_chanel, Row_Index, Col_Index)
# LR_bottom <- get_pixel_value(LR_image_data_chanel, Row_Index+1, Col_Index)
# LR_up_right <- get_pixel_value(LR_image_data_chanel, Row_Index-1, Col_Index+1)
# LR_right <- get_pixel_value(LR_image_data_chanel, Row_Index, Col_Index+1)
# LR_bottom_right <- get_pixel_value(LR_image_data_chanel, Row_Index+1, Col_Index+1)
Fivematrix <- Fivematrix-Fivematrix[3,3]
# Ninematrix <- Ninematrix-Ninematrix[5,5]
LR_Neighbor_value <- as.vector(Fivematrix)
# LR_Neighbor_value <- as.vector(Ninematrix)
#LR_Neighbor_value <- c(LR_up_left, LR_left, LR_bottom_left, LR_up, LR_bottom, LR_up_right, LR_right, LR_bottom_right)
# LR_Neighbor_value <- LR_Neighbor_value - LR_center
LR_Neighbor_NA_index <- which(is.na(LR_Neighbor_value))
LR_Neighbor_value[LR_Neighbor_NA_index] <- 0
LR_Neighbor_value <- LR_Neighbor_value[-13]
#Result_LR_Neighbor_value[index, ] <- LR_Neighbor_value[-40]
# weight matrix
WeightMatrix <- exp(- (D / 2) ^ 2 / 2)
Result_LR_Neighbor_value[index, ] <- LR_Neighbor_value * as.vector(WeightMatrix)[-13]
# next select sub pixel from HR
Fourmatrix <- HR_image_data_chanel[2*Row_Index-1:2*Row_Index,2*Col_Index-1:2*Col_Index]
# HR_1 <- get_pixel_value(HR_image_data_chanel, 2*Row_Index-1, 2*Col_Index-1)
# HR_2 <- get_pixel_value(HR_image_data_chanel, 2*Row_Index, 2*Col_Index-1)
# HR_3 <- get_pixel_value(HR_image_data_chanel, 2*Row_Index-1, 2*Col_Index)
# HR_4 <- get_pixel_value(HR_image_data_chanel, 2*Row_Index, 2*Col_Index)
# sub_pixels <- c(HR_1, HR_2, HR_3, HR_4)
sub_pixels <- as.vector(Fourmatrix)
sub_pixels <- sub_pixels-Fivematrix[3,3]
# sub_pixels <- sub_pixels - LR_center
Result_sub_pixels[index,] <- sub_pixels
# print(which(is.na(sub_pixels)))
#
if(length(which(is.na(sub_pixels)))>0){
print("========")
print(nrow(LR_image_data_chanel))
print(ncol(LR_image_data_chanel))
print("========")
print(nrow(HR_image_data_chanel))
print(ncol(HR_image_data_chanel))
print("========")
print(Row_Index)
print(Col_Index)
print(2*Row_Index-1)
print(2*Col_Index-1)
print(2*Row_Index)
print(2*Col_Index-1)
print(2*Row_Index-1)
print("========")
}
}
return(list(LR_Neighbor_value = Result_LR_Neighbor_value, sub_pixels = Result_sub_pixels))
}
feature2 <- function(LR_dir, HR_dir, n_points=1000){
### Construct process features for training images (LR/HR pairs)
### Input: a path for low-resolution images + a path for high-resolution images
### + number of points sampled from each LR image
### Output: an .RData file contains processed features and responses for the images
### load libraries
library("EBImage")
n_files <- length(list.files(LR_dir))
# n_files <- 100
### store feature and responses
featMat <- array(NA, c(n_files * n_points, 24, 3))
labMat <- array(NA, c(n_files * n_points, 4, 3))
# nrow(featMat[,,1])
### read LR/HR image pairs
Mat_Index <- 1
for(i in 1:n_files){
imgLR <- readImage(paste0(LR_dir, "img_", sprintf("%04d", i), ".jpg"))
imgHR <- readImage(paste0(HR_dir, "img_", sprintf("%04d", i), ".jpg"))
LR_image_data <- imageData(imgLR)
HR_image_data <- imageData(imgHR)
### step 3. repeat above for three channels
Result_Feature_Red <- Extract_Feature(LR_image_data, HR_image_data, 1, n_points)
Result_Feature_LR_Neighbor_value_Red <- Result_Feature_Red$LR_Neighbor_value
Result_Feature_sub_pixels_Red <- Result_Feature_Red$sub_pixels
Result_Feature_Green <- Extract_Feature(LR_image_data, HR_image_data, 2, n_points)
Result_Feature_LR_Neighbor_value_Green <- Result_Feature_Green$LR_Neighbor_value
Result_Feature_sub_pixels_Green <- Result_Feature_Green$sub_pixels
Result_Feature_Blue <- Extract_Feature(LR_image_data, HR_image_data, 3, n_points)
Result_Feature_LR_Neighbor_value_Blue <- Result_Feature_Blue$LR_Neighbor_value
Result_Feature_sub_pixels_Blue <- Result_Feature_Blue$sub_pixels
# if(i == 3){
# print(Result_Feature_LR_Neighbor_value_Red[1:5, ])
# print(LR_image_data[1:5,1:5,1])
# print(Result_Feature_sub_pixels_Red[1:5, ])
# print(HR_image_data[1:5,1:5,1])
# print(Result_Feature_LR_Neighbor_value_Green[1:5, ])
# print(LR_image_data[1:5,1:5,2])
# print(Result_Feature_sub_pixels_Green[1:5, ])
# print(LR_image_data[1:5,1:5,2])
# print(Result_Feature_LR_Neighbor_value_Blue[1:5, ])
# print(LR_image_data[1:5,1:5,3])
# }
for (Value_Index in c(1:n_points)) {
featMat[Mat_Index, , 1] <- Result_Feature_LR_Neighbor_value_Red[Value_Index,]
labMat[Mat_Index, , 1] <- Result_Feature_sub_pixels_Red[Value_Index,]
featMat[Mat_Index, , 2] <- Result_Feature_LR_Neighbor_value_Green[Value_Index,]
labMat[Mat_Index, , 2] <- Result_Feature_sub_pixels_Green[Value_Index,]
featMat[Mat_Index, , 3] <- Result_Feature_LR_Neighbor_value_Blue[Value_Index,]
labMat[Mat_Index, , 3] <- Result_Feature_sub_pixels_Blue[Value_Index,]
# nrow(featMat[,,1])
### read LR/HR image pairs
Mat_Index <- Mat_Index + 1
}
cat("file", i, "\n")
}
return(list(feature = featMat, label = labMat))
}
|
6243217e27c268f274662183feb1ffe2a687ff70
|
1dd7892ae8546fdee168ca69fc2ddba36c9028e6
|
/plot2.R
|
4fba428fb8289f488227e163a0dc9a9d161b3ecb
|
[] |
no_license
|
csllam/ExData_Plotting1
|
378a8a1a17999283c0c3a041be46ab24e0fec86c
|
84489aa7945576e64e27ca326ceadb204bacdad9
|
refs/heads/master
| 2021-01-17T06:16:59.054905
| 2015-02-08T06:34:38
| 2015-02-08T06:34:38
| 30,482,589
| 0
| 0
| null | 2015-02-08T06:00:52
| 2015-02-08T06:00:52
| null |
UTF-8
|
R
| false
| false
| 612
|
r
|
plot2.R
|
##plot2.R
Dat<-read.csv("exdata_data_household_power_consumption/household_power_consumption.txt", sep = ";")
DAT<- subset(Dat, subset = Dat$Date == "1/2/2007" | Dat$Date == "2/2/2007")
DAT$Global_active_power <- as.numeric(as.character(DAT$Global_active_power))
DAT$Date<- as.character(DAT$Date)
DAT$Time<- as.character(DAT$Time)
DAT$datetime = as.POSIXct(paste(DAT$Date, DAT$Time), format="%d/%m/%Y %H:%M:%S")
png("plot2.png", width = 480, height = 480, units="px", bg = "transparent")
plot(x = DAT$datetime, y= DAT$Global_active_power, type="l", xlab = "", ylab="Global Active Power (kilowatts)")
dev.off()
|
9ef52befdbad092adcbbe1087b9a936f6521be4b
|
85a0e45a8d85ab80d6bcf48560dec3c2e502a4d7
|
/nightLightsExample.R
|
cad00f0712e0a3fcbce93f47cce44561fc00f571
|
[] |
no_license
|
garrett-w-powers/rgeeTraining
|
1fcb335f07b0466338e9abffe7ce9fc908446f5b
|
f60376bc658b3718a48cff1c5e3f6f8d8fca23c5
|
refs/heads/main
| 2023-04-25T07:19:22.946641
| 2021-05-19T14:55:12
| 2021-05-19T14:55:12
| 368,894,472
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 928
|
r
|
nightLightsExample.R
|
library(rgee)
ee_Initialize()
#add a band containing image date as years since 1991
createTimeBand <- function(img) {
year <- ee$Date(img$get('system:time_start'))$get('year')$subtract(1991L)
ee$Image(year)$byte()$addBands(img)
}
#map the time band creation helper over the night lights collection
collection <- ee$ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS')$
select('stable_lights')$
map(createTimeBand)
#compute a linear fit over the seriese of values at each pixel,
#visualizing the y intercept in green and positive/negative slopes as red/blue
col_reduce <- collection$reduce(ee$Reducer$linearFit())
col_reduce <- col_reduce$addBands(
col_reduce$select('scale')
)
ee_print(col_reduce)
Map$setCenter(9.08203, 47.39835, 3)
Map$addLayer(
eeObject = col_reduce,
visParams = list(
bands = c("scale", "offset", "scale"),
min = 0,
max = c(0.18, 20, -0.18)
),
name = "stable lights trend"
)
|
f6f3aef35688ab53457318992e0e77b296566940
|
3de36a93bafc5f58aaaeb316d2d7bf7c774e2464
|
/R/rgl.isomap.R
|
dda53bc2e127d6e2b7deeedc9e68fc151494037e
|
[] |
no_license
|
vanderleidebastiani/vegan
|
fc94bdc355c0520c383942bdbfb8fd34bd7b4438
|
dd2c622d0d8c7c6533cfd60c1207a819d688fd1f
|
refs/heads/master
| 2021-01-14T08:27:15.372938
| 2013-12-17T18:19:10
| 2013-12-17T18:19:10
| 15,258,339
| 0
| 1
| null | null | null | null |
UTF-8
|
R
| false
| false
| 266
|
r
|
rgl.isomap.R
|
`rgl.isomap` <-
function(x, web = "white", ...)
{
require(rgl) || stop("requires package 'rgl'")
ordirgl(x, ...)
z <- scores(x, ...)
net <- x$net
for (i in 1:nrow(net))
rgl.lines(z[net[i,],1], z[net[i,],2], z[net[i,],3], color=web)
}
|
8cf724c795e58eab20878c6e2d645c97582ca2b4
|
b2f61fde194bfcb362b2266da124138efd27d867
|
/code/dcnf-ankit-optimized/Results/QBFLIB-2018/A1/Database/Letombe/renHorn/renHorn_400CNF1280_2aQBF_62/renHorn_400CNF1280_2aQBF_62.R
|
02f17c6035b78733c4cd9526b73b2e08c2907089
|
[] |
no_license
|
arey0pushpa/dcnf-autarky
|
e95fddba85c035e8b229f5fe9ac540b692a4d5c0
|
a6c9a52236af11d7f7e165a4b25b32c538da1c98
|
refs/heads/master
| 2021-06-09T00:56:32.937250
| 2021-02-19T15:15:23
| 2021-02-19T15:15:23
| 136,440,042
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 77
|
r
|
renHorn_400CNF1280_2aQBF_62.R
|
369759c0130d583c2cc5984e4fe756b1 renHorn_400CNF1280_2aQBF_62.qdimacs 400 1280
|
232ce5c1707cefaf8aec68f469d6b5fca783a7f7
|
e2c647ffbf27b64d2e20e0f6266e65f06582f651
|
/run_analysis.R
|
eb4a8c6114cb0df4f109a88b2365f8e7b5aaf66e
|
[] |
no_license
|
i-digital/CleaningData_Assgn
|
3b591a329084f348819971fe8894fa4df6db94c8
|
1dfdc552862142c6168dc9cc39f19ff0cabe276c
|
refs/heads/master
| 2016-08-10T22:34:05.047901
| 2016-02-13T10:30:52
| 2016-02-13T10:30:52
| 51,641,826
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 2,165
|
r
|
run_analysis.R
|
#setwd("/Projects/GIT/MOOC/Data Science/assignments/CleaningData_Assgn")
## Activity Labels
activityDF <- read.table("UCI HAR Dataset/activity_labels.txt", header = FALSE, stringsAsFactors = FALSE)
## Features
features <- read.table("UCI HAR Dataset/features.txt", header = FALSE, stringsAsFactor = FALSE)
## Read Test Data
test_data <- read.table("UCI HAR Dataset/test/X_test.txt", header = FALSE)
test_subject <- read.table("UCI HAR Dataset/test/subject_test.txt", header = FALSE, stringsAsFactors = FALSE)
test_label <- read.table("UCI HAR Dataset/test/y_test.txt", header = FALSE, colClasses = c("factor"))
## Give descriptive variable names
#names(test_data) <- paste("test_", features[,2], sep = "")
names(test_data) <- features[,2]
# Combine Test Data
test_data$subject <- test_subject[,1]
test_data$activity <- test_label[,1]
rm("test_label","test_subject")
## Read Training Data
train_data <- read.table("UCI HAR Dataset/train/X_train.txt", header = FALSE)
train_subject <- read.table("UCI HAR Dataset/train/subject_train.txt", header = FALSE, stringsAsFactors = FALSE)
train_label <- read.table("UCI HAR Dataset/train/y_train.txt", header = FALSE, colClasses = c("factor"))
## Give descriptive variable names
#names(train_data) <- paste("training_", features[,2], sep = "")
names(train_data) <- features[,2]
# Combine Training Data
train_data$subject <- train_subject[,1]
train_data$activity <- train_label[,1]
rm("train_label","train_subject")
## Merged Test & Training Data
test_data$mode <- "test"
train_data$mode <- "training"
mergedData <- rbind(train_data, test_data)
## Extract only those with "mean" and "standard deviation"
filterData <- mergedData[,append(grep("[mM]ean|[sS]td", names(mergedData)), c(562,563,564))]
## Assign descriptive value for 'activity'
levels(filterData$activity) <- activityDF[,2]
## Reshape data to create Tidy Data
library(reshape2)
longData <- melt(filterData, id = c("subject","activity","mode"))
tidyData <- dcast(longData, subject + activity + mode ~ variable, mean)
## Save the data as text file
write.table(tidyData, "tidyData.txt", row.names = FALSE)
## Clean up
rm("longData")
#### END ####
|
5f3d798eb99ebcd1f50b366f3a1727a577639a51
|
822c73ded025bf2d03903809aa240b7fe78799aa
|
/R/functions_for_testing.R
|
72bc017b7f5fdd8acd0852ac878c7109e573107c
|
[] |
no_license
|
Nekojou/masters-thesis
|
0bedf25b5685763921aa82420602af8c4c9f332f
|
ba2907e34368f047bd55009b2f1ae108e14d2bba
|
refs/heads/master
| 2021-09-10T07:58:56.128194
| 2018-03-22T13:24:58
| 2018-03-22T13:24:58
| 112,517,977
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 649
|
r
|
functions_for_testing.R
|
# generate some test samples
# according to simulation study 1 (weibull distributions)
# but without varying the parameter alpha2
test.generateTestSamples <- function(numberOfCases=2,montecarloRepetitions=10)
{
samples<-matrix(data.frame(), nrow=numberOfCases, ncol=montecarloRepetitions)
for(casesIterator in 1:numberOfCases){
for(repetitionsIterator in 1:montecarloRepetitions){
{
X = rweibull(100, 2, 3)
Y = rweibull(100, 1.5, 4.5)
Z = mapply(min, X, Y)
delta = ifelse(X<=Y,1,0)
samples[[casesIterator,repetitionsIterator]] = data.frame(Z,delta)
}
}
}
return(samples)
}
|
ff2a85a5b29d82e8cadb2e513e725bb78d990b31
|
ded62e5f272ada0a34f658d4b6ba25dcd3f08a2c
|
/Code/PredictCM_RAMspp.R
|
b0e8faac9103a661d78ddc8d7255f31c34715275
|
[] |
no_license
|
bselden/RAM_FishClim
|
39a1819d5f274badf3d8555195dd3f8d7ab2c258
|
5b17a9ad81fae13bdef0cc9ce38325152e2ad613
|
refs/heads/master
| 2020-05-02T07:50:49.087082
| 2019-06-24T20:24:07
| 2019-06-24T20:24:07
| 177,828,089
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 9,809
|
r
|
PredictCM_RAMspp.R
|
library(data.table)
library(Hmisc)
load("Data/hauls_catch_Dec2017.RData", verbose=T)
ram.stocks <- readRDS("Data/ram.stock.us.rds")
setorder(ram.stocks, scientificname)
### Species catch by haul
catch.dt <- as.data.table(dat)
haul.dt <- as.data.table(hauls)
### Classify hauls into RAM regions
haul.dt[,"subarea":=ifelse(regionfact=="AFSC_EBS", "EBS",
ifelse(regionfact=="AFSC_Aleutians", "AI",
ifelse(regionfact=="AFSC_GOA", "GOA",
ifelse(regionfact=="AFSC_WCTri", "US West Coast",
ifelse(regionfact=="NEFSC_NEUS", "US East Coast",
ifelse(regionfact=="NWFSC_WCAnn", "US West Coast",
ifelse(regionfact=="SEFSC_GOMex", "GMex",
ifelse(regionfact=="SCDNR_SEUS", "SEUS",
ifelse(regionfact=="DFO_Newfoundland", "Canada East Coast",
ifelse(regionfact=="DFO_SoGulf", "Canada East Coast",
ifelse(regionfact=="DFO_ScotianShelf", "Canada East Coast", NA)))))))))))]
haul.stratum.obs <- haul.dt[,list(num.yrs.obs=length(unique(year))), by=list(stratum, regionfact, subarea, ocean, surveyfact)]
yrs.obs.region <- haul.dt[,list(num.yrs.surv=length(unique(year))), by=list(regionfact, subarea, ocean, surveyfact)]
haul.stratum.obs2 <- merge(haul.stratum.obs, yrs.obs.region, by=c("regionfact", "ocean", "subarea", "surveyfact"))
haul.stratum.obs2[,"frac.yrs":=num.yrs.obs/num.yrs.surv]
### Limit to strata observed in >=90% of years of a survey & year >=1968 (so both spring and fall combined for NEUS)
haul.dt2 <- haul.dt[stratum %in% haul.stratum.obs2[frac.yrs>=0.9]$stratum & year>=1968]
catch.dt2 <- catch.dt[haulid %in% haul.dt2$haulid]
catch.dt2[,"spp":=capitalize(gsub("_.*$", "", sppocean))]
### Limit to just RAM species
catch.dt.ram <- catch.dt2[spp %in% ram.stocks$scientificname]
### Merge with haul location
catch.wloc <- merge(catch.dt.ram,
haul.dt2[,list(haulid=haulid, regionfact=regionfact)],
by=c("haulid"))
### Create master sheet where every species
haul.master <- catch.wloc[,j={
t.dt <- .SD
temp <- CJ(haulid=unique(t.dt$haulid), sppocean=unique(t.dt$sppocean))
}, by=list(regionfact)]
haul.master[,"spp":=capitalize(gsub("_.*$", "", sppocean))]
### Merge back into haul.dt2 to get other data
haul.master.meta <- merge(haul.master, haul.dt2, by=c("haulid", "regionfact"))
### Keep only the variables I want for all hauls
keep.cols <- c("haulid", "regionfact", "subarea", "spp", "sppocean", "lat", "lon", "stratum",
"region", "year", "month", "depth", "rugosity", "GRAINSIZE",
"SBT.actual", "SST.actual", "SBT.seasonal", "SST.seasonal.mean",
"SBT.min", "SBT.max", "SST.min", "SST.max")
haul.master.meta <- haul.master.meta[,keep.cols, with=F]
## This confirms that every species had all hauls in a region represented
with(haul.master.meta[regionfact=="NEFSC_NEUS" & spp %in% c("Gadus morhua", "Centropristis striata", "Urophycis chuss")],
table(year, spp))
### Merge with catch data, and add zeros where not observed
catch.w.zeros <- merge(haul.master.meta, catch.wloc, by=c("haulid", "spp", "sppocean", "regionfact"), all.x=T)
catch.w.zeros[,"wtcpue":=ifelse(is.na(wtcpue), 0, wtcpue)]
catch.w.zeros[,"logwtcpue":=ifelse(is.na(logwtcpue), -10, logwtcpue)]
catch.w.zeros[,"presfit":=ifelse(is.na(presfit), FALSE, presfit)]
setorder(catch.w.zeros, sppocean)
### Clim Fits
### From Jim Morley
### Downloaded from Amphiprion nicheMods_PlosOne2018
mod_list <- list.files("Data/CEmods", ".RData")
sppocean_list <- gsub("CEmods_Nov2017_fitallreg_2017_", "", gsub(".RData", "", mod_list))
spp_lookup <- data.table(sppocean=sppocean_list)
spp_lookup[,"spp":=capitalize(gsub("_.*$", "", sppocean))]
pred.dt <- catch.w.zeros[sppocean %in% spp_lookup$sppocean,j={
print(sppocean)
t.dt <- .SD
spp <- which(sppocean_list==eval(sppocean))
load(paste0("Data/CEmods/", mod_list[spp]), verbose=T)
dt.fit <- as.data.table(mods$mygam1$model)
dt.fit.bio <- as.data.table(mods$mygam2$model)
region.orig <- levels(dt.fit$regionfact) #original fit only had some regions
# some didn't have regionfact in there (potentially for spp in single regions?)
if(!(is.null(region.orig))){
sub <- t.dt[regionfact %in% region.orig]
} else{sub <- copy(t.dt)}
sub[,"pred.pres" := predict(mods$mygam1, newdata=sub, type="response")]
sub[,"pred.log.bio":=predict(mods$mygam2, newdata=sub, type="response")]
### Combined prediction (pred.pres * exp(pred.log.bio))
sub[,"pred.total":=pred.pres * exp(pred.log.bio)]
list(haulid=sub$haulid,
spp=sub$spp,
regionfact=sub$regionfact,
subarea=subarea,
lat=sub$lat,
lon=sub$lon,
stratum=sub$stratum,
region=sub$region,
year=sub$year,
month=sub$month,
depth=sub$depth,
SBT.actual=sub$SBT.actual,
SBT.seasonal=sub$SBT.seasonal,
SST.seasonal.mean=sub$SST.seasonal.mean,
SBT.min=sub$SBT.min,
SBT.max=sub$SBT.max,
SST.min=sub$SST.min,
SST.max=sub$SST.max,
wtcpue=sub$wtcpue,
logwtcpue=sub$wtcpue,
presfit=sub$presfit,
pred.pres=sub$pred.pres,
pred.log.bio=sub$pred.log.bio,
pred.total=sub$pred.total)
}, by=list(sppocean)]
pred.dt[is.na(spp), unique(sppocean)]
saveRDS(pred.dt, "Output/pred.dt.rds")
#Run if want to read in existing output
pred.dt <- readRDS("Output/pred.dt.rds")
##################################
### Centroids in each year (and lagged)
### Centroid in each year, and mean environmental variables
### Averaging across fall and spring (previously limited to 1968 and later)
spp_dist <- pred.dt[complete.cases(lat, lon, depth),
list(obs.lat=weighted.mean(lat, wtcpue),
obs.lon=weighted.mean(lon, wtcpue),
obs.depth=weighted.mean(depth, wtcpue),
SBT.seasonal=mean(SBT.seasonal),
SST.seasonal=mean(SST.seasonal.mean),
SBT.min=mean(SBT.min),
SST.min=mean(SST.min),
SBT.max=mean(SBT.max),
SST.max=mean(SST.max),
wtcpue=mean(wtcpue),
freq.occ=mean(presfit),
pred.lat.pres=weighted.mean(lat, pred.pres),
pred.lon.pres=weighted.mean(lon, pred.pres),
pred.depth.pres=weighted.mean(depth, pred.pres),
pred.lat.bio=weighted.mean(lat, pred.total),
pred.lon.bio=weighted.mean(lon, pred.total),
pred.depth=weighted.mean(depth, pred.total)),
by=list(spp, sppocean, subarea, year)]
setorder(spp_dist, spp, sppocean, subarea, year)
# Matches Jim's gams in bsb_gamVSbrt_allseasons.pdf email from 10/9/2018
plot(obs.lat ~ year, spp_dist[spp=="Centropristis striata" & subarea=="US East Coast"], type="o",
ylab="Latitude (w=wtcpue)")
points(pred.lat.bio ~ year, spp_dist[spp=="Centropristis striata" & subarea=="US East Coast"], type="o", col="blue")
### Lead variables
vars <- c("obs.lat", "obs.lon", "obs.depth", "pred.lat.bio", "pred.lon.bio", "pred.depth")
lead1cols <- paste("lead1", vars, sep=".")
cent_master_lim <- copy(spp_dist)
cent_master_lim[,(lead1cols):=shift(.SD, n=1, type="lead"), by=list(spp, sppocean, subarea), .SDcols=vars]
### Annual difference
cent_master_lim[,"lat.cent.diff":= lead1.obs.lat - obs.lat, by=list(sppocean, spp, subarea)]
cent_master_lim[,"lat.cent.cm.diff":=lead1.pred.lat.bio - pred.lat.bio, by=list(sppocean, spp, subarea)]
### Observed - predicted annual diff
cent_master_lim[,"annual.obsminuspred":=lat.cent.diff - lat.cent.cm.diff]
cent_master_lim[,"sign.pred":=sign(lat.cent.cm.diff)]
cent_master_lim[,"annual.bias":=annual.obsminuspred*sign.pred]
hist(cent_master_lim$annual.bias)
cent_master_lim[,"nyrs.obs":=length(unique(year[is.finite(obs.lat)])), by=list(sppocean, spp, subarea)]
#### Rate of change over time for spp sub area combinations with at least 5 years of observations
### 271 spp, subarea combinations
cent_lm <- cent_master_lim[nyrs.obs>5,j={
print(paste0(spp, " ", subarea))
t.dt <- .SD
lm.obs <- lm(obs.lat ~ year)
lm.pred <- lm(pred.lat.bio ~ year, t.dt)
list(lm.obs.slope=summary(lm.obs)$coefficients[2,1],
lm.obs.p=summary(lm.obs)$coefficients[2,4],
lm.obs.r2=summary(lm.obs)$r.squared,
lm.pred.slope=summary(lm.pred)$coefficients[2,1],
lm.pred.p=summary(lm.pred)$coefficients[2,4],
lm.pred.r2=summary(lm.pred)$r.squared)
}, by=list(sppocean, spp, subarea, nyrs.obs)]
cent_lm[,"obsminuspred":=ifelse(lm.pred.slope>0, lm.obs.slope - lm.pred.slope, -(lm.obs.slope-lm.pred.slope))]
png("Figures/lagclim_null.png", height=5, width=5, units="in", res=300)
plot(lm.obs.slope ~ lm.pred.slope, cent_lm)
points(lm.obs.slope ~ lm.pred.slope, cent_lm[obsminuspred<0], col="blue", pch=10, cex=0.5)
abline(a=0, b=1, col="red")
abline(h=0, lty=2)
abline(v=0, lty=2)
dev.off()
plot(freq.occ ~ year, cent_master_lim[spp=="Centropristis striata" & subarea=="US East Coast"])
plot(freq.occ ~ year, cent_master_lim[spp=="Gadus morhua" & subarea=="US East Coast"])
save(cent_master_lim, cent_lm, file="Output/cent_out.RData")
|
f6fbac84de7523408b7c97d877757ddd7434d1ec
|
6228e9c9be718a2d59665a455cdd42f212b0b732
|
/R/rem_mv.R
|
50ed3a92ae2905132e177885d4a14aa31d656bb4
|
[] |
no_license
|
csbl-usp/MetaVolcanoR
|
ef6080be107274fb5a26caf0c845c0eda7bd5c98
|
c0f64a47d566b294bfffdc0b72fb1be789e5cf8c
|
refs/heads/master
| 2023-08-18T08:07:29.869316
| 2019-11-04T09:38:37
| 2019-11-04T09:38:37
| 150,426,737
| 18
| 1
| null | 2023-08-10T08:19:09
| 2018-09-26T12:56:31
|
R
|
UTF-8
|
R
| false
| false
| 7,894
|
r
|
rem_mv.R
|
#' @importFrom parallel mclapply
#' @importFrom topconfects normal_confects
#' @importFrom methods new 'slot<-' show
#' @importFrom plotly as_widget ggplotly
#' @importFrom htmlwidgets saveWidget
#' @import dplyr
setOldClass('gg')
setOldClass('ggplot')
#' An S4 class to represent MetaVolcanoR results
#'
#' @slot input merged diiferential expression inputs \code{data.frame}
#' @slot inputnames names of the differential expression inputs \code{character}
#' @slot metaresult meta-analysis results \code{data.frame}
#' @slot MetaVolcano plot with meta-analysis results
#' @slot degfreq supplementary figure of the vote-counting MetaVolcano
setClass('MetaVolcano', slots = list(input='data.frame',
inputnames='character',
metaresult='data.frame',
MetaVolcano='gg',
degfreq='gg'
))
#' A function to perform the Random Effect Model (REM) MetaVolcano
#'
#' This function runs the 'Random Effect Model' MetaVolcano section
#' @param diffexp list of data.frame/data.table (s) with DE results where lines
#' are genes
#' @param pcriteria the column name of the pvalue variable <string>
#' @param foldchangecol the column name of the foldchange variable <string>
#' @param genenamecol the column name of the gene name variable <string>
#' @param geneidcol the column name of the gene ID/probe/oligo/transcript
#' variable <string>
#' @param collaps if probes should be collapsed based on the DE direction
#' <logical>
#' @param llcol left limit of the fold change coinfidence interval variable
#' name <string>
#' @param rlcol right limit of the fold change coinfidence interval variable
#' name <string>
#' @param vcol name of the fold change variance variable <string>
#' @param cvar weather or not to calculate gene variance from confidence
#' interval limits <logical>
#' @param metathr top percentage of perturbed genes to be highlighted <double>
#' @param jobname name of the running job <string>
#' @param outputfolder /path where to write the results/
#' @param draw wheather or not to draw the .html visualization <logical>
#' @param ncores the number of processors the user wants to use <integer>
#' @keywords write 'combining meta-analysis' metavolcano
#' @return MetaVolcano object
#' @export
#' @examples
#' data(diffexplist)
#' diffexplist <- lapply(diffexplist, function(del) {
#' dplyr::filter(del, grepl("MP", Symbol))
#' })
#' mv <- rem_mv(diffexplist, metathr = 0.1)
#' str(mv)
rem_mv <- function(diffexp=list(), pcriteria="pvalue", foldchangecol="Log2FC",
genenamecol="Symbol", geneidcol=NULL, collaps=FALSE,
llcol="CI.L", rlcol="CI.R", vcol=NULL, cvar=TRUE,
metathr=0.01, jobname="MetaVolcano", outputfolder=".",
draw='HTML', ncores=1) {
if(!draw %in% c('PDF', 'HTML')) {
stop("Oops! Seems like you did not provide a right 'draw' parameter.
Try 'PDF' or 'HTML'")
}
# ---- Calculating variance from coifidence interval
if(cvar == TRUE) {
diffexp <- lapply(diffexp, function(...) calc_vi(..., llcol, rlcol))
vcol <- 'vi'
} else {
if(is.null(vcol)) {
stop("Oops! If cvar=FALSE, you should provide a variance stimate,
Please, check the vcol parameter.")
}
}
if (collaps) {
# --- Removing non-named genes
diffexp <- lapply(diffexp, function(g) {
g %>%
dplyr::filter(!!as.name(genenamecol) != "") %>%
dplyr::filter(!is.na(!!as.name(genenamecol))) %>%
dplyr::filter(!!as.name(genenamecol) != "NA")
})
# --- Collapsing redundant geneIDs. Rataining the geneID with the
# --- smallest pcriteria
diffexp <- lapply(diffexp, function(g) {
collapse_deg(g, genenamecol, pcriteria)
})
# --- Subsetting the diffexp inputs
diffexp <- lapply(diffexp, function(...) dplyr::select(...,
dplyr::matches(paste(c(genenamecol, foldchangecol,
llcol, rlcol, vcol),
collapse = '|'))))
# --- merging DEG results
diffexp <- rename_col(diffexp, genenamecol)
meta_diffexp <- Reduce(function(...) merge(..., by = genenamecol,
all = TRUE), diffexp)
genecol <- genenamecol
} else {
if(is.null(geneidcol)) {
geneidcol <- genenamecol
}
# Testing if geneIDs are unique
gid <- vapply(diffexp, function(g) {
length(unique(g[[geneidcol]])) == nrow(g)
},
logical(1))
if(all(gid)) {
# --- Subsetting the diffexp inputs
diffexp <- lapply(diffexp, function(...) dplyr::select(...,
dplyr::matches(paste(c(geneidcol, foldchangecol,
llcol, rlcol, vcol),
collapse = '|'))))
# --- merging the diffexp inputs
diffexp <- rename_col(diffexp, geneidcol)
meta_diffexp <- Reduce(function(...) merge(...,
by = geneidcol,
all = TRUE), diffexp)
genecol <- geneidcol
} else {
stop("the geneidcol contains duplicated values, consider to
set collaps=TRUE")
}
}
# Calculating the REM summary (metafor)
# computational intensive parallel run recommended
remres <- do.call(rbind,
mclapply(split(meta_diffexp, meta_diffexp[[genecol]]),
function(g) {
remodel(g, foldchangecol, vcol)
}, mc.cores = ncores)
)
remres[[genecol]] <- rownames(remres)
meta_diffexp <- merge(meta_diffexp, remres, by = genecol, all = TRUE)
# --- Subsettig genes where REML doesnt converge
meta_diffexp_err <- dplyr::filter(meta_diffexp, error == TRUE)
# --- Topconfects ranking
meta_diffexp <- meta_diffexp %>%
dplyr::filter(error != TRUE) # removing genes which REML
# failed to converge
meta_diffexp <- meta_diffexp %>%
dplyr::mutate(se = (randomCi.ub - randomCi.lb)/3.92) %>% # 95% conf.int
dplyr::mutate(index = seq(nrow(meta_diffexp)))
confects <- normal_confects(meta_diffexp$randomSummary,
se=meta_diffexp$se,
fdr=0.05,
full=TRUE)
meta_diffexp <- merge(meta_diffexp,
dplyr::select(confects$table, c(index, `rank`)),
by = 'index', all = TRUE)
# --- Keep all genes for the results report
if(nrow(meta_diffexp_err) != 0) {
meta_diffexp_err <- meta_diffexp_err %>%
dplyr::mutate(se=NA,
index=NA,
`rank`=seq(nrow(meta_diffexp_err))+nrow(meta_diffexp))
meta_diffexp <- rbind(meta_diffexp, meta_diffexp_err)
}
meta_diffexp <- dplyr::arrange(meta_diffexp, `rank`)
#####
print(head(meta_diffexp))
#####
# --- Draw REM MetaVolcano
gg <- plot_rem(meta_diffexp, jobname, outputfolder, genecol, metathr)
if(draw == "HTML") {
# --- Writing html device for offline visualization
saveWidget(as_widget(ggplotly(gg)),
paste0(normalizePath(outputfolder),
"/RandomEffectModel_MetaVolcano_",
jobname, ".html"))
} else if(draw == "PDF") {
# --- Writing PDF visualization
pdf(paste0(normalizePath(outputfolder),
"/RandomEffectModel_MetaVolcano_", jobname,
".pdf"), width = 7, height = 6)
plot(gg)
dev.off()
}
# Set REM result
icols <- paste(c(genecol, pcriteria, foldchangecol, llcol, rlcol, vcol),
collapse="|^")
rcols <- paste(c(genecol, "^random", "^het_", "^error$", "^rank$",
"signcon"), collapse="|")
result <- new('MetaVolcano',
input=dplyr::select(meta_diffexp,
dplyr::matches(icols)),
inputnames=names(diffexp),
metaresult=dplyr::select(meta_diffexp,
dplyr::matches(rcols)),
MetaVolcano=gg,
degfreq=ggplot()
)
return(result)
}
|
7779a9aa3d30c66664ee79124649214fb0b0e277
|
57079c65f2ca12dcc58ed9cbe54e32b093345627
|
/limma.R
|
41c0794d119fe9f6b147be44efbc2c7bc88fcb31
|
[] |
no_license
|
h3aknust/Assessing-differential-expression-analyses-tools
|
97eeeb507a84c63c731cd2426769353c152e49e2
|
4ac65b7ba270ac492dbd2f0fd8e37d2c65a8420e
|
refs/heads/master
| 2021-02-09T23:39:13.835516
| 2020-03-02T09:55:44
| 2020-03-02T09:55:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 3,611
|
r
|
limma.R
|
##
#This code computes for differentially expressed genes using limma
##
#Import package limma
library("limma")
library("edgeR")
#First create a DGEList object using the edgeR package:
dge <- DGEList(counts=df)
#Create a design matrix
design <- cbind("1"=1,"1vs2"=rep(c(1,2), each = nrow(metadatah)/2))
#apply scale normalization to counts, TMM normalization method perform well from comparative studies.
dge <- calcNormFactors(dge)
#In the limma-trend approach, the counts are converted to logCPM values using edgeR’s cpm function:
#The prior count is used here to damp down the variances of logarithms of low counts.
logCPM <- cpm(dge, log=FALSE, prior.count=2)
# The logCPM values can then be used in any standard limma pipeline,
# using the trend=TRUE argument when running eBayes or treat .
fit <- lmFit(logCPM, design)
fit <- eBayes(fit)
res_limma_trend_eBayes <- topTable(fit, coef=ncol(design),number=Inf)
res_limma_trend_eBayes <- subset(res_limma_trend_eBayes, adj.P.Val < 0.05)
write.table(as.data.frame(rownames(res_limma_trend_eBayes)),
paste0("limma-trend_eBayes.csv",j,".csv"),
row.names = F,sep=",",col.names=FALSE)
df1=read.csv(paste0("limma-trend_eBayes.csv",j,".csv"),header = F)
source('putinalist.R')
putinalist(df1)
# Or, to give more weight to fold-changes in the gene ranking, one might use:
# The logCPM values can then be used in any standard limma pipeline,
fit <- lmFit(logCPM, design)
fit <- treat(fit, lfc = log2(1.2))
res_limma_trend_treat <- topTreat(fit, coef = ncol(design),number=Inf)
res_limma_trend_treat <- subset(res_limma_trend_treat, adj.P.Val < 0.05)
write.table(as.data.frame(rownames(res_limma_trend_treat)),
paste0("limma-trend_treat.csv",j,".csv"),
row.names = F,sep=",",col.names=FALSE)
df1=read.csv(paste0("limma-trend_treat.csv",j,".csv"),header = F)
source('putinalist.R')
putinalist(df1)
# The voom transformation is applied to the normalized and filtered DGEList object
# (When the library sizes are quite variable between samples,
# the voom approach is theoretically more powerful than limma-trend)
# The voom transformation uses the experiment design matrix, and produces an EList object.
v <- voom(dge, design)
#It is also possible to give a matrix of counts directly to voom without TMM normalization, by
v2 <- voom(df, design, plot=TRUE)
#If the data are very noisy, one can apply the between-array normalization methods.
v3 <- voom(df, design, plot=TRUE, normalize="quantile")
# After this, the usual limma pipelines for differential expression is be applied.
fit <- lmFit(v, design)
fit <- eBayes(fit)
res_limma_voom_eBayes <- topTable(fit, coef=ncol(design),number=Inf)
res_limma_voom_eBayes <- subset(res_limma_voom_eBayes, adj.P.Val < 0.05)
write.table(as.data.frame(rownames(res_limma_voom_eBayes)),
paste0("limma_voom_eBayes.csv",j,".csv"),
row.names = F,sep=",",col.names=FALSE)
df1=read.csv(paste0("limma_voom_eBayes.csv",j,".csv"),header = F)
source('putinalist.R')
putinalist(df1)
#Or, to give more weight to fold-changes in the ranking, one could use say:
fit <- lmFit(v, design)
fit <- treat(fit)
res_limma_voom_treat <- topTreat(fit, coef=ncol(design),number=Inf)
head(res_limma_voom_treat)
res_limma_voom_treat <- subset(res_limma_voom_treat, adj.P.Val < 0.05)
write.table(as.data.frame(rownames(res_limma_voom_treat)),
paste0("limma_voom_treat.csv",j,".csv"),
row.names = F,sep=",",col.names=FALSE)
df1=read.csv(paste0("limma_voom_treat.csv",j,".csv"),header = F)
source('putinalist.R')
putinalist(df1)
|
3f6233a3b04c067cd58487ab4acca0555cc2996c
|
d38fe23893d143f54550ea2f851ae5fec759e3de
|
/utils.R
|
61d9a8cf8193651295a21cb111445c8bfb4a9be5
|
[] |
no_license
|
danioyuan/r_utils
|
025f9753faeb32343ae0bd3e5ef4cf7ae7ba0022
|
913b9df777d7f3fda1638389a4fc52b5d11b29a8
|
refs/heads/master
| 2020-07-28T15:17:21.907006
| 2016-11-10T18:16:37
| 2016-11-10T18:16:37
| 73,408,359
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 788
|
r
|
utils.R
|
currency2Num <- function(x, na.string = "N/A") {
# Extract value and currency symbol from a currency string.
# Eg. "-CND$0.08", "$-1.89B"
if (is.na(x) || x == na.string) { return(rep(NA, 2)) }
m <- regexpr("^([+-]*)([^\\d+-]+)([\\d.+-]+)(\\D*)", x, perl=T)
if (m < 0) { return(rep(NA, 2)) }
ss <- attr(m, "capture.start")
ll <- attr(m, "capture.length")
val <- paste(substr(x, ss[1], ss[1] + ll[1] - 1),
substr(x, ss[3], ss[3] + ll[3] - 1), sep = "")
unit <- substr(x, ss[4], ss[4] + ll[4] - 1)
currency <- substr(x, ss[2], ss[2] + ll[2] - 1)
val <- as.numeric(val)
if (unit == "K") {
val <- val * 1e3
} else if (unit == "M") {
val <- val * 1e6
} else if (unit == "B") {
val <- val * 1e9
}
return(c(val, currency))
}
|
f885aa95ff4ce1de12263549c8600244e6eb28de
|
eb27c112efa6f461c722551526e80b162c7b54ea
|
/R/sp_lit_parse_names.R
|
5f8c6c2449148cd9bcb59ddd5cf2d3b159bb8415
|
[
"MIT"
] |
permissive
|
sckott/spplit
|
493df117c40e681381f4e37a2f36ecba6225be5e
|
9a663449bbc751b069876847d325e35c2808adda
|
refs/heads/master
| 2023-05-23T18:17:37.596992
| 2020-09-24T01:40:14
| 2020-09-24T01:40:14
| 48,463,958
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,235
|
r
|
sp_lit_parse_names.R
|
#' Parse scientific names
#'
#' Depends on non-CRAN package rgnparser
#'
#' @export
#' @param x An object of class `sp_lit_text` or `sp_lit_text_one`
#' @param progress (logical) print a progress bar. default: `TRUE`
#' @param ... arguments passed on to `rgnparser::gn_parse_tidy()`
#' @details make sure to install gnparser first
#' <https://gitlab.com/gogna/gnparser>
#' @return a data.frame
sp_lit_parse_names <- function(x, progress = TRUE, ...) {
UseMethod("sp_lit_parse_names")
}
#' @export
sp_lit_parse_names.default <- function(x, progress = TRUE, ...) {
no_method("sp_lit_parse_names", x)
}
#' @export
sp_lit_parse_names.sp_lit_text <- function(x, progress = TRUE, ...) {
stop("not ready yet")
# lapply_prog(x, sp_lit_parse_names, ..., progress = progress)
}
#' @export
sp_lit_parse_names.sp_lit_text_one <- function(x, progress = TRUE, ...) {
stop("not ready yet")
}
#' @export
sp_lit_parse_names.list <- function(x, ..., progress = TRUE) {
stop("not ready yet")
# lapply_prog(x, function(w) {
# if (!class(w) %in% c("sp_lit_text_one", "sp_lit_text"))
# stop("All inputs must be of class 'sp_lit_text_one'",
# call. = FALSE)
# sp_lit_parse_names(w, ...)
# }, progress = progress)
}
|
76c2b2e9b3f764c2c30231eb4d7082532172869e
|
dcfd7d7140ff5f4d52a90c148262892a4b041b79
|
/man/drcfit.Rd
|
f6ef824f86d482137afc26946a6775ca1ee9e24e
|
[] |
no_license
|
DrRoad/DRomics
|
364fa7e6a0ed3419a106e7ec3fca27b9beee80ab
|
94b9d5a0b975698044a12588058e0a910de45d29
|
refs/heads/master
| 2020-07-04T08:58:14.593775
| 2019-07-26T12:18:59
| 2019-07-26T12:18:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 7,817
|
rd
|
drcfit.Rd
|
\name{drcfit}
\alias{drcfit}
\alias{print.drcfit}
\alias{plot.drcfit}
\title{Dose response modelling for responsive items}
\description{
Fits dose reponse models to responsive items.
}
\usage{
drcfit(itemselect, sigmoid.model = c("Hill", "log-probit"),
progressbar = TRUE, saveplot2pdf = TRUE,
parallel = c("no", "snow", "multicore"), ncpus)
\method{print}{drcfit}(x, \dots)
\method{plot}{drcfit}(x, items,
plot.type = c("dose_fitted", "dose_residuals","fitted_residuals"), \dots)
}
\arguments{
\item{itemselect}{An object of class \code{"itemselect"} returned by the function \code{itemselect}.}
\item{sigmoid.model}{The chosen sigmoid model, \code{"Hill"} (default
choice) or \code{"log-probit"}.}
\item{progressbar}{If \code{TRUE} a progress bar is used to follow the fitting process.}
\item{saveplot2pdf}{If \code{TRUE} a pdf file named drcfitplot.pdf is saved containing
all the fitted dose-response curves sorted by adjusted p-values of the selection step.}
\item{parallel}{The type of parallel operation to be used, \code{"snow"} or \code{"multicore"}
(the second one not being available on Windows),
or \code{"no"} if no parallel operation.}
\item{ncpus}{Number of processes to be used in parallel operation :
typically one would fix it to the number of available CPUs.}
\item{x}{An object of class \code{"drcfit"}.}
\item{items}{Argument of the \code{plot.drcfit} function : the number of the first fits to
plot (20 items max) or the character vector
specifying the identifiers of the items to plot (20 items max).}
\item{plot.type}{the type of plot, by default \code{"dose_fitted"} for the plot of
fitted curves with the observed points added to the plot and the observed means at each dose
added as black plain circles, \code{"dose_residuals"} for the plot of the residuals as function
of the dose, and \code{fitted_residuals} for the plot of the residuals as function of
the fitted value.}
\item{\dots}{ further arguments passed to graphical or print functions.}
}
\details{
For each selected item, five dose-response models (linear, Hill, exponential,
Gauss-probit and log-Gauss-probit, see Larras et al. 2018
for their definition) were fitted by non linear regression,
using the \code{\link{nls}} function. The best one was chosen as the one giving the lowest AIC value.
Items with the best AIC value not lower than the AIC value of the null model (constant model) minus 2
were eliminated. Items with the best fit showing a global significant quadratic trend of the residuals
as a function of the dose (in rank-scale) were also eliminated (the best fit is considered as
not reliable in such cases). Each retained item is classified in a twelve class typology depending of the
chosen model and of its parameter values :
\itemize{
\item H.inc for increasing Hill curves (or lP.inc if \code{sigmoid.model = "log-probit"}),
\item H.dec for decreasing Hill curves (or lP.dec if \code{sigmoid.model = "log-probit"}),
\item L.inc for increasing linear curves,
\item L.dec for decreasing linear curves,
\item E.inc.convex for increasing convex exponential curves,
\item E.dec.concave for decreasing concave exponential curves,
\item E.inc.concave for increasing concave exponential curves,
\item E.dec.convex for decreasing convex exponential curves,
\item GP.U for U-shape Gauss-probit curves,
\item GP.bell for bell-shape Gauss-probit curves,
\item lGP.U for U-shape log-Gauss-probit curves,
\item lGP.bell for bell-shape log-Gauss-probit curves.
}
Each retained item is also classified in four classes by its global trend :
\itemize{
\item inc for increasing curves,
\item dec for decreasing curves ,
\item U for U-shape curves,
\item bell for bell-shape curves.
}
Some curves fitted by a Gauss-probit model can be classified as increasing or decreasing when the
dose value at which their extremum is reached is at zero.
}
\value{
\code{drcfit} returns an object of class \code{"drcfit"}, a list with 4 components:
\item{fitres}{ a data frame reporting the results of the fit on each selected item (one line per item) sorted in the ascending order of the adjusted p-values returned by function \code{itemselect}. The different columns correspond to the identifier of each item (\code{id}), the row number of this item in the initial data set (\code{irow}), the adjusted p-value of the selection step (\code{adjpvalue}), the name of the best fit model (\code{model}), the number of fitted parameters (\code{nbpar}), the values of the parameters \code{b}, \code{c}, \code{d}, \code{e} and \code{f}, (\code{NA} for non used parameters), the residual standard deviation (\code{SDres}), the typology of the curve (\code{typology}), the
rough trend of the curve (\code{trend}) defined with four classes (U, bell, increasing or decreasing shape), the
theoretical value at the control \code{y0}), the theoretical y range for x within the range of
tested doses (\code{yrange}),
for biphasic curves
the x value at which their extremum is reached (\code{xextrem})
and the corresponding y value (\code{yextrem}).
}
\item{omicdata}{ The corresponding object of class \code{"microarraydata"} given in input
(component of itemselect).}
\item{n.failure}{ The number of previously selected items on which the workflow failed to
fit an acceptable model.}
\item{AIC.val}{ a data frame reporting AIC values for each selected item (one line per item) and each fitted model (one colum per model with the AIC value fixed at \code{Inf} when the fit failed).}
}
\seealso{
See \code{\link{nls}} for details about the non linear regression function.
}
\references{
Larras F, Billoir E, Baillard V, Siberchicot A, Scholz S, Wubet T, Tarkka M,
Schmitt-Jansen M and Delignette-Muller ML (2018). DRomics: a turnkey tool to support the use of the dose-response framework for omics data in ecological risk assessment. Environmental science & technology.\href{https://doi.org/10.1021/acs.est.8b04752}{https://doi.org/10.1021/acs.est.8b04752}
}
\author{
Marie-Laure Delignette-Muller
}
\examples{
# (1) a toy example (a very small subsample of a microarray data set)
#
datatxt <- system.file("extdata", "transcripto_very_small_sample.txt", package="DRomics")
# to test the package on a small (for a quick calculation) but not very small data set
# use the following commented line
# datatxt <- system.file("extdata", "transcripto_sample.txt", package="DRomics")
(o <- microarraydata(datatxt, check = TRUE, norm.method = "cyclicloess"))
(s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05))
(f <- drcfit(s_quad, progressbar = TRUE))
# Default plot
plot(f)
# Plot of residuals as function of the dose
plot(f, plot.type = "dose_residuals")
\donttest{
# plot of residuals as function of the fitted value
plot(f, plot.type = "fitted_residuals")
}
# (2) an example on a microarray data set (a subsample of a greater data set)
#
\donttest{
datatxt <- system.file("extdata", "transcripto_sample.txt", package="DRomics")
(o <- microarraydata(datatxt, check = TRUE, norm.method = "cyclicloess"))
(s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05))
(f <- drcfit(s_quad, progressbar = TRUE))
# Default plot
plot(f)
# Plot of the first 12 most responsive items
plot(f, items = 12)
# Plot of the chosen items in the chosen order
plot(f, items = c("301.2", "363.1", "383.1"))
}
# (3) Comparison of parallel and non paralell implementations on a
# larger selection of items
#
\donttest{
s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05)
system.time(f1 <- drcfit(s_quad, progressbar = TRUE))
system.time(f2 <- drcfit(s_quad, progressbar = FALSE, parallel = "snow", ncpus = 2))
}
}
|
33ff0587622e9a89506501b3f4eaef8784d9565a
|
6058ae780cde6ec6117a3fc86a4c1c26b578650e
|
/R/seq_clatworthy_williams.R
|
265d8c173fc237236a1329250642faa69e6653e4
|
[] |
no_license
|
mjg211/xover
|
88243eb2f99a76502057f67924725fda1796dd39
|
9e8bb48dcc735d78aa9a8d14f236a8ba13609866
|
refs/heads/master
| 2020-03-26T14:55:03.702584
| 2019-10-15T10:40:29
| 2019-10-15T10:40:29
| 145,011,976
| 1
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 462,981
|
r
|
seq_clatworthy_williams.R
|
#' Clatworthy-Williams cross-over design specification
#'
#' Specifies cross-over designs based on combining Clatworthy (1973) designs
#' with Williams (1949) designs.
#'
#' \code{seq_clatworthy_williams()} supports the specification of designs based
#' on combining designs from Clatworthy (1973) with designs from Williams
#' (1949). Designs for a large array of values of the number of
#' treatments and periods are available (accessible by setting
#' \code{williams_D}, \code{selection} and \code{type} carefully), for any
#' chosen treatment labels (see \code{labels}). In addition, the designs can be
#' returned in \code{\link[base]{matrix}} or \code{\link[tibble]{tibble}} form
#' (see \code{as_matrix}).
#'
#' Precisely, \code{type} must be set as one of \code{"R"}, \code{"S"}, and
#' \code{"SR"}. Then, \code{williams_D} must be set to an integer between three
#' and nine inclusive. With this, \code{selection} can take one of a particular
#' set of \code{\link[base]{numeric}} or \code{\link[base]{character}} values.
#' The best way to ascertain which values are allowed is to use the utility
#' function \code{\link[xover]{summary_seq_clatworthy_williams}}. Ultimately,
#' the \ifelse{html}{\out{(<i>k</i>,<i>j</i>)}}{\eqn{(k,j)}}th element of the
#' cross-over design matrix corresponds to the treatment a subject on the
#' \ifelse{html}{\out{<i>k</i>}}{\eqn{k}}th sequence would receive in the
#' \ifelse{html}{\out{<i>j</i>}}{\eqn{j}}th period.
#'
#' @param D The number of treatments in the utilised Williams (1949) design.
#' Must be a single \code{\link[base]{numeric}} integer between three and nine
#' inclusive. Defaults to \code{3}.
#' @param type A \code{\link[base]{character}} string indicating which type of
#' sequences to return. Must be one of \code{"R"}, \code{"S"}, and \code{"SR"}.
#' Defaults to \code{"R"}.
#' @param selection A \code{\link[base]{numeric}} integer or
#' \code{\link[base]{character}} string indicating which design to return, for
#' the chosen values of \code{williams_D} and \code{type}. See \strong{Details}
#' for information on how to ascertain supported values. Defaults to \code{1}.
#' @param labels A \code{\link[base]{vector}} of labels for the treatments.
#' If specified, should have \code{\link[base]{length}} corresponding to the
#' number of treatments in the chosen design, containing unique elements. If
#' missing, will internally default to \code{0:(D - 1)}, where \code{D} is the
#' number of treatments.
#' @param as_matrix A \code{\link[base]{logical}} variable indicating whether
#' the design should be returned as a \code{\link[base]{matrix}}, or a
#' \code{\link[tibble]{tibble}}. Defaults to \code{T}.
#' @param summary A \code{\link[base]{logical}} variable indicating whether a
#' summary of the function's progress should be printed to the console. Defaults
#' to \code{T}.
#' @return Either a \code{\link[base]{matrix}} if \code{as_matrix = T} (with
#' rows corresponding to sequences and columns to periods), or a
#' \code{\link[tibble]{tibble}} if \code{as_matrix = F} (with rows corresponding
#' to a particular period on a particular sequence). In either case, the
#' returned object will have class \code{xover_seq}.
#' @examples
#' # A six treatment design
#' clatworthy_williams <- seq_clatworthy_williams()
#' # Using different labels
#' clatworthy_williams_ABCDEF <- seq_clatworthy(labels = LETTERS[1:6])
#' # Returning in tibble form
#' clatworthy_williams_tibble <- seq_clatworthy(as_matrix = F)
#' @references Clatworthy WH, Cameron JM, Speckman JA (1973) Tables of
#' two-associate-class partially balanced designs. \emph{US Government Printing
#' Office}.
#' @references Patterson HD, Lucas HL (1962) Change-over designs. \emph{North
#' Carolina Agricultural Experiment Station}. Tech Bull 147.
#' @references Williams EJ (1949) Experimental designs balanced for the
#' estimation of residual effects of treatments. \emph{Aust J Sci Res Ser A}
#' \strong{2:}149-168.
#' @author Based on data from the \code{\link[Crossover]{Crossover}} package by
#' Kornelius Rohmeyer.
#' @seealso \code{\link[xover]{summary_seq_clatworthy_williams}}.
#' @export
seq_pbib_clatworthy_williams <- function(williams_D = 3, type = "R",
selection = 42, labels,
as_matrix = T, summary = T) {
##### Error checking #########################################################
check_integer_range(williams_D, "williams_D", c(2, 10))
check_type(type)
if (all(williams_D == 3, type == "R")) {
if (!(selection %in%
c(42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 54, 56, 58, 59, 60, 61,
62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 78, 79, 80, 81,
82, 84, 85, 86, 89, 91, 93))) {
stop("For williams_D = 3 and type = \"R\" selection must be one of 42-48",
", 50-52, 54, 56, 58-63, 65-73, 75, 78-82, 84-86, 89, 91, or 93")
}
} else if (all(williams_D == 3, type == "S")) {
stop("No designs are available for williams_D = 3 and type = \"S\"")
} else if (all(williams_D == 3, type == "SR")) {
if (!(selection %in% c(18, 19, 23, 25, 26))) {
stop("For williams_D = 3 and type = \"SR\" selection must be one of 18,",
" 19, 23, 25, or 26")
}
} else if (all(williams_D == 4, type == "R")) {
if (!(selection %in% c(94, 95, 96, 97, 98, 101, 103, 104, 106, 109, 111,
112, 114, 115, 117, 118, 119))) {
stop("For williams_D = 4 and type = \"R\" selection must be one of 94-98",
", 101, 103, 104, 106, 109, 111, 112, 114, 115, or 117-119")
}
} else if (all(williams_D == 4, type == "S")) {
if (!(selection %in% c(1, 3, 6, 7, 9, 11))) {
stop("For williams_D = 4 and type = \"S\" selection must be one of 1, 3,",
" 6, 7, 9, or 11")
}
} else if (all(williams_D == 4, type == "SR")) {
if (!(selection %in% c(35, 36, 37, 41, 42, 44, 46))) {
stop("For williams_D = 4 and type = \"SR\" selection must be one of ",
"35-37, 41, 42, 44, or 46")
}
} else if (all(williams_D == 5, type == "R")) {
if (!(any(selection %in%
c(133, 134, 137, 139, 140, 143, 144, 145, 150, 153),
selection == "153a"))) {
stop("For williams_D = 5 and type = \"R\" selection must be one of 133,",
" 134, 137, 139, 140, 143-145, 150, 153, or 153a")
}
} else if (all(williams_D == 5, type == "S")) {
stop("No designs are available for williams_D = 5 and type = \"S\"")
} else if (all(williams_D == 5, type == "SR")) {
if (!(selection %in% c(52, 53, 54, 55, 56, 60))) {
stop("For williams_D = 5 and type = \"SR\" selection must be one of ",
"52-56, or 60")
}
} else if (all(williams_D == 6, type == "R")) {
if (!(selection %in% c(164, 165, 169, 170, 171))) {
stop("For williams_D = 6 and type = \"R\" selection must be one of 164,",
" 165, or 169-171")
}
} else if (all(williams_D == 6, type == "S")) {
if (!(selection %in%
c(18, 21, 24, 26, 27, 28, 29, 31, 32, 34, 35, 37, 38))) {
stop("For williams_D = 6 and type = \"S\" selection must be one of 18, ",
"21, 24, 26-29, 31, 32, 34, 35, 37, or 38")
}
} else if (all(williams_D == 6, type == "SR")) {
if (!(any(selection %in% c(65, 66, 67, 68, 72, 73, 75),
selection == "36a"))) {
stop("For williams_D = 6 and type = \"SR\" selection must be one of 36a,",
" 65-68, 72, 73, or 75")
}
} else if (all(williams_D == 7, type == "R")) {
if (!(selection %in% c(172, 175, 176, 177))) {
stop("For williams_D = 7 and type = \"R\" selection must be one of 172, ",
"or 175-177")
}
} else if (all(williams_D == 7, type == "S")) {
stop("No designs are available for williams_D = 7 and type = \"S\"")
} else if (all(williams_D == 7, type == "SR")) {
if (!(selection %in% c(80, 81, 82))) {
stop("For williams_D = 7 and type = \"SR\" selection must be one of ",
"80-82")
}
} else if (all(williams_D == 8, type == "R")) {
if (!(selection == 186)) {
stop("For williams_D = 8 and type = \"R\" selection must be 186")
}
} else if (all(williams_D == 8, type == "S")) {
if (!(selection %in% c(51, 52, 53, 58, 59, 61, 63, 65, 66, 67))) {
stop("For williams_D = 8 and type = \"S\" selection must be one of ",
"51-53, 58, 59, 61, 63, or 65-67")
}
} else if (all(williams_D == 8, type == "SR")) {
if (!(selection %in% c(90, 91, 92, 93, 94))) {
stop("For williams_D = 8 and type = \"SR\" selection must be one of ",
"90-94")
}
} else if (all(williams_D == 9, type == "R")) {
if (!(selection == 193)) {
stop("For williams_D = 9 and type = \"R\" selection must be 193")
}
} else if (all(williams_D == 9, type == "S")) {
if (!(selection %in% c(82, 85, 86, 88, 91))) {
stop("For williams_D = 9 and type = \"S\" selection must be one of 82, ",
"85, 86, 88, or 91")
}
} else if (all(williams_D == 9, type == "SR")) {
if (!(selection %in% c(99, 100))) {
stop("For williams_D = 9 and type = \"SR\" selection must be one of 99 ",
"or 100")
}
}
check_logical(as_matrix, "as_matrix")
##### Main computations ######################################################
if (all(williams_D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 3, 5, 4, 4, 3, 5, 5, 4, 3),
72, 3, byrow = T)
} else if (all(williams_D == 3, selection == 44, type == "R")) {
sequences <- matrix(c(1, 4, 2, 4, 2, 1, 2, 1, 4, 2, 4, 1, 1, 2, 4, 4, 1, 2,
3, 6, 5, 6, 5, 3, 5, 3, 6, 5, 6, 3, 3, 5, 6, 6, 3, 5,
4, 1, 3, 1, 3, 4, 3, 4, 1, 3, 1, 4, 4, 3, 1, 1, 4, 3,
2, 5, 6, 5, 6, 2, 6, 2, 5, 6, 5, 2, 2, 6, 5, 5, 2, 6,
1, 5, 4, 5, 4, 1, 4, 1, 5, 4, 5, 1, 1, 4, 5, 5, 1, 4,
6, 3, 2, 3, 2, 6, 2, 6, 3, 2, 3, 6, 6, 2, 3, 3, 6, 2,
4, 6, 1, 6, 1, 4, 1, 4, 6, 1, 6, 4, 4, 1, 6, 6, 4, 1,
5, 2, 3, 2, 3, 5, 3, 5, 2, 3, 2, 5, 5, 3, 2, 2, 5, 3,
2, 1, 5, 1, 5, 2, 5, 2, 1, 5, 1, 2, 2, 5, 1, 1, 2, 5,
3, 4, 6, 4, 6, 3, 6, 3, 4, 6, 4, 3, 3, 6, 4, 4, 3, 6,
5, 2, 4, 2, 4, 5, 4, 5, 2, 4, 2, 5, 5, 4, 2, 2, 5, 4,
6, 3, 1, 3, 1, 6, 1, 6, 3, 1, 3, 6, 6, 1, 3, 3, 6, 1),
72, 3, byrow = T)
} else if (all(williams_D == 3, selection == 45, type == "R")) {
sequences <- matrix(c(1, 3, 5, 3, 5, 1, 5, 1, 3, 5, 3, 1, 1, 5, 3, 3, 1, 5,
1, 2, 4, 2, 4, 1, 4, 1, 2, 4, 2, 1, 1, 4, 2, 2, 1, 4,
2, 3, 6, 3, 6, 2, 6, 2, 3, 6, 3, 2, 2, 6, 3, 3, 2, 6,
4, 5, 6, 5, 6, 4, 6, 4, 5, 6, 5, 4, 4, 6, 5, 5, 4, 6,
1, 3, 5, 3, 5, 1, 5, 1, 3, 5, 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5, 3, 6, 6, 5, 3,
2, 1, 4, 1, 4, 2, 4, 2, 1, 4, 1, 2, 2, 4, 1, 1, 2, 4),
108, 3, byrow = T)
} else if (all(williams_D == 3, selection == 54, type == "R")) {
sequences <- matrix(c(1, 2, 4, 2, 4, 1, 4, 1, 2, 4, 2, 1, 1, 4, 2, 2, 1, 4,
2, 3, 5, 3, 5, 2, 5, 2, 3, 5, 3, 2, 2, 5, 3, 3, 2, 5,
3, 4, 6, 4, 6, 3, 6, 3, 4, 6, 4, 3, 3, 6, 4, 4, 3, 6,
4, 5, 7, 5, 7, 4, 7, 4, 5, 7, 5, 4, 4, 7, 5, 5, 4, 7,
5, 6, 8, 6, 8, 5, 8, 5, 6, 8, 6, 5, 5, 8, 6, 6, 5, 8,
6, 7, 1, 7, 1, 6, 1, 6, 7, 1, 7, 6, 6, 1, 7, 7, 6, 1,
7, 8, 2, 8, 2, 7, 2, 7, 8, 2, 8, 7, 7, 2, 8, 8, 7, 2,
8, 1, 3, 1, 3, 8, 3, 8, 1, 3, 1, 8, 8, 3, 1, 1, 8, 3),
48, 3, byrow = T)
} else if (all(williams_D == 3, selection == 56, type == "R")) {
sequences <- matrix(c(1, 5, 2, 5, 2, 1, 2, 1, 5, 2, 5, 1, 1, 2, 5, 5, 1, 2,
2, 6, 3, 6, 3, 2, 3, 2, 6, 3, 6, 2, 2, 3, 6, 6, 2, 3,
3, 7, 4, 7, 4, 3, 4, 3, 7, 4, 7, 3, 3, 4, 7, 7, 3, 4,
4, 8, 1, 8, 1, 4, 1, 4, 8, 1, 8, 4, 4, 1, 8, 8, 4, 1,
5, 4, 8, 4, 8, 5, 8, 5, 4, 8, 4, 5, 5, 8, 4, 4, 5, 8,
6, 1, 5, 1, 5, 6, 5, 6, 1, 5, 1, 6, 6, 5, 1, 1, 6, 5,
7, 2, 6, 2, 6, 7, 6, 7, 2, 6, 2, 7, 7, 6, 2, 2, 7, 6,
8, 3, 7, 3, 7, 8, 7, 8, 3, 7, 3, 8, 8, 7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, 3, 10, 8, 6, 4, 9, 4, 9, 6, 9,
6, 4, 9, 4, 6, 6, 9, 4, 4, 6, 9, 7, 5, 10, 5, 10, 7,
10, 7, 5, 10, 5, 7, 7, 10, 5, 5, 7, 10), 120, 3,
byrow = T)
} else if (all(williams_D == 3, selection == 70, type == "R")) {
sequences <- matrix(c(1, 3, 4, 3, 4, 1, 4, 1, 3, 4, 3, 1, 1, 4, 3, 3, 1, 4,
2, 9, 7, 9, 7, 2, 7, 2, 9, 7, 9, 2, 2, 7, 9, 9, 2, 7,
3, 5, 12, 5, 12, 3, 12, 3, 5, 12, 5, 3, 3, 12, 5, 5,
3, 12, 9, 6, 10, 6, 10, 9, 10, 9, 6, 10, 6, 9, 9, 10,
6, 6, 9, 10, 6, 8, 1, 8, 1, 6, 1, 6, 8, 1, 8, 6, 6, 1,
8, 8, 6, 1, 11, 4, 2, 4, 2, 11, 2, 11, 4, 2, 4, 11,
11, 2, 4, 4, 11, 2, 8, 7, 3, 7, 3, 8, 3, 8, 7, 3, 7,
8, 8, 3, 7, 7, 8, 3, 4, 12, 9, 12, 9, 4, 9, 4, 12, 9,
12, 4, 4, 9, 12, 12, 4, 9, 7, 10, 5, 10, 5, 7, 5, 7,
10, 5, 10, 7, 7, 5, 10, 10, 7, 5, 10, 1, 11, 1, 11,
10, 11, 10, 1, 11, 1, 10, 10, 11, 1, 1, 10, 11, 2, 5,
6, 5, 6, 2, 6, 2, 5, 6, 5, 2, 2, 6, 5, 5, 2, 6, 3, 6,
11, 6, 11, 3, 11, 3, 6, 11, 6, 3, 3, 11, 6, 6, 3, 11,
9, 11, 8, 11, 8, 9, 8, 9, 11, 8, 11, 9, 9, 8, 11, 11,
9, 8, 5, 8, 4, 8, 4, 5, 4, 5, 8, 4, 8, 5, 5, 4, 8, 8,
5, 4, 6, 4, 7, 4, 7, 6, 7, 6, 4, 7, 4, 6, 6, 7, 4, 4,
6, 7, 11, 7, 12, 7, 12, 11, 12, 11, 7, 12, 7, 11, 11,
12, 7, 7, 11, 12, 8, 12, 10, 12, 10, 8, 10, 8, 12, 10,
12, 8, 8, 10, 12, 12, 8, 10, 12, 1, 2, 1, 2, 12, 2,
12, 1, 2, 1, 12, 12, 2, 1, 1, 12, 2, 10, 2, 3, 2, 3,
10, 3, 10, 2, 3, 2, 10, 10, 3, 2, 2, 10, 3, 1, 9, 5,
9, 5, 1, 5, 1, 9, 5, 9, 1, 1, 5, 9, 9, 1, 5), 120, 3,
byrow = T)
} else if (all(williams_D == 3, selection == 71, type == "R")) {
sequences <- matrix(c(1, 7, 2, 7, 2, 1, 2, 1, 7, 2, 7, 1, 1, 2, 7, 7, 1, 2,
3, 8, 2, 8, 2, 3, 2, 3, 8, 2, 8, 3, 3, 2, 8, 8, 3, 2,
7, 9, 3, 9, 3, 7, 3, 7, 9, 3, 9, 7, 7, 3, 9, 9, 7, 3,
8, 1, 7, 1, 7, 8, 7, 8, 1, 7, 1, 8, 8, 7, 1, 1, 8, 7,
9, 2, 8, 2, 8, 9, 8, 9, 2, 8, 2, 9, 9, 8, 2, 2, 9, 8,
9, 3, 1, 3, 1, 9, 1, 9, 3, 1, 3, 9, 9, 1, 3, 3, 9, 1,
1, 5, 6, 5, 6, 1, 6, 1, 5, 6, 5, 1, 1, 6, 5, 5, 1, 6,
2, 6, 4, 6, 4, 2, 4, 2, 6, 4, 6, 2, 2, 4, 6, 6, 2, 4,
3, 4, 5, 4, 5, 3, 5, 3, 4, 5, 4, 3, 3, 5, 4, 4, 3, 5,
7, 11, 4, 11, 4, 7, 4, 7, 11, 4, 11, 7, 7, 4, 11, 11,
7, 4, 8, 10, 5, 10, 5, 8, 5, 8, 10, 5, 10, 8, 8, 5,
10, 10, 8, 5, 10, 4, 9, 4, 9, 10, 9, 10, 4, 9, 4, 10,
10, 9, 4, 4, 10, 9, 11, 1, 12, 1, 12, 11, 12, 11, 1,
12, 1, 11, 11, 12, 1, 1, 11, 12, 12, 2, 10, 2, 10, 12,
10, 12, 2, 10, 2, 12, 12, 10, 2, 2, 12, 10, 11, 3, 10,
3, 10, 11, 10, 11, 3, 10, 3, 11, 11, 10, 3, 3, 11, 10,
5, 7, 12, 7, 12, 5, 12, 5, 7, 12, 7, 5, 5, 12, 7, 7,
5, 12, 6, 8, 11, 8, 11, 6, 11, 6, 8, 11, 8, 6, 6, 11,
8, 8, 6, 11, 5, 11, 9, 11, 9, 5, 9, 5, 11, 9, 11, 5,
5, 9, 11, 11, 5, 9, 4, 10, 1, 10, 1, 4, 1, 4, 10, 1,
10, 4, 4, 1, 10, 10, 4, 1, 2, 5, 11, 5, 11, 2, 11, 2,
5, 11, 5, 2, 2, 11, 5, 5, 2, 11, 6, 12, 3, 12, 3, 6,
3, 6, 12, 3, 12, 6, 6, 3, 12, 12, 6, 3, 10, 6, 7, 6,
7, 10, 7, 10, 6, 7, 6, 10, 10, 7, 6, 6, 10, 7, 4, 12,
8, 12, 8, 4, 8, 4, 12, 8, 12, 4, 4, 8, 12, 12, 4, 8,
12, 9, 6, 9, 6, 12, 6, 12, 9, 6, 9, 12, 12, 6, 9, 9,
12, 6), 144, 3, byrow = T)
} else if (all(williams_D == 3, selection == 72, type == "R")) {
sequences <- matrix(c(1, 4, 7, 4, 7, 1, 7, 1, 4, 7, 4, 1, 1, 7, 4, 4, 1, 7,
2, 5, 8, 5, 8, 2, 8, 2, 5, 8, 5, 2, 2, 8, 5, 5, 2, 8,
3, 6, 9, 6, 9, 3, 9, 3, 6, 9, 6, 3, 3, 9, 6, 6, 3, 9,
10, 11, 12, 11, 12, 10, 12, 10, 11, 12, 11, 10, 10,
12, 11, 11, 10, 12, 1, 6, 8, 6, 8, 1, 8, 1, 6, 8, 6,
1, 1, 8, 6, 6, 1, 8, 2, 3, 10, 3, 10, 2, 10, 2, 3, 10,
3, 2, 2, 10, 3, 3, 2, 10, 7, 9, 11, 9, 11, 7, 11, 7,
9, 11, 9, 7, 7, 11, 9, 9, 7, 11, 4, 5, 12, 5, 12, 4,
12, 4, 5, 12, 5, 4, 4, 12, 5,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6, 6, 4, 11, 8, 9, 10, 9, 10, 8, 10, 8, 9, 10, 9,
8, 8, 10, 9, 9, 8, 10), 168, 3, byrow = T)
} else if (all(williams_D == 3, selection == 73, type == "R")) {
sequences <- matrix(c(1, 7, 5, 7, 5, 1, 5, 1, 7, 5, 7, 1, 1, 5, 7, 7, 1, 5,
1, 7, 6, 7, 6, 1, 6, 1, 7, 6, 7, 1, 1, 6, 7, 7, 1, 6,
1, 7, 11, 7, 11, 1, 11, 1, 7, 11, 7, 1, 1, 11, 7, 7,
1, 11, 1, 7, 12, 7, 12, 1, 12, 1, 7, 12, 7, 1, 1, 12,
7, 7, 1, 12, 1, 2, 8, 2, 8, 1, 8, 1, 2, 8, 2, 1, 1, 8,
2, 2, 1, 8, 1, 3, 9, 3, 9, 1, 9, 1, 3, 9, 3, 1, 1, 9,
3, 3, 1, 9, 1, 4, 10, 4, 10, 1, 10, 1, 4, 10, 4, 1, 1,
10, 4, 4, 1, 10, 2, 3, 8, 3, 8, 2, 8, 2, 3, 8, 3, 2,
2, 8, 3, 3, 2, 8, 2, 4, 10, 4, 10, 2, 10, 2, 4, 10, 4,
2, 2, 10, 4, 4, 2, 10, 2, 5, 11, 5, 11, 2, 11, 2, 5,
11, 5, 2, 2, 11, 5, 5, 2, 11, 2, 6, 12, 6, 12, 2, 12,
2, 6, 12, 6, 2, 2, 12, 6, 6, 2, 12, 2, 7, 8, 7, 8, 2,
8, 2, 7, 8, 7, 2, 2, 8, 7, 7, 2, 8, 2, 8, 9, 8, 9, 2,
9, 2, 8, 9, 8, 2, 2, 9, 8, 8, 2, 9, 5, 8, 11, 8, 11,
5, 11, 5, 8, 11, 8, 5, 5, 11, 8, 8, 5, 11, 3, 4, 9, 4,
9, 3, 9, 3, 4, 9, 4, 3, 3, 9, 4, 4, 3, 9, 3, 5, 11, 5,
11, 3, 11, 3, 5, 11, 5, 3, 3, 11, 5, 5, 3, 11, 3, 6,
12, 6, 12, 3, 12, 3, 6, 12, 6, 3, 3, 12, 6, 6, 3, 12,
3, 7, 9, 7, 9, 3, 9, 3, 7, 9, 7, 3, 3, 9, 7, 7, 3, 9,
3, 9, 10, 9, 10, 3, 10, 3, 9, 10, 9, 3, 3, 10, 9, 9,
3, 10, 5, 9, 11, 9, 11, 5, 11, 5, 9, 11, 9, 5, 5, 11,
9, 9, 5, 11, 5, 10, 12, 10, 12, 5, 12, 5, 10, 12, 10,
5, 5, 12, 10, 10, 5, 12, 4, 5, 6, 5, 6, 4, 6, 4, 5, 6,
5, 4, 4, 6, 5, 5, 4, 6, 4, 7, 10, 7, 10, 4, 10, 4, 7,
10, 7, 4, 4, 10, 7, 7, 4, 10, 4, 8, 10, 8, 10, 4, 10,
4, 8, 10, 8, 4, 4, 10, 8, 8, 4, 10, 4, 11, 12, 11, 12,
4, 12, 4, 11, 12, 11, 4, 4, 12, 11, 11, 4, 12, 6, 8,
12, 8, 12, 6, 12, 6, 8, 12, 8, 6, 6, 12, 8, 8, 6, 12,
6, 9, 12, 9, 12, 6, 12, 6, 9, 12, 9, 6, 6, 12, 9, 9,
6, 12, 6, 10, 11, 10, 11, 6, 11, 6, 10, 11, 10, 6, 6,
11, 10, 10, 6, 11), 168, 3, byrow = T)
} else if (all(williams_D == 3, selection == 75, type == "R")) {
sequences <- matrix(c(1, 2, 4, 2, 4, 1, 4, 1, 2, 4, 2, 1, 1, 4, 2, 2, 1, 4,
2, 3, 5, 3, 5, 2, 5, 2, 3, 5, 3, 2, 2, 5, 3, 3, 2, 5,
3, 4, 6, 4, 6, 3, 6, 3, 4, 6, 4, 3, 3, 6, 4, 4, 3, 6,
4, 5, 7, 5, 7, 4, 7, 4, 5, 7, 5, 4, 4, 7, 5, 5, 4, 7,
5, 6, 8, 6, 8, 5, 8, 5, 6, 8, 6, 5, 5, 8, 6, 6, 5, 8,
6, 7, 9, 7, 9, 6, 9, 6, 7, 9, 7, 6, 6, 9, 7, 7, 6, 9,
7, 8, 10, 8, 10, 7, 10, 7, 8, 10, 8, 7, 7, 10, 8, 8,
7, 10, 8, 9, 11, 9, 11, 8, 11, 8, 9, 11, 9, 8, 8, 11,
9, 9, 8, 11, 9, 10, 12, 10, 12, 9, 12, 9, 10, 12, 10,
9, 9, 12, 10, 10, 9, 12, 10, 11, 1, 11, 1, 10, 1, 10,
11, 1, 11, 10, 10, 1, 11, 11, 10, 1, 11, 12, 2, 12, 2,
11, 2, 11, 12, 2, 12, 11, 11, 2, 12, 12, 11, 2, 12, 1,
3, 1, 3, 12, 3, 12, 1, 3, 1, 12, 12, 3, 1, 1, 12, 3,
1, 2, 7, 2, 7, 1, 7, 1, 2, 7, 2, 1, 1, 7, 2, 2, 1, 7,
2, 3, 8, 3, 8, 2, 8, 2, 3, 8, 3, 2, 2, 8, 3, 3, 2, 8,
3, 4, 9, 4, 9, 3, 9, 3, 4, 9, 4, 3, 3, 9, 4, 4, 3, 9,
4, 5, 10, 5, 10, 4, 10, 4, 5, 10, 5, 4, 4, 10, 5, 5,
4, 10, 5, 6, 11, 6, 11, 5, 11, 5, 6, 11, 6, 5, 5, 11,
6, 6, 5, 11, 6, 7, 12, 7, 12, 6, 12, 6, 7, 12, 7, 6,
6, 12, 7, 7, 6, 12, 7, 8, 1, 8, 1, 7, 1, 7, 8, 1, 8,
7, 7, 1, 8, 8, 7, 1, 8, 9, 2, 9, 2, 8, 2, 8, 9, 2, 9,
8, 8, 2, 9, 9, 8, 2, 9, 10, 3, 10, 3, 9, 3, 9, 10, 3,
10, 9, 9, 3, 10, 10, 9, 3, 10, 11, 4, 11, 4, 10, 4,
10, 11, 4, 11, 10, 10, 4, 11, 11, 10, 4, 11, 12, 5,
12, 5, 11, 5, 11, 12, 5, 12, 11, 11, 5, 12, 12, 11, 5,
12, 1, 6, 1, 6, 12, 6, 12, 1, 6, 1, 12, 12, 6, 1, 1,
12, 6, 1, 3, 6, 3, 6, 1, 6, 1, 3, 6, 3, 1, 1, 6, 3, 3,
1, 6, 2, 4, 7, 4, 7, 2, 7, 2, 4, 7, 4, 2, 2, 7, 4, 4,
2, 7, 3, 5, 8, 5, 8, 3, 8, 3, 5, 8, 5, 3, 3, 8, 5, 5,
3, 8, 4, 6, 9, 6, 9, 4, 9, 4, 6, 9, 6, 4, 4, 9, 6, 6,
4, 9, 5, 7, 10, 7, 10, 5, 10, 5, 7, 10, 7, 5, 5, 10,
7, 7, 5, 10, 6, 8, 11, 8, 11, 6, 11, 6, 8, 11, 8, 6,
6, 11, 8, 8, 6, 11, 7, 9, 12, 9, 12, 7, 12, 7, 9, 12,
9, 7, 7, 12, 9, 9, 7, 12, 8, 10, 1, 10, 1, 8, 1, 8,
10, 1, 10, 8, 8, 1, 10, 10, 8, 1, 9, 11, 2, 11, 2, 9,
2, 9, 11, 2, 11, 9, 9, 2, 11, 11, 9, 2, 10, 12, 3, 12,
3, 10, 3, 10, 12, 3, 12, 10, 10, 3, 12, 12, 10, 3, 11,
1, 4, 1, 4, 11, 4, 11, 1, 4, 1, 11, 11, 4, 1, 1, 11,
4, 12, 2, 5, 2, 5, 12, 5, 12, 2, 5, 2, 12, 12, 5, 2,
2, 12, 5), 216, 3, byrow = T)
} else if (all(williams_D == 3, selection == 78, type == "R")) {
sequences <- matrix(c(1, 2, 4, 2, 4, 1, 4, 1, 2, 4, 2, 1, 1, 4, 2, 2, 1, 4,
2, 3, 5, 3, 5, 2, 5, 2, 3, 5, 3, 2, 2, 5, 3, 3, 2, 5,
3, 4, 6, 4, 6, 3, 6, 3, 4, 6, 4, 3, 3, 6, 4, 4, 3, 6,
4, 5, 7, 5, 7, 4, 7, 4, 5, 7, 5, 4, 4, 7, 5, 5, 4, 7,
5, 6, 8, 6, 8, 5, 8, 5, 6, 8, 6, 5, 5, 8, 6, 6, 5, 8,
6, 7, 9, 7, 9, 6, 9, 6, 7, 9, 7, 6, 6, 9, 7, 7, 6, 9,
7, 8, 10, 8, 10, 7, 10, 7, 8, 10, 8, 7, 7, 10, 8, 8,
7, 10, 8, 9, 11, 9, 11, 8, 11, 8, 9, 11, 9, 8, 8, 11,
9, 9, 8, 11, 9, 10, 12, 10, 12, 9, 12, 9, 10, 12, 10,
9, 9, 12, 10, 10, 9, 12, 10, 11, 1, 11, 1, 10, 1, 10,
11, 1, 11, 10, 10, 1, 11, 11, 10, 1, 11, 12, 2, 12, 2,
11, 2, 11, 12, 2, 12, 11, 11, 2, 12, 12, 11, 2, 12, 1,
3, 1, 3, 12, 3, 12, 1, 3, 1, 12, 12, 3, 1, 1, 12, 3,
1, 5, 9, 5, 9, 1, 9, 1, 5, 9, 5, 1, 1, 9, 5, 5, 1, 9,
2, 6, 10, 6, 10, 2, 10, 2, 6, 10, 6, 2, 2, 10, 6, 6,
2, 10, 3, 7, 11, 7, 11, 3, 11, 3, 7, 11, 7, 3, 3, 11,
7, 7, 3, 11, 4, 8, 12, 8, 12, 4, 12, 4, 8, 12, 8, 4,
4, 12, 8, 8, 4, 12, 1, 2, 7, 2, 7, 1, 7, 1, 2, 7, 2,
1, 1, 7, 2, 2, 1, 7, 2, 3, 8, 3, 8, 2, 8, 2, 3, 8, 3,
2, 2, 8, 3, 3, 2, 8, 3, 4, 9, 4, 9, 3, 9, 3, 4, 9, 4,
3, 3, 9, 4, 4, 3, 9, 4, 5, 10, 5, 10, 4, 10, 4, 5, 10,
5, 4, 4, 10, 5, 5, 4, 10, 5, 6, 11, 6, 11, 5, 11, 5,
6, 11, 6, 5, 5, 11, 6, 6, 5, 11, 6, 7, 12, 7, 12, 6,
12, 6, 7, 12, 7, 6, 6, 12, 7, 7, 6, 12, 7, 8, 1, 8, 1,
7, 1, 7, 8, 1, 8, 7, 7, 1, 8, 8, 7, 1, 8, 9, 2, 9, 2,
8, 2, 8, 9, 2, 9, 8, 8, 2, 9, 9, 8, 2, 9, 10, 3, 10,
3, 9, 3, 9, 10, 3, 10, 9, 9, 3, 10, 10, 9, 3, 10, 11,
4, 11, 4, 10, 4, 10, 11, 4, 11, 10, 10, 4, 11, 11, 10,
4, 11, 12, 5, 12, 5, 11, 5, 11, 12, 5, 12, 11, 11, 5,
12, 12, 11, 5, 12, 1, 6, 1, 6, 12, 6, 12, 1, 6, 1, 12,
12, 6, 1, 1, 12, 6, 1, 3, 6, 3, 6, 1, 6, 1, 3, 6, 3,
1, 1, 6, 3, 3, 1, 6, 2, 4, 7, 4, 7, 2, 7, 2, 4, 7, 4,
2, 2, 7, 4, 4, 2, 7, 3, 5, 8, 5, 8, 3, 8, 3, 5, 8, 5,
3, 3, 8, 5, 5, 3, 8, 4, 6, 9, 6, 9, 4, 9, 4, 6, 9, 6,
4, 4, 9, 6, 6, 4, 9, 5, 7, 10, 7, 10, 5, 10, 5, 7, 10,
7, 5, 5, 10, 7, 7, 5, 10, 6, 8, 11, 8, 11, 6, 11, 6,
8, 11, 8, 6, 6, 11, 8, 8, 6, 11, 7, 9, 12, 9, 12, 7,
12, 7, 9, 12, 9, 7, 7, 12, 9, 9, 7, 12, 8, 10, 1, 10,
1, 8, 1, 8, 10, 1, 10, 8, 8, 1, 10, 10, 8, 1, 9, 11,
2, 11, 2, 9, 2, 9, 11, 2, 11, 9, 9, 2, 11, 11, 9, 2,
10, 12, 3, 12, 3, 10, 3, 10, 12, 3, 12, 10, 10, 3, 12,
12, 10, 3, 11, 1, 4, 1, 4, 11, 4, 11, 1, 4, 1, 11, 11,
4, 1, 1, 11, 4, 12, 2, 5, 2, 5, 12, 5, 12, 2, 5, 2,
12, 12, 5, 2, 2, 12, 5), 240, 3, byrow = T)
} else if (all(williams_D == 3, selection == 79, type == "R")) {
sequences <- matrix(c(2, 7, 8, 7, 8, 2, 8, 2, 7, 8, 7, 2, 2, 8, 7, 7, 2, 8,
3, 1, 9, 1, 9, 3, 9, 3, 1, 9, 1, 3, 3, 9, 1, 1, 3, 9,
4, 2, 10, 2, 10, 4, 10, 4, 2, 10, 2, 4, 4, 10, 2, 2,
4, 10, 5, 3, 11, 3, 11, 5, 11, 5, 3, 11, 3, 5, 5, 11,
3, 3, 5, 11, 6, 4, 12, 4, 12, 6, 12, 6, 4, 12, 4, 6,
6, 12, 4, 4, 6, 12, 7, 5, 13, 5, 13, 7, 13, 7, 5, 13,
5, 7, 7, 13, 5, 5, 7, 13, 1, 6, 14, 6, 14, 1, 14, 1,
6, 14, 6, 1, 1, 14, 6, 6, 1, 14, 8, 6, 3, 6, 3, 8, 3,
8, 6, 3, 6, 8, 8, 3, 6, 6, 8, 3, 9, 7, 4, 7, 4, 9, 4,
9, 7, 4, 7, 9, 9, 4, 7, 7, 9, 4, 10, 1, 5, 1, 5, 10,
5, 10, 1, 5, 1, 10, 10, 5, 1, 1, 10, 5, 11, 2, 6, 2,
6, 11, 6, 11, 2, 6, 2, 11, 11, 6, 2, 2, 11, 6, 12, 3,
7, 3, 7, 12, 7, 12, 3, 7, 3, 12, 12, 7, 3, 3, 12, 7,
13, 4, 1, 4, 1, 13, 1, 13, 4, 1, 4, 13, 13, 1, 4, 4,
13, 1, 14, 5, 2, 5, 2, 14, 2, 14, 5, 2, 5, 14, 14, 2,
5, 5, 14, 2, 4, 8, 5, 8, 5, 4, 5, 4, 8, 5, 8, 4, 4, 5,
8, 8, 4, 5, 5, 9, 6, 9, 6, 5, 6, 5, 9, 6, 9, 5, 5, 6,
9, 9, 5, 6, 6, 10, 7, 10, 7, 6, 7, 6, 10, 7, 10, 6, 6,
7, 10, 10, 6, 7, 7, 11, 1, 11, 1, 7, 1, 7, 11, 1, 11,
7, 7, 1, 11, 11, 7, 1, 1, 12, 2, 12, 2, 1, 2, 1, 12,
2, 12, 1, 1, 2, 12, 12, 1, 2, 2, 13, 3, 13, 3, 2, 3,
2, 13, 3, 13, 2, 2, 3, 13, 13, 2, 3, 3, 14, 4, 14, 4,
3, 4, 3, 14, 4, 14, 3, 3, 4, 14, 14, 3, 4, 9, 10, 12,
10, 12, 9, 12, 9, 10, 12, 10, 9, 9, 12, 10, 10, 9, 12,
10, 11, 13, 11, 13, 10, 13, 10, 11, 13, 11, 10, 10,
13, 11, 11, 10, 13, 11, 12, 14, 12, 14, 11, 14, 11,
12, 14, 12, 11, 11, 14, 12, 12, 11, 14, 12, 13, 8, 13,
8, 12, 8, 12, 13, 8, 13, 12, 12, 8, 13, 13, 12, 8, 13,
14, 9, 14, 9, 13, 9, 13, 14, 9, 14, 13, 13, 9, 14, 14,
13, 9, 14, 8, 10, 8, 10, 14, 10, 14, 8, 10, 8, 14, 14,
10, 8, 8, 14, 10, 8, 9, 11, 9, 11, 8, 11, 8, 9, 11, 9,
8, 8, 11, 9, 9, 8, 11), 168, 3, byrow = T)
} else if (all(williams_D == 3, selection == 80, type == "R")) {
sequences <- matrix(c(1, 2, 8, 2, 8, 1, 8, 1, 2, 8, 2, 1, 1, 8, 2, 2, 1, 8,
2, 3, 9, 3, 9, 2, 9, 2, 3, 9, 3, 2, 2, 9, 3, 3, 2, 9,
3, 4, 10, 4, 10, 3, 10, 3, 4, 10, 4, 3, 3, 10, 4, 4,
3, 10, 4, 5, 11, 5, 11, 4, 11, 4, 5, 11, 5, 4, 4, 11,
5, 5, 4, 11, 5, 6, 12, 6, 12, 5, 12, 5, 6, 12, 6, 5,
5, 12, 6, 6, 5, 12, 6, 7, 13, 7, 13, 6, 13, 6, 7, 13,
7, 6, 6, 13, 7, 7, 6, 13, 7, 1, 14, 1, 14, 7, 14, 7,
1, 14, 1, 7, 7, 14, 1, 1, 7, 14, 1, 8, 9, 8, 9, 1, 9,
1, 8, 9, 8, 1, 1, 9, 8, 8, 1, 9, 2, 9, 10, 9, 10, 2,
10, 2, 9, 10, 9, 2, 2, 10, 9, 9, 2, 10, 3, 10, 11, 10,
11, 3, 11, 3, 10, 11, 10, 3, 3, 11, 10, 10, 3, 11, 4,
11, 12, 11, 12, 4, 12, 4, 11, 12, 11, 4, 4, 12, 11,
11, 4, 12, 5, 12, 13, 12, 13, 5, 13, 5, 12, 13, 12, 5,
5, 13, 12, 12, 5, 13, 6, 13, 14, 13, 14, 6, 14, 6, 13,
14, 13, 6, 6, 14, 13, 13, 6, 14, 7, 14, 8, 14, 8, 7,
8, 7, 14, 8, 14, 7, 7, 8, 14, 14, 7, 8, 1, 3, 8, 3, 8,
1, 8, 1, 3, 8, 3, 1, 1, 8, 3, 3, 1, 8, 2, 4, 9, 4, 9,
2, 9, 2, 4, 9, 4, 2, 2, 9, 4, 4, 2, 9, 3, 5, 10, 5,
10, 3, 10, 3, 5, 10, 5, 3, 3, 10, 5, 5, 3, 10, 4, 6,
11, 6, 11, 4, 11, 4, 6, 11, 6, 4, 4, 11, 6, 6, 4, 11,
5, 7, 12, 7, 12, 5, 12, 5, 7, 12, 7, 5, 5, 12, 7, 7,
5, 12, 6, 1, 13, 1, 13, 6, 13, 6, 1, 13, 1, 6, 6, 13,
1, 1, 6, 13, 7, 2, 14, 2, 14, 7, 14, 7, 2, 14, 2, 7,
7, 14, 2, 2, 7, 14, 1, 8, 10, 8, 10, 1, 10, 1, 8, 10,
8, 1, 1, 10, 8, 8, 1, 10, 2, 9, 11, 9, 11, 2, 11, 2,
9, 11, 9, 2, 2, 11, 9, 9, 2, 11, 3, 10, 12, 10, 12, 3,
12, 3, 10, 12, 10, 3, 3, 12, 10, 10, 3, 12, 4, 11, 13,
11, 13, 4, 13, 4, 11, 13, 11, 4, 4, 13, 11, 11, 4, 13,
5, 12, 14, 12, 14, 5, 14, 5, 12, 14, 12, 5, 5, 14, 12,
12, 5, 14, 6, 13, 8, 13, 8, 6, 8, 6, 13, 8, 13, 6, 6,
8, 13, 13, 6, 8, 7, 14, 9, 14, 9, 7, 9, 7, 14, 9, 14,
7, 7, 9, 14, 14, 7, 9, 1, 4, 8, 4, 8, 1, 8, 1, 4, 8,
4, 1, 1, 8, 4, 4, 1, 8, 2, 5, 9, 5, 9, 2, 9, 2, 5, 9,
5, 2, 2, 9, 5, 5, 2, 9, 3, 6, 10, 6, 10, 3, 10, 3, 6,
10, 6, 3, 3, 10, 6, 6, 3, 10, 4, 7, 11, 7, 11, 4, 11,
4, 7, 11, 7, 4, 4, 11, 7, 7, 4, 11, 5, 1, 12, 1, 12,
5, 12, 5, 1, 12, 1, 5, 5, 12, 1, 1, 5, 12, 6, 2, 13,
2, 13, 6, 13, 6, 2, 13, 2, 6, 6, 13, 2, 2, 6, 13, 7,
3, 14, 3, 14, 7, 14, 7, 3, 14, 3, 7, 7, 14, 3, 3, 7,
14, 1, 8, 11, 8, 11, 1, 11, 1, 8, 11, 8, 1, 1, 11, 8,
8, 1, 11, 2, 9, 12, 9, 12, 2, 12, 2, 9, 12, 9, 2, 2,
12, 9, 9, 2, 12, 3, 10, 13, 10, 13, 3, 13, 3, 10, 13,
10, 3, 3, 13, 10, 10, 3, 13, 4, 11, 14, 11, 14, 4, 14,
4, 11, 14, 11, 4, 4, 14, 11, 11, 4, 14, 5, 12, 8, 12,
8, 5, 8, 5, 12, 8, 12, 5, 5, 8, 12, 12, 5, 8, 6, 13,
9, 13, 9, 6, 9, 6, 13, 9, 13, 6, 6, 9, 13, 13, 6, 9,
7, 14, 10, 14, 10, 7, 10, 7, 14, 10, 14, 7, 7, 10, 14,
14, 7, 10), 252, 3, byrow = T)
} else if (all(williams_D == 3, selection == 81, type == "R")) {
sequences <- matrix(c(2, 5, 6, 5, 6, 2, 6, 2, 5, 6, 5, 2, 2, 6, 5, 5, 2, 6,
3, 1, 7, 1, 7, 3, 7, 3, 1, 7, 1, 3, 3, 7, 1, 1, 3, 7,
4, 2, 8, 2, 8, 4, 8, 4, 2, 8, 2, 4, 4, 8, 2, 2, 4, 8,
5, 3, 9, 3, 9, 5, 9, 5, 3, 9, 3, 5, 5, 9, 3, 3, 5, 9,
1, 4, 10, 4, 10, 1, 10, 1, 4, 10, 4, 1, 1, 10, 4, 4,
1, 10, 8, 9, 11, 9, 11, 8, 11, 8, 9, 11, 9, 8, 8, 11,
9, 9, 8, 11, 9, 10, 12, 10, 12, 9, 12, 9, 10, 12, 10,
9, 9, 12, 10, 10, 9, 12, 10, 6, 13, 6, 13, 10, 13, 10,
6, 13, 6, 10, 10, 13, 6, 6, 10, 13, 6, 7, 14, 7, 14,
6, 14, 6, 7, 14, 7, 6, 6, 14, 7, 7, 6, 14, 7, 8, 15,
8, 15, 7, 15, 7, 8, 15, 8, 7, 7, 15, 8, 8, 7, 15, 12,
15, 1, 15, 1, 12, 1, 12, 15, 1, 15, 12, 12, 1, 15, 15,
12, 1, 13, 11, 2, 11, 2, 13, 2, 13, 11, 2, 11, 13, 13,
2, 11, 11, 13, 2, 14, 12, 3, 12, 3, 14, 3, 14, 12, 3,
12, 14, 14, 3, 12, 12, 14, 3, 15, 13, 4, 13, 4, 15, 4,
15, 13, 4, 13, 15, 15, 4, 13, 13, 15, 4, 11, 14, 5,
14, 5, 11, 5, 11, 14, 5, 14, 11, 11, 5, 14, 14, 11, 5,
13, 14, 1, 14, 1, 13, 1, 13, 14, 1, 14, 13, 13, 1, 14,
14, 13, 1, 14, 15, 2, 15, 2, 14, 2, 14, 15, 2, 15, 14,
14, 2, 15, 15, 14, 2, 15, 11, 3, 11, 3, 15, 3, 15, 11,
3, 11, 15, 15, 3, 11, 11, 15, 3, 11, 12, 4, 12, 4, 11,
4, 11, 12, 4, 12, 11, 11, 4, 12, 12, 11, 4, 12, 13, 5,
13, 5, 12, 5, 12, 13, 5, 13, 12, 12, 5, 13, 13, 12, 5,
3, 4, 6, 4, 6, 3, 6, 3, 4, 6, 4, 3, 3, 6, 4, 4, 3, 6,
4, 5, 7, 5, 7, 4, 7, 4, 5, 7, 5, 4, 4, 7, 5, 5, 4, 7,
5, 1, 8, 1, 8, 5, 8, 5, 1, 8, 1, 5, 5, 8, 1, 1, 5, 8,
1, 2, 9, 2, 9, 1, 9, 1, 2, 9, 2, 1, 1, 9, 2, 2, 1, 9,
2, 3, 10, 3, 10, 2, 10, 2, 3, 10, 3, 2, 2, 10, 3, 3,
2, 10, 7, 10, 11, 10, 11, 7, 11, 7, 10, 11, 10, 7, 7,
11, 10, 10, 7, 11, 8, 6, 12, 6, 12, 8, 12, 8, 6, 12,
6, 8, 8, 12, 6, 6, 8, 12, 9, 7, 13, 7, 13, 9, 13, 9,
7, 13, 7, 9, 9, 13, 7, 7, 9, 13, 10, 8, 14, 8, 14, 10,
14, 10, 8, 14, 8, 10, 10, 14, 8, 8, 10, 14, 6, 9, 15,
9, 15, 6, 15, 6, 9, 15, 9, 6, 6, 15, 9, 9, 6, 15),
180, 3, byrow = T)
} else if (all(williams_D == 3, selection == 82, type == "R")) {
sequences <- matrix(c(1, 6, 11, 6, 11, 1, 11, 1, 6, 11, 6, 1, 1, 11, 6, 6,
1, 11, 2, 7, 12, 7, 12, 2, 12, 2, 7, 12, 7, 2, 2, 12,
7, 7, 2, 12, 3, 8, 13, 8, 13, 3, 13, 3, 8, 13, 8, 3,
3, 13, 8, 8, 3, 13, 4, 9, 14, 9, 14, 4, 14, 4, 9, 14,
9, 4, 4, 14, 9, 9, 4, 14, 5, 10, 15, 10, 15, 5, 15, 5,
10, 15, 10, 5, 5, 15, 10, 10, 5, 15, 1, 7, 15, 7, 15,
1, 15, 1, 7, 15, 7, 1, 1, 15, 7, 7, 1, 15, 6, 13, 4,
13, 4, 6, 4, 6, 13, 4, 13, 6, 6, 4, 13, 13, 6, 4, 11,
2, 10, 2, 10, 11, 10, 11, 2, 10, 2, 11, 11, 10, 2, 2,
11, 10, 12, 8, 14, 8, 14, 12, 14, 12, 8, 14, 8, 12,
12, 14, 8, 8, 12, 14, 3, 9, 5, 9, 5, 3, 5, 3, 9, 5, 9,
3, 3, 5, 9, 9, 3, 5, 1, 8, 9, 8, 9, 1, 9, 1, 8, 9, 8,
1, 1, 9, 8, 8, 1, 9, 6, 3, 10, 3, 10, 6, 10, 6, 3, 10,
3, 6, 6, 10, 3, 3, 6, 10, 11, 12, 13, 12, 13, 11, 13,
11, 12, 13, 12, 11, 11, 13, 12, 12, 11, 13, 2, 4, 15,
4, 15, 2, 15, 2, 4, 15, 4, 2, 2, 15, 4, 4, 2, 15, 7,
14, 5, 14, 5, 7, 5, 7, 14, 5, 14, 7, 7, 5, 14, 14, 7,
5, 1, 6, 11, 6, 11, 1, 11, 1, 6, 11, 6, 1, 1, 11, 6,
6, 1, 11, 2, 7, 12, 7, 12, 2, 12, 2, 7, 12, 7, 2, 2,
12, 7, 7, 2, 12, 3, 8, 13, 8, 13, 3, 13, 3, 8, 13, 8,
3, 3, 13, 8, 8, 3, 13, 4, 9, 14, 9, 14, 4, 14, 4, 9,
14, 9, 4, 4, 14, 9, 9, 4, 14, 5, 10, 15, 10, 15, 5,
15, 5, 10, 15, 10, 5, 5, 15, 10, 10, 5, 15, 1, 13, 5,
13, 5, 1, 5, 1, 13, 5, 13, 1, 1, 5, 13, 13, 1, 5, 6,
2, 14, 2, 14, 6, 14, 6, 2, 14, 2, 6, 6, 14, 2, 2, 6,
14, 11, 7, 9, 7, 9, 11, 9, 11, 7, 9, 7, 11, 11, 9, 7,
7, 11, 9, 12, 3, 15, 3, 15, 12, 15, 12, 3, 15, 3, 12,
12, 15, 3, 3, 12, 15, 8, 4, 10, 4, 10, 8, 10, 8, 4,
10, 4, 8, 8, 10, 4, 4, 8, 10, 1, 14, 10, 14, 10, 1,
10, 1, 14, 10, 14, 1, 1, 10, 14, 14, 1, 10, 6, 12, 5,
12, 5, 6, 5, 6, 12, 5, 12, 6, 6, 5, 12, 12, 6, 5, 11,
8, 15, 8, 15, 11, 15, 11, 8, 15, 8, 11, 11, 15, 8, 8,
11, 15, 2, 13, 9, 13, 9, 2, 9, 2, 13, 9, 13, 2, 2, 9,
13, 13, 2, 9, 7, 3, 4, 3, 4, 7, 4, 7, 3, 4, 3, 7, 7,
4, 3, 3, 7, 4, 1, 2, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1, 1,
3, 2, 2, 1, 3, 6, 7, 8, 7, 8, 6, 8, 6, 7, 8, 7, 6, 6,
8, 7, 7, 6, 8, 11, 4, 5, 4, 5, 11, 5, 11, 4, 5, 4, 11,
11, 5, 4, 4, 11, 5, 12, 9, 10, 9, 10, 12, 10, 12, 9,
10, 9, 12, 12, 10, 9, 9, 12, 10, 13, 14, 15, 14, 15,
13, 15, 13, 14, 15, 14, 13, 13, 15, 14, 14, 13, 15, 1,
12, 4, 12, 4, 1, 4, 1, 12, 4, 12, 1, 1, 4, 12, 12, 1,
4, 6, 9, 15, 9, 15, 6, 15, 6, 9, 15, 9, 6, 6, 15, 9,
9, 6, 15, 11, 3, 14, 3, 14, 11, 14, 11, 3, 14, 3, 11,
11, 14, 3, 3, 11, 14, 2, 8, 5, 8, 5, 2, 5, 2, 8, 5, 8,
2, 2, 5, 8, 8, 2, 5, 7, 13, 10, 13, 10, 7, 10, 7, 13,
10, 13, 7, 7, 10, 13, 13, 7, 10), 240, 3, byrow = T)
} else if (all(williams_D == 3, selection == 84, type == "R")) {
sequences <- matrix(c(2, 5, 6, 5, 6, 2, 6, 2, 5, 6, 5, 2, 2, 6, 5, 5, 2, 6,
3, 1, 7, 1, 7, 3, 7, 3, 1, 7, 1, 3, 3, 7, 1, 1, 3, 7,
4, 2, 8, 2, 8, 4, 8, 4, 2, 8, 2, 4, 4, 8, 2, 2, 4, 8,
5, 3, 9, 3, 9, 5, 9, 5, 3, 9, 3, 5, 5, 9, 3, 3, 5, 9,
1, 4, 10, 4, 10, 1, 10, 1, 4, 10, 4, 1, 1, 10, 4, 4,
1, 10, 8, 9, 11, 9, 11, 8, 11, 8, 9, 11, 9, 8, 8, 11,
9, 9, 8, 11, 9, 10, 12, 10, 12, 9, 12, 9, 10, 12, 10,
9, 9, 12, 10, 10, 9, 12, 10, 6, 13, 6, 13, 10, 13, 10,
6, 13, 6, 10, 10, 13, 6, 6, 10, 13, 6, 7, 14, 7, 14,
6, 14, 6, 7, 14, 7, 6, 6, 14, 7, 7, 6, 14, 7, 8, 15,
8, 15, 7, 15, 7, 8, 15, 8, 7, 7, 15, 8, 8, 7, 15, 12,
15, 1, 15, 1, 12, 1, 12, 15, 1, 15, 12, 12, 1, 15, 15,
12, 1, 13, 11, 2, 11, 2, 13, 2, 13, 11, 2, 11, 13, 13,
2, 11, 11, 13, 2, 14, 12, 3, 12, 3, 14, 3, 14, 12, 3,
12, 14, 14, 3, 12, 12, 14, 3, 15, 13, 4, 13, 4, 15, 4,
15, 13, 4, 13, 15, 15, 4, 13, 13, 15, 4, 11, 14, 5,
14, 5, 11, 5, 11, 14, 5, 14, 11, 11, 5, 14, 14, 11, 5,
13, 14, 1, 14, 1, 13, 1, 13, 14, 1, 14, 13, 13, 1, 14,
14, 13, 1, 14, 15, 2, 15, 2, 14, 2, 14, 15, 2, 15, 14,
14, 2, 15, 15, 14, 2, 15, 11, 3, 11, 3, 15, 3, 15, 11,
3, 11, 15, 15, 3, 11, 11, 15, 3, 11, 12, 4, 12, 4, 11,
4, 11, 12, 4, 12, 11, 11, 4, 12, 12, 11, 4, 12, 13, 5,
13, 5, 12, 5, 12, 13, 5, 13, 12, 12, 5, 13, 13, 12, 5,
3, 4, 6, 4, 6, 3, 6, 3, 4, 6, 4, 3, 3, 6, 4, 4, 3, 6,
4, 5, 7, 5, 7, 4, 7, 4, 5, 7, 5, 4, 4, 7, 5, 5, 4, 7,
5, 1, 8, 1, 8, 5, 8, 5, 1, 8, 1, 5, 5, 8, 1, 1, 5, 8,
1, 2, 9, 2, 9, 1, 9, 1, 2, 9, 2, 1, 1, 9, 2, 2, 1, 9,
2, 3, 10, 3, 10, 2, 10, 2, 3, 10, 3, 2, 2, 10, 3, 3,
2, 10, 7, 10, 11, 10, 11, 7, 11, 7, 10, 11, 10, 7, 7,
11, 10, 10, 7, 11, 8, 6, 12, 6, 12, 8, 12, 8, 6, 12,
6, 8, 8, 12, 6, 6, 8, 12, 9, 7, 13, 7, 13, 9, 13, 9,
7, 13, 7, 9, 9, 13, 7, 7, 9, 13, 10, 8, 14, 8, 14, 10,
14, 10, 8, 14, 8, 10, 10, 14, 8, 8, 10, 14, 6, 9, 15,
9, 15, 6, 15, 6, 9, 15, 9, 6, 6, 15, 9, 9, 6, 15, 1,
6, 11, 6, 11, 1, 11, 1, 6, 11, 6, 1, 1, 11, 6, 6, 1,
11, 2, 7, 12, 7, 12, 2, 12, 2, 7, 12, 7, 2, 2, 12, 7,
7, 2, 12, 3, 8, 13, 8, 13, 3, 13, 3, 8, 13, 8, 3, 3,
13, 8, 8, 3, 13, 4, 9, 14, 9, 14, 4, 14, 4, 9, 14, 9,
4, 4, 14, 9, 9, 4, 14, 5, 10, 15, 10, 15, 5, 15, 5,
10, 15, 10, 5, 5, 15, 10, 10, 5, 15, 6, 11, 1, 11, 1,
6, 1, 6, 11, 1, 11, 6, 6, 1, 11, 11, 6, 1, 7, 12, 2,
12, 2, 7, 2, 7, 12, 2, 12, 7, 7, 2, 12, 12, 7, 2, 8,
13, 3, 13, 3, 8, 3, 8, 13, 3, 13, 8, 8, 3, 13, 13, 8,
3, 9, 14, 4, 14, 4, 9, 4, 9, 14, 4, 14, 9, 9, 4, 14,
14, 9, 4, 10, 15, 5, 15, 5, 10, 5, 10, 15, 5, 15, 10,
10, 5, 15, 15, 10, 5, 11, 1, 6, 1, 6, 11, 6, 11, 1, 6,
1, 11, 11, 6, 1, 1, 11, 6, 12, 2, 7, 2, 7, 12, 7, 12,
2, 7, 2, 12, 12, 7, 2, 2, 12, 7, 13, 3, 8, 3, 8, 13,
8, 13, 3, 8, 3, 13, 13, 8, 3, 3, 13, 8, 14, 4, 9, 4,
9, 14, 9, 14, 4, 9, 4, 14, 14, 9, 4, 4, 14, 9, 15, 5,
10, 5, 10, 15, 10, 15, 5, 10, 5, 15, 15, 10, 5, 5, 15,
10), 270, 3, byrow = T)
} else if (all(williams_D == 3, selection == 85, type == "R")) {
sequences <- matrix(c(1, 4, 10, 4, 10, 1, 10, 1, 4, 10, 4, 1, 1, 10, 4, 4,
1, 10, 2, 5, 6, 5, 6, 2, 6, 2, 5, 6, 5, 2, 2, 6, 5, 5,
2, 6, 3, 1, 7, 1, 7, 3, 7, 3, 1, 7, 1, 3, 3, 7, 1, 1,
3, 7, 4, 2, 8, 2, 8, 4, 8, 4, 2, 8, 2, 4, 4, 8, 2, 2,
4, 8, 5, 3, 9, 3, 9, 5, 9, 5, 3, 9, 3, 5, 5, 9, 3, 3,
5, 9, 6, 7, 14, 7, 14, 6, 14, 6, 7, 14, 7, 6, 6, 14,
7, 7, 6, 14, 7, 8, 15, 8, 15, 7, 15, 7, 8, 15, 8, 7,
7, 15, 8, 8, 7, 15, 8, 9, 11, 9, 11, 8, 11, 8, 9, 11,
9, 8, 8, 11, 9, 9, 8, 11, 9, 10, 12, 10, 12, 9, 12, 9,
10, 12, 10, 9, 9, 12, 10, 10, 9, 12, 10, 6, 13, 6, 13,
10, 13, 10, 6, 13, 6, 10, 10, 13, 6, 6, 10, 13, 12,
15, 1, 15, 1, 12, 1, 12, 15, 1, 15, 12, 12, 1, 15, 15,
12, 1, 13, 11, 2, 11, 2, 13, 2, 13, 11, 2, 11, 13, 13,
2, 11, 11, 13, 2, 14, 12, 3, 12, 3, 14, 3, 14, 12, 3,
12, 14, 14, 3, 12, 12, 14, 3, 15, 13, 4, 13, 4, 15, 4,
15, 13, 4, 13, 15, 15, 4, 13, 13, 15, 4, 11, 14, 5,
14, 5, 11, 5, 11, 14, 5, 14, 11, 11, 5, 14, 14, 11, 5,
1, 2, 9, 2, 9, 1, 9, 1, 2, 9, 2, 1, 1, 9, 2, 2, 1, 9,
2, 3, 10, 3, 10, 2, 10, 2, 3, 10, 3, 2, 2, 10, 3, 3,
2, 10, 3, 4, 6, 4, 6, 3, 6, 3, 4, 6, 4, 3, 3, 6, 4, 4,
3, 6, 4, 5, 7, 5, 7, 4, 7, 4, 5, 7, 5, 4, 4, 7, 5, 5,
4, 7, 5, 1, 8, 1, 8, 5, 8, 5, 1, 8, 1, 5, 5, 8, 1, 1,
5, 8, 7, 10, 11, 10, 11, 7, 11, 7, 10, 11, 10, 7, 7,
11, 10, 10, 7, 11, 8, 6, 12, 6, 12, 8, 12, 8, 6, 12,
6, 8, 8, 12, 6, 6, 8, 12, 9, 7, 13, 7, 13, 9, 13, 9,
7, 13, 7, 9, 9, 13, 7, 7, 9, 13, 10, 8, 14, 8, 14, 10,
14, 10, 8, 14, 8, 10, 10, 14, 8, 8, 10, 14, 6, 9, 15,
9, 15, 6, 15, 6, 9, 15, 9, 6, 6, 15, 9, 9, 6, 15, 14,
13, 1, 13, 1, 14, 1, 14, 13, 1, 13, 14, 14, 1, 13, 13,
14, 1, 15, 14, 2, 14, 2, 15, 2, 15, 14, 2, 14, 15, 15,
2, 14, 14, 15, 2, 11, 15, 3, 15, 3, 11, 3, 11, 15, 3,
15, 11, 11, 3, 15, 15, 11, 3, 12, 11, 4, 11, 4, 12, 4,
12, 11, 4, 11, 12, 12, 4, 11, 11, 12, 4, 13, 12, 5,
12, 5, 13, 5, 13, 12, 5, 12, 13, 13, 5, 12, 12, 13, 5,
1, 6, 11, 6, 11, 1, 11, 1, 6, 11, 6, 1, 1, 11, 6, 6,
1, 11, 1, 6, 11, 6, 11, 1, 11, 1, 6, 11, 6, 1, 1, 11,
6, 6, 1, 11, 1, 6, 11, 6, 11, 1, 11, 1, 6, 11, 6, 1,
1, 11, 6, 6, 1, 11, 1, 6, 11, 6, 11, 1, 11, 1, 6, 11,
6, 1, 1, 11, 6, 6, 1, 11, 2, 7, 12, 7, 12, 2, 12, 2,
7, 12, 7, 2, 2, 12, 7, 7, 2, 12, 2, 7, 12, 7, 12, 2,
12, 2, 7, 12, 7, 2, 2, 12, 7, 7, 2, 12, 2, 7, 12, 7,
12, 2, 12, 2, 7, 12, 7, 2, 2, 12, 7, 7, 2, 12, 2, 7,
12, 7, 12, 2, 12, 2, 7, 12, 7, 2, 2, 12, 7, 7, 2, 12,
3, 8, 13, 8, 13, 3, 13, 3, 8, 13, 8, 3, 3, 13, 8, 8,
3, 13, 3, 8, 13, 8, 13, 3, 13, 3, 8, 13, 8, 3, 3, 13,
8, 8, 3, 13, 3, 8, 13, 8, 13, 3, 13, 3, 8, 13, 8, 3,
3, 13, 8, 8, 3, 13, 3, 8, 13, 8, 13, 3, 13, 3, 8, 13,
8, 3, 3, 13, 8, 8, 3, 13, 4, 9, 14, 9, 14, 4, 14, 4,
9, 14, 9, 4, 4, 14, 9, 9, 4, 14, 4, 9, 14, 9, 14, 4,
14, 4, 9, 14, 9, 4, 4, 14, 9, 9, 4, 14, 4, 9, 14, 9,
14, 4, 14, 4, 9, 14, 9, 4, 4, 14, 9, 9, 4, 14, 4, 9,
14, 9, 14, 4, 14, 4, 9, 14, 9, 4, 4, 14, 9, 9, 4, 14,
5, 10, 15, 10, 15, 5, 15, 5, 10, 15, 10, 5, 5, 15, 10,
10, 5, 15, 5, 10, 15, 10, 15, 5, 15, 5, 10, 15, 10, 5,
5, 15, 10, 10, 5, 15, 5, 10, 15, 10, 15, 5, 15, 5, 10,
15, 10, 5, 5, 15, 10, 10, 5, 15, 5, 10, 15, 10, 15, 5,
15, 5, 10, 15, 10, 5, 5, 15, 10, 10, 5, 15), 300, 3,
byrow = T)
} else if (all(williams_D == 3, selection == 86, type == "R")) {
sequences <- matrix(c(1, 2, 11, 2, 11, 1, 11, 1, 2, 11, 2, 1, 1, 11, 2, 2,
1, 11, 2, 3, 12, 3, 12, 2, 12, 2, 3, 12, 3, 2, 2, 12,
3, 3, 2, 12, 3, 4, 13, 4, 13, 3, 13, 3, 4, 13, 4, 3,
3, 13, 4, 4, 3, 13, 4, 5, 14, 5, 14, 4, 14, 4, 5, 14,
5, 4, 4, 14, 5, 5, 4, 14, 5, 6, 15, 6, 15, 5, 15, 5,
6, 15, 6, 5, 5, 15, 6, 6, 5, 15, 6, 7, 16, 7, 16, 6,
16, 6, 7, 16, 7, 6, 6, 16, 7, 7, 6, 16, 7, 8, 1, 8, 1,
7, 1, 7, 8, 1, 8, 7, 7, 1, 8, 8, 7, 1, 8, 9, 2, 9, 2,
8, 2, 8, 9, 2, 9, 8, 8, 2, 9, 9, 8, 2, 9, 10, 3, 10,
3, 9, 3, 9, 10, 3, 10, 9, 9, 3, 10, 10, 9, 3, 10, 11,
4, 11, 4, 10, 4, 10, 11, 4, 11, 10, 10, 4, 11, 11, 10,
4, 11, 12, 5, 12, 5, 11, 5, 11, 12, 5, 12, 11, 11, 5,
12, 12, 11, 5, 12, 13, 6, 13, 6, 12, 6, 12, 13, 6, 13,
12, 12, 6, 13, 13, 12, 6, 13, 14, 7, 14, 7, 13, 7, 13,
14, 7, 14, 13, 13, 7, 14, 14, 13, 7, 14, 15, 8, 15, 8,
14, 8, 14, 15, 8, 15, 14, 14, 8, 15, 15, 14, 8, 15,
16, 9, 16, 9, 15, 9, 15, 16, 9, 16, 15, 15, 9, 16, 16,
15, 9, 16, 1, 10, 1, 10, 16, 10, 16, 1, 10, 1, 16, 16,
10, 1, 1, 16, 10, 1, 3, 6, 3, 6, 1, 6, 1, 3, 6, 3, 1,
1, 6, 3, 3, 1, 6, 2, 4, 7, 4, 7, 2, 7, 2, 4, 7, 4, 2,
2, 7, 4, 4, 2, 7, 3, 5, 8, 5, 8, 3, 8, 3, 5, 8, 5, 3,
3, 8, 5, 5, 3, 8, 4, 6, 9, 6, 9, 4, 9, 4, 6, 9, 6, 4,
4, 9, 6, 6, 4, 9, 5, 7, 10, 7, 10, 5, 10, 5, 7, 10, 7,
5, 5, 10, 7, 7, 5, 10, 6, 8, 11, 8, 11, 6, 11, 6, 8,
11, 8, 6, 6, 11, 8, 8, 6, 11, 7, 9, 12, 9, 12, 7, 12,
7, 9, 12, 9, 7, 7, 12, 9, 9, 7, 12, 8, 10, 13, 10, 13,
8, 13, 8, 10, 13, 10, 8, 8, 13, 10, 10, 8, 13, 9, 11,
14, 11, 14, 9, 14, 9, 11, 14, 11, 9, 9, 14, 11, 11, 9,
14, 10, 12, 15, 12, 15, 10, 15, 10, 12, 15, 12, 10,
10, 15, 12, 12, 10, 15, 11, 13, 16, 13, 16, 11, 16,
11, 13, 16, 13, 11, 11, 16, 13, 13, 11, 16, 12, 14, 1,
14, 1, 12, 1, 12, 14, 1, 14, 12, 12, 1, 14, 14, 12, 1,
13, 15, 2, 15, 2, 13, 2, 13, 15, 2, 15, 13, 13, 2, 15,
15, 13, 2, 14, 16, 3, 16, 3, 14, 3, 14, 16, 3, 16, 14,
14, 3, 16, 16, 14, 3, 15, 1, 4, 1, 4, 15, 4, 15, 1, 4,
1, 15, 15, 4, 1, 1, 15, 4, 16, 2, 5, 2, 5, 16, 5, 16,
2, 5, 2, 16, 16, 5, 2, 2, 16, 5), 192, 3, byrow = T)
} else if (all(williams_D == 3, selection == 89, type == "R")) {
sequences <- matrix(c(1, 13, 11, 13, 11, 1, 11, 1, 13, 11, 13, 1, 1, 11, 13,
13, 1, 11, 2, 14, 12, 14, 12, 2, 12, 2, 14, 12, 14, 2,
2, 12, 14, 14, 2, 12, 3, 15, 13, 15, 13, 3, 13, 3, 15,
13, 15, 3, 3, 13, 15, 15, 3, 13, 4, 16, 14, 16, 14, 4,
14, 4, 16, 14, 16, 4, 4, 14, 16, 16, 4, 14, 5, 17, 15,
17, 15, 5, 15, 5, 17, 15, 17, 5, 5, 15, 17, 17, 5, 15,
6, 18, 16, 18, 16, 6, 16, 6, 18, 16, 18, 6, 6, 16, 18,
18, 6, 16, 7, 10, 17, 10, 17, 7, 17, 7, 10, 17, 10, 7,
7, 17, 10, 10, 7, 17, 8, 11, 18, 11, 18, 8, 18, 8, 11,
18, 11, 8, 8, 18, 11, 11, 8, 18, 9, 12, 10, 12, 10, 9,
10, 9, 12, 10, 12, 9, 9, 10, 12, 12, 9, 10, 14, 1, 10,
1, 10, 14, 10, 14, 1, 10, 1, 14, 14, 10, 1, 1, 14, 10,
15, 2, 11, 2, 11, 15, 11, 15, 2, 11, 2, 15, 15, 11, 2,
2, 15, 11, 16, 3, 12, 3, 12, 16, 12, 16, 3, 12, 3, 16,
16, 12, 3, 3, 16, 12, 17, 4, 13, 4, 13, 17, 13, 17, 4,
13, 4, 17, 17, 13, 4, 4, 17, 13, 18, 5, 14, 5, 14, 18,
14, 18, 5, 14, 5, 18, 18, 14, 5, 5, 18, 14, 10, 6, 15,
6, 15, 10, 15, 10, 6, 15, 6, 10, 10, 15, 6, 6, 10, 15,
11, 7, 16, 7, 16, 11, 16, 11, 7, 16, 7, 11, 11, 16, 7,
7, 11, 16, 12, 8, 17, 8, 17, 12, 17, 12, 8, 17, 8, 12,
12, 17, 8, 8, 12, 17, 13, 9, 18, 9, 18, 13, 18, 13, 9,
18, 9, 13, 13, 18, 9, 9, 13, 18, 1, 15, 18, 15, 18, 1,
18, 1, 15, 18, 15, 1, 1, 18, 15, 15, 1, 18, 2, 16, 10,
16, 10, 2, 10, 2, 16, 10, 16, 2, 2, 10, 16, 16, 2, 10,
3, 17, 11, 17, 11, 3, 11, 3, 17, 11, 17, 3, 3, 11, 17,
17, 3, 11, 4, 18, 12, 18, 12, 4, 12, 4, 18, 12, 18, 4,
4, 12, 18, 18, 4, 12, 5, 10, 13, 10, 13, 5, 13, 5, 10,
13, 10, 5, 5, 13, 10, 10, 5, 13, 6, 11, 14, 11, 14, 6,
14, 6, 11, 14, 11, 6, 6, 14, 11, 11, 6, 14, 7, 12, 15,
12, 15, 7, 15, 7, 12, 15, 12, 7, 7, 15, 12, 12, 7, 15,
8, 13, 16, 13, 16, 8, 16, 8, 13, 16, 13, 8, 8, 16, 13,
13, 8, 16, 9, 14, 17, 14, 17, 9, 17, 9, 14, 17, 14, 9,
9, 17, 14, 14, 9, 17, 16, 17, 1, 17, 1, 16, 1, 16, 17,
1, 17, 16, 16, 1, 17, 17, 16, 1, 17, 18, 2, 18, 2, 17,
2, 17, 18, 2, 18, 17, 17, 2, 18, 18, 17, 2, 18, 10, 3,
10, 3, 18, 3, 18, 10, 3, 10, 18, 18, 3, 10, 10, 18, 3,
10, 11, 4, 11, 4, 10, 4, 10, 11, 4, 11, 10, 10, 4, 11,
11, 10, 4, 11, 12, 5, 12, 5, 11, 5, 11, 12, 5, 12, 11,
11, 5, 12, 12, 11, 5, 12, 13, 6, 13, 6, 12, 6, 12, 13,
6, 13, 12, 12, 6, 13, 13, 12, 6, 13, 14, 7, 14, 7, 13,
7, 13, 14, 7, 14, 13, 13, 7, 14, 14, 13, 7, 14, 15, 8,
15, 8, 14, 8, 14, 15, 8, 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, 9, 11,
11, 2, 9, 9, 11, 2), 324, 3, byrow = T)
} else if (all(williams_D == 3, selection == 91, type == "R")) {
sequences <- matrix(c(1, 2, 11, 2, 11, 1, 11, 1, 2, 11, 2, 1, 1, 11, 2, 2,
1, 11, 2, 3, 12, 3, 12, 2, 12, 2, 3, 12, 3, 2, 2, 12,
3, 3, 2, 12, 3, 4, 13, 4, 13, 3, 13, 3, 4, 13, 4, 3,
3, 13, 4, 4, 3, 13, 4, 5, 14, 5, 14, 4, 14, 4, 5, 14,
5, 4, 4, 14, 5, 5, 4, 14, 5, 6, 15, 6, 15, 5, 15, 5,
6, 15, 6, 5, 5, 15, 6, 6, 5, 15, 6, 7, 16, 7, 16, 6,
16, 6, 7, 16, 7, 6, 6, 16, 7, 7, 6, 16, 7, 8, 17, 8,
17, 7, 17, 7, 8, 17, 8, 7, 7, 17, 8, 8, 7, 17, 8, 9,
18, 9, 18, 8, 18, 8, 9, 18, 9, 8, 8, 18, 9, 9, 8, 18,
9, 10, 19, 10, 19, 9, 19, 9, 10, 19, 10, 9, 9, 19, 10,
10, 9, 19, 10, 11, 20, 11, 20, 10, 20, 10, 11, 20, 11,
10, 10, 20, 11, 11, 10, 20, 11, 12, 21, 12, 21, 11,
21, 11, 12, 21, 12, 11, 11, 21, 12, 12, 11, 21, 12,
13, 1, 13, 1, 12, 1, 12, 13, 1, 13, 12, 12, 1, 13, 13,
12, 1, 13, 14, 2, 14, 2, 13, 2, 13, 14, 2, 14, 13, 13,
2, 14, 14, 13, 2, 14, 15, 3, 15, 3, 14, 3, 14, 15, 3,
15, 14, 14, 3, 15, 15, 14, 3, 15, 16, 4, 16, 4, 15, 4,
15, 16, 4, 16, 15, 15, 4, 16, 16, 15, 4, 16, 17, 5,
17, 5, 16, 5, 16, 17, 5, 17, 16, 16, 5, 17, 17, 16, 5,
17, 18, 6, 18, 6, 17, 6, 17, 18, 6, 18, 17, 17, 6, 18,
18, 17, 6, 18, 19, 7, 19, 7, 18, 7, 18, 19, 7, 19, 18,
18, 7, 19, 19, 18, 7, 19, 20, 8, 20, 8, 19, 8, 19, 20,
8, 20, 19, 19, 8, 20, 20, 19, 8, 20, 21, 9, 21, 9, 20,
9, 20, 21, 9, 21, 20, 20, 9, 21, 21, 20, 9, 21, 1, 10,
1, 10, 21, 10, 21, 1, 10, 1, 21, 21, 10, 1, 1, 21, 10,
1, 3, 7, 3, 7, 1, 7, 1, 3, 7, 3, 1, 1, 7, 3, 3, 1, 7,
2, 4, 8, 4, 8, 2, 8, 2, 4, 8, 4, 2, 2, 8, 4, 4, 2, 8,
3, 5, 9, 5, 9, 3, 9, 3, 5, 9, 5, 3, 3, 9, 5, 5, 3, 9,
4, 6, 10, 6, 10, 4, 10, 4, 6, 10, 6, 4, 4, 10, 6, 6,
4, 10, 5, 7, 11, 7, 11, 5, 11, 5, 7, 11, 7, 5, 5, 11,
7, 7, 5, 11, 6, 8, 12, 8, 12, 6, 12, 6, 8, 12, 8, 6,
6, 12, 8, 8, 6, 12, 7, 9, 13, 9, 13, 7, 13, 7, 9, 13,
9, 7, 7, 13, 9, 9, 7, 13, 8, 10, 14, 10, 14, 8, 14, 8,
10, 14, 10, 8, 8, 14, 10, 10, 8, 14, 9, 11, 15, 11,
15, 9, 15, 9, 11, 15, 11, 9, 9, 15, 11, 11, 9, 15, 10,
12, 16, 12, 16, 10, 16, 10, 12, 16, 12, 10, 10, 16,
12, 12, 10, 16, 11, 13, 17, 13, 17, 11, 17, 11, 13,
17, 13, 11, 11, 17, 13, 13, 11, 17, 12, 14, 18, 14,
18, 12, 18, 12, 14, 18, 14, 12, 12, 18, 14, 14, 12,
18, 13, 15, 19, 15, 19, 13, 19, 13, 15, 19, 15, 13,
13, 19, 15, 15, 13, 19, 14, 16, 20, 16, 20, 14, 20,
14, 16, 20, 16, 14, 14, 20, 16, 16, 14, 20, 15, 17,
21, 17, 21, 15, 21, 15, 17, 21, 17, 15, 15, 21, 17,
17, 15, 21, 16, 18, 1, 18, 1, 16, 1, 16, 18, 1, 18,
16, 16, 1, 18, 18, 16, 1, 17, 19, 2, 19, 2, 17, 2, 17,
19, 2, 19, 17, 17, 2, 19, 19, 17, 2, 18, 20, 3, 20, 3,
18, 3, 18, 20, 3, 20, 18, 18, 3, 20, 20, 18, 3, 19,
21, 4, 21, 4, 19, 4, 19, 21, 4, 21, 19, 19, 4, 21, 21,
19, 4, 20, 1, 5, 1, 5, 20, 5, 20, 1, 5, 1, 20, 20, 5,
1, 1, 20, 5, 21, 2, 6, 2, 6, 21, 6, 21, 2, 6, 2, 21,
21, 6, 2, 2, 21, 6, 1, 4, 9, 4, 9, 1, 9, 1, 4, 9, 4,
1, 1, 9, 4, 4, 1, 9, 2, 5, 10, 5, 10, 2, 10, 2, 5, 10,
5, 2, 2, 10, 5, 5, 2, 10, 3, 6, 11, 6, 11, 3, 11, 3,
6, 11, 6, 3, 3, 11, 6, 6, 3, 11, 4, 7, 12, 7, 12, 4,
12, 4, 7, 12, 7, 4, 4, 12, 7, 7, 4, 12, 5, 8, 13, 8,
13, 5, 13, 5, 8, 13, 8, 5, 5, 13, 8, 8, 5, 13, 6, 9,
14, 9, 14, 6, 14, 6, 9, 14, 9, 6, 6, 14, 9, 9, 6, 14,
7, 10, 15, 10, 15, 7, 15, 7, 10, 15, 10, 7, 7, 15, 10,
10, 7, 15, 8, 11, 16, 11, 16, 8, 16, 8, 11, 16, 11, 8,
8, 16, 11, 11, 8, 16, 9, 12, 17, 12, 17, 9, 17, 9, 12,
17, 12, 9, 9, 17, 12, 12, 9, 17, 10, 13, 18, 13, 18,
10, 18, 10, 13, 18, 13, 10, 10, 18, 13, 13, 10, 18,
11, 14, 19, 14, 19, 11, 19, 11, 14, 19, 14, 11, 11,
19, 14, 14, 11, 19, 12, 15, 20, 15, 20, 12, 20, 12,
15, 20, 15, 12, 12, 20, 15, 15, 12, 20, 13, 16, 21,
16, 21, 13, 21, 13, 16, 21, 16, 13, 13, 21, 16, 16,
13, 21, 14, 17, 1, 17, 1, 14, 1, 14, 17, 1, 17, 14,
14, 1, 17, 17, 14, 1, 15, 18, 2, 18, 2, 15, 2, 15, 18,
2, 18, 15, 15, 2, 18, 18, 15, 2, 16, 19, 3, 19, 3, 16,
3, 16, 19, 3, 19, 16, 16, 3, 19, 19, 16, 3, 17, 20, 4,
20, 4, 17, 4, 17, 20, 4, 20, 17, 17, 4, 20, 20, 17, 4,
18, 21, 5, 21, 5, 18, 5, 18, 21, 5, 21, 18, 18, 5, 21,
21, 18, 5, 19, 1, 6, 1, 6, 19, 6, 19, 1, 6, 1, 19, 19,
6, 1, 1, 19, 6, 20, 2, 7, 2, 7, 20, 7, 20, 2, 7, 2,
20, 20, 7, 2, 2, 20, 7, 21, 3, 8, 3, 8, 21, 8, 21, 3,
8, 3, 21, 21, 8, 3, 3, 21, 8), 378, 3, byrow = T)
} else if (all(williams_D == 3, selection == 93, type == "R")) {
sequences <- matrix(c(1, 2, 21, 2, 21, 1, 21, 1, 2, 21, 2, 1, 1, 21, 2, 2,
1, 21, 2, 7, 22, 7, 22, 2, 22, 2, 7, 22, 7, 2, 2, 22,
7, 7, 2, 22, 7, 8, 3, 8, 3, 7, 3, 7, 8, 3, 8, 7, 7, 3,
8, 8, 7, 3, 8, 13, 4, 13, 4, 8, 4, 8, 13, 4, 13, 8, 8,
4, 13, 13, 8, 4, 13, 14, 9, 14, 9, 13, 9, 13, 14, 9,
14, 13, 13, 9, 14, 14, 13, 9, 14, 19, 10, 19, 10, 14,
10, 14, 19, 10, 19, 14, 14, 10, 19, 19, 14, 10, 19,
20, 15, 20, 15, 19, 15, 19, 20, 15, 20, 19, 19, 15,
20, 20, 19, 15, 20, 1, 16, 1, 16, 20, 16, 20, 1, 16,
1, 20, 20, 16, 1, 1, 20, 16, 1, 14, 22, 14, 22, 1, 22,
1, 14, 22, 14, 1, 1, 22, 14, 14, 1, 22, 2, 19, 3, 19,
3, 2, 3, 2, 19, 3, 19, 2, 2, 3, 19, 19, 2, 3, 7, 20,
4, 20, 4, 7, 4, 7, 20, 4, 20, 7, 7, 4, 20, 20, 7, 4,
8, 1, 9, 1, 9, 8, 9, 8, 1, 9, 1, 8, 8, 9, 1, 1, 8, 9,
13, 2, 10, 2, 10, 13, 10, 13, 2, 10, 2, 13, 13, 10, 2,
2, 13, 10, 14, 7, 15, 7, 15, 14, 15, 14, 7, 15, 7, 14,
14, 15, 7, 7, 14, 15, 19, 8, 16, 8, 16, 19, 16, 19, 8,
16, 8, 19, 19, 16, 8, 8, 19, 16, 20, 13, 21, 13, 21,
20, 21, 20, 13, 21, 13, 20, 20, 21, 13, 13, 20, 21, 1,
4, 17, 4, 17, 1, 17, 1, 4, 17, 4, 1, 1, 17, 4, 4, 1,
17, 2, 9, 18, 9, 18, 2, 18, 2, 9, 18, 9, 2, 2, 18, 9,
9, 2, 18, 7, 10, 23, 10, 23, 7, 23, 7, 10, 23, 10, 7,
7, 23, 10, 10, 7, 23, 8, 15, 24, 15, 24, 8, 24, 8, 15,
24, 15, 8, 8, 24, 15, 15, 8, 24, 13, 16, 5, 16, 5, 13,
5, 13, 16, 5, 16, 13, 13, 5, 16, 16, 13, 5, 14, 21, 6,
21, 6, 14, 6, 14, 21, 6, 21, 14, 14, 6, 21, 21, 14, 6,
19, 22, 11, 22, 11, 19, 11, 19, 22, 11, 22, 19, 19,
11, 22, 22, 19, 11, 20, 3, 12, 3, 12, 20, 12, 20, 3,
12, 3, 20, 20, 12, 3, 3, 20, 12, 5, 2, 15, 2, 15, 5,
15, 5, 2, 15, 2, 5, 5, 15, 2, 2, 5, 15, 6, 7, 16, 7,
16, 6, 16, 6, 7, 16, 7, 6, 6, 16, 7, 7, 6, 16, 11, 8,
21, 8, 21, 11, 21, 11, 8, 21, 8, 11, 11, 21, 8, 8, 11,
21, 3, 4, 23, 4, 23, 3, 23, 3, 4, 23, 4, 3, 3, 23, 4,
4, 3, 23, 4, 9, 24, 9, 24, 4, 24, 4, 9, 24, 9, 4, 4,
24, 9, 9, 4, 24, 9, 10, 5, 10, 5, 9, 5, 9, 10, 5, 10,
9, 9, 5, 10, 10, 9, 5, 10, 15, 6, 15, 6, 10, 6, 10,
15, 6, 15, 10, 10, 6, 15, 15, 10, 6, 15, 16, 11, 16,
11, 15, 11, 15, 16, 11, 16, 15, 15, 11, 16, 16, 15,
11, 16, 21, 12, 21, 12, 16, 12, 16, 21, 12, 21, 16,
16, 12, 21, 21, 16, 12, 21, 22, 17, 22, 17, 21, 17,
21, 22, 17, 22, 21, 21, 17, 22, 22, 21, 17, 22, 3, 18,
3, 18, 22, 18, 22, 3, 18, 3, 22, 22, 18, 3, 3, 22, 18,
3, 16, 24, 16, 24, 3, 24, 3, 16, 24, 16, 3, 3, 24, 16,
16, 3, 24, 4, 21, 5, 21, 5, 4, 5, 4, 21, 5, 21, 4, 4,
5, 21, 21, 4, 5, 9, 22, 6, 22, 6, 9, 6, 9, 22, 6, 22,
9, 9, 6, 22, 22, 9, 6, 10, 3, 11, 3, 11, 10, 11, 10,
3, 11, 3, 10, 10, 11, 3, 3, 10, 11, 15, 4, 12, 4, 12,
15, 12, 15, 4, 12, 4, 15, 15, 12, 4, 4, 15, 12, 16, 9,
17, 9, 17, 16, 17, 16, 9, 17, 9, 16, 16, 17, 9, 9, 16,
17, 21, 10, 18, 10, 18, 21, 18, 21, 10, 18, 10, 21,
21, 18, 10, 10, 21, 18, 22, 15, 23, 15, 23, 22, 23,
22, 15, 23, 15, 22, 22, 23, 15, 15, 22, 23, 3, 6, 13,
6, 13, 3, 13, 3, 6, 13, 6, 3, 3, 13, 6, 6, 3, 13, 4,
11, 14, 11, 14, 4, 14, 4, 11, 14, 11, 4, 4, 14, 11,
11, 4, 14, 9, 12, 19, 12, 19, 9, 19, 9, 12, 19, 12, 9,
9, 19, 12, 12, 9, 19, 10, 17, 20, 17, 20, 10, 20, 10,
17, 20, 17, 10, 10, 20, 17, 17, 10, 20, 15, 18, 1, 18,
1, 15, 1, 15, 18, 1, 18, 15, 15, 1, 18, 18, 15, 1, 16,
23, 2, 23, 2, 16, 2, 16, 23, 2, 23, 16, 16, 2, 23, 23,
16, 2, 21, 24, 7, 24, 7, 21, 7, 21, 24, 7, 24, 21, 21,
7, 24, 24, 21, 7, 22, 5, 8, 5, 8, 22, 8, 22, 5, 8, 5,
22, 22, 8, 5, 5, 22, 8, 12, 13, 22, 13, 22, 12, 22,
12, 13, 22, 13, 12, 12, 22, 13, 13, 12, 22, 17, 14, 3,
14, 3, 17, 3, 17, 14, 3, 14, 17, 17, 3, 14, 14, 17, 3,
18, 19, 4, 19, 4, 18, 4, 18, 19, 4, 19, 18, 18, 4, 19,
19, 18, 4, 1, 3, 5, 3, 5, 1, 5, 1, 3, 5, 3, 1, 1, 5,
3, 3, 1, 5, 2, 4, 6, 4, 6, 2, 6, 2, 4, 6, 4, 2, 2, 6,
4, 4, 2, 6, 7, 9, 11, 9, 11, 7, 11, 7, 9, 11, 9, 7, 7,
11, 9, 9, 7, 11, 8, 10, 12, 10, 12, 8, 12, 8, 10, 12,
10, 8, 8, 12, 10, 10, 8, 12, 13, 15, 17, 15, 17, 13,
17, 13, 15, 17, 15, 13, 13, 17, 15, 15, 13, 17, 14,
16, 18, 16, 18, 14, 18, 14, 16, 18, 16, 14, 14, 18,
16, 16, 14, 18, 19, 21, 23, 21, 23, 19, 23, 19, 21,
23, 21, 19, 19, 23, 21, 21, 19, 23, 20, 22, 24, 22,
24, 20, 24, 20, 22, 24, 22, 20, 20, 24, 22, 22, 20,
24, 5, 6, 19, 6, 19, 5, 19, 5, 6, 19, 6, 5, 5, 19, 6,
6, 5, 19, 6, 11, 20, 11, 20, 6, 20, 6, 11, 20, 11, 6,
6, 20, 11, 11, 6, 20, 11, 12, 1, 12, 1, 11, 1, 11, 12,
1, 12, 11, 11, 1, 12, 12, 11, 1, 12, 17, 2, 17, 2, 12,
2, 12, 17, 2, 17, 12, 12, 2, 17, 17, 12, 2, 17, 18, 7,
18, 7, 17, 7, 17, 18, 7, 18, 17, 17, 7, 18, 18, 17, 7,
18, 23, 8, 23, 8, 18, 8, 18, 23, 8, 23, 18, 18, 8, 23,
23, 18, 8, 23, 24, 13, 24, 13, 23, 13, 23, 24, 13, 24,
23, 23, 13, 24, 24, 23, 13, 24, 5, 14, 5, 14, 24, 14,
24, 5, 14, 5, 24, 24, 14, 5, 5, 24, 14, 5, 18, 20, 18,
20, 5, 20, 5, 18, 20, 18, 5, 5, 20, 18, 18, 5, 20, 6,
23, 1, 23, 1, 6, 1, 6, 23, 1, 23, 6, 6, 1, 23, 23, 6,
1, 11, 24, 2, 24, 2, 11, 2, 11, 24, 2, 24, 11, 11, 2,
24, 24, 11, 2, 12, 5, 7, 5, 7, 12, 7, 12, 5, 7, 5, 12,
12, 7, 5, 5, 12, 7, 17, 6, 8, 6, 8, 17, 8, 17, 6, 8,
6, 17, 17, 8, 6, 6, 17, 8, 18, 11, 13, 11, 13, 18, 13,
18, 11, 13, 11, 18, 18, 13, 11, 11, 18, 13, 23, 12,
14, 12, 14, 23, 14, 23, 12, 14, 12, 23, 23, 14, 12,
12, 23, 14, 24, 17, 19, 17, 19, 24, 19, 24, 17, 19,
17, 24, 24, 19, 17, 17, 24, 19, 23, 20, 9, 20, 9, 23,
9, 23, 20, 9, 20, 23, 23, 9, 20, 20, 23, 9, 24, 1, 10,
1, 10, 24, 10, 24, 1, 10, 1, 24, 24, 10, 1, 1, 24,
10), 480, 3, byrow = T)
} else if (all(williams_D == 3, selection == 18, type == "SR")) {
sequences <- matrix(c(1, 2, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1, 1, 3, 2, 2, 1, 3,
1, 5, 6, 5, 6, 1, 6, 1, 5, 6, 5, 1, 1, 6, 5, 5, 1, 6,
2, 4, 6, 4, 6, 2, 6, 2, 4, 6, 4, 2, 2, 6, 4, 4, 2, 6,
3, 4, 5, 4, 5, 3, 5, 3, 4, 5, 4, 3, 3, 5, 4, 4, 3, 5),
24, 3, byrow = T)
} else if (all(williams_D == 3, selection == 19, type == "SR")) {
sequences <- matrix(c(1, 2, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1, 1, 3, 2, 2, 1, 3,
4, 5, 6, 5, 6, 4, 6, 4, 5, 6, 5, 4, 4, 6, 5, 5, 4, 6,
1, 5, 3, 5, 3, 1, 3, 1, 5, 3, 5, 1, 1, 3, 5, 5, 1, 3,
4, 2, 6, 2, 6, 4, 6, 4, 2, 6, 2, 4, 4, 6, 2, 2, 4, 6,
1, 2, 6, 2, 6, 1, 6, 1, 2, 6, 2, 1, 1, 6, 2, 2, 1, 6,
4, 5, 3, 5, 3, 4, 3, 4, 5, 3, 5, 4, 4, 3, 5, 5, 4, 3,
1, 5, 6, 5, 6, 1, 6, 1, 5, 6, 5, 1, 1, 6, 5, 5, 1, 6,
4, 2, 3, 2, 3, 4, 3, 4, 2, 3, 2, 4, 4, 3, 2, 2, 4, 3),
48, 3, byrow = T)
} else if (all(williams_D == 3, selection == 23, type == "SR")) {
sequences <- matrix(c(1, 2, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1, 1, 3, 2, 2, 1, 3,
4, 5, 6, 5, 6, 4, 6, 4, 5, 6, 5, 4, 4, 6, 5, 5, 4, 6,
7, 8, 9, 8, 9, 7, 9, 7, 8, 9, 8, 7, 7, 9, 8, 8, 7, 9,
1, 5, 9, 5, 9, 1, 9, 1, 5, 9, 5, 1, 1, 9, 5, 5, 1, 9,
2, 6, 7, 6, 7, 2, 7, 2, 6, 7, 6, 2, 2, 7, 6, 6, 2, 7,
3, 4, 8, 4, 8, 3, 8, 3, 4, 8, 4, 3, 3, 8, 4, 4, 3, 8,
1, 6, 8, 6, 8, 1, 8, 1, 6, 8, 6, 1, 1, 8, 6, 6, 1, 8,
2, 4, 9, 4, 9, 2, 9, 2, 4, 9, 4, 2, 2, 9, 4, 4, 2, 9,
3, 5, 7, 5, 7, 3, 7, 3, 5, 7, 5, 3, 3, 7, 5, 5, 3, 7),
54, 3, byrow = T)
} else if (all(williams_D == 3, selection == 25, type == "SR")) {
sequences <- matrix(c(1, 2, 3, 2, 3, 1, 3, 1, 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, 4, 6, 4, 2, 2, 6, 4, 4, 2, 6,
5, 7, 9, 7, 9, 5, 9, 5, 7, 9, 7, 5, 5, 9, 7, 7, 5, 9,
1, 6, 8, 6, 8, 1, 8, 1, 6, 8, 6, 1, 1, 8, 6, 6, 1, 8,
2, 4, 9, 4, 9, 2, 9, 2, 4, 9, 4, 2, 2, 9, 4, 4, 2, 9,
3, 5, 7, 5, 7, 3, 7, 3, 5, 7, 5, 3, 3, 7, 5, 5, 3, 7,
1, 8, 9, 8, 9, 1, 9, 1, 8, 9, 8, 1, 1, 9, 8, 8, 1, 9,
2, 3, 4, 3, 4, 2, 4, 2, 3, 4, 3, 2, 2, 4, 3, 3, 2, 4,
5, 6, 7, 6, 7, 5, 7, 5, 6, 7, 6, 5, 5, 7, 6, 6, 5, 7),
162, 3, byrow = T)
} else if (all(williams_D == 3, selection == 26, type == "SR")) {
sequences <- matrix(c(1, 2, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1, 1, 3, 2, 2, 1, 3,
12, 8, 7, 8, 7, 12, 7, 12, 8, 7, 8, 12, 12, 7, 8, 8,
12, 7, 9, 10, 5, 10, 5, 9, 5, 9, 10, 5, 10, 9, 9, 5,
10, 10, 9, 5, 11, 4, 6, 4, 6, 11, 6, 11, 4, 6, 4, 11,
11, 6, 4, 4, 11, 6, 1, 5, 6, 5, 6, 1, 6, 1, 5, 6, 5,
1, 1, 6, 5, 5, 1, 6, 8, 3, 4, 3, 4, 8, 4, 8, 3, 4, 3,
8, 8, 4, 3, 3, 8, 4, 9, 11, 7, 11, 7, 9, 7, 9, 11, 7,
11, 9, 9, 7, 11, 11, 9, 7, 2, 12, 10, 12, 10, 2, 10,
2, 12, 10, 12, 2, 2, 10, 12, 12, 2, 10, 1, 12, 11, 12,
11, 1, 11, 1, 12, 11, 12, 1, 1, 11, 12, 12, 1, 11, 5,
7, 3, 7, 3, 5, 3, 5, 7, 3, 7, 5, 5, 3, 7, 7, 5, 3, 6,
10, 8, 10, 8, 6, 8, 6, 10, 8, 10, 6, 6, 8, 10, 10, 6,
8, 4, 2, 9, 2, 9, 4, 9, 4, 2, 9, 2, 4, 4, 9, 2, 2, 4,
9, 1, 8, 9, 8, 9, 1, 9, 1, 8, 9, 8, 1, 1, 9, 8, 8, 1,
9, 7, 6, 2, 6, 2, 7, 2, 7, 6, 2, 6, 7, 7, 2, 6, 6, 7,
2, 10, 11, 3, 11, 3, 10, 3, 10, 11, 3, 11, 10, 10, 3,
11, 11, 10, 3, 4, 12, 5, 12, 5, 4, 5, 4, 12, 5, 12, 4,
4, 5, 12, 12, 4, 5), 96, 3, byrow = T)
} else if (all(williams_D == 4, selection == 94, type == "R")) {
sequences <- matrix(c(1, 2, 6, 4, 2, 4, 1, 6, 4, 6, 2, 1, 6, 1, 4, 2, 2, 3,
1, 5, 3, 5, 2, 1, 5, 1, 3, 2, 1, 2, 5, 3, 3, 4, 2, 6,
4, 6, 3, 2, 6, 2, 4, 3, 2, 3, 6, 4, 4, 5, 3, 1, 5, 1,
4, 3, 1, 3, 5, 4, 3, 4, 1, 5, 5, 6, 4, 2, 6, 2, 5, 4,
2, 4, 6, 5, 4, 5, 2, 6, 6, 1, 5, 3, 1, 3, 6, 5, 3, 5,
1, 6, 5, 6, 3, 1), 24, 4, byrow = T)
} else if (all(williams_D == 4, selection == 95, type == "R")) {
sequences <- matrix(c(1, 2, 6, 4, 2, 4, 1, 6, 4, 6, 2, 1, 6, 1, 4, 2, 3, 4,
2, 6, 4, 6, 3, 2, 6, 2, 4, 3, 2, 3, 6, 4, 5, 6, 4, 2,
6, 2, 5, 4, 2, 4, 6, 5, 4, 5, 2, 6, 2, 1, 5, 3, 1, 3,
2, 5, 3, 5, 1, 2, 5, 2, 3, 1, 4, 3, 1, 5, 3, 5, 4, 1,
5, 1, 3, 4, 1, 4, 5, 3, 6, 5, 3, 1, 5, 1, 6, 3, 1, 3,
5, 6, 3, 6, 1, 5, 1, 2, 6, 4, 2, 4, 1, 6, 4, 6, 2, 1,
6, 1, 4, 2, 3, 4, 2, 6, 4, 6, 3, 2, 6, 2, 4, 3, 2, 3,
6, 4, 5, 6, 4, 2, 6, 2, 5, 4, 2, 4, 6, 5, 4, 5, 2, 6,
2, 1, 5, 3, 1, 3, 2, 5, 3, 5, 1, 2, 5, 2, 3, 1, 4, 3,
1, 5, 3, 5, 4, 1, 5, 1, 3, 4, 1, 4, 5, 3, 6, 5, 3, 1,
5, 1, 6, 3, 1, 3, 5, 6, 3, 6, 1, 5), 48, 4, byrow = T)
} else if (all(williams_D == 4, selection == 96, type == "R")) {
sequences <- matrix(c(3, 6, 4, 5, 6, 5, 3, 4, 5, 4, 6, 3, 4, 3, 5, 6, 4, 1,
2, 6, 1, 6, 4, 2, 6, 2, 1, 4, 2, 4, 6, 1, 1, 5, 3, 2,
5, 2, 1, 3, 2, 3, 5, 1, 3, 1, 2, 5, 5, 6, 4, 2, 6, 2,
5, 4, 2, 4, 6, 5, 4, 5, 2, 6, 5, 1, 3, 6, 1, 6, 5, 3,
6, 3, 1, 5, 3, 5, 6, 1, 4, 2, 1, 3, 2, 3, 4, 1, 3, 1,
2, 4, 1, 4, 3, 2, 2, 3, 5, 4, 3, 4, 2, 5, 4, 5, 3, 2,
5, 2, 4, 3, 1, 4, 6, 5, 4, 5, 1, 6, 5, 6, 4, 1, 6, 1,
5, 4, 6, 2, 1, 3, 2, 3, 6, 1, 3, 1, 2, 6, 1, 6, 3, 2,
2, 3, 6, 4, 3, 4, 2, 6, 4, 6, 3, 2, 6, 2, 4, 3, 3, 4,
5, 1, 4, 1, 3, 5, 1, 5, 4, 3, 5, 3, 1, 4, 6, 5, 2, 1,
5, 1, 6, 2, 1, 2, 5, 6, 2, 6, 1, 5), 48, 4, byrow = T)
} else if (all(williams_D == 4, selection == 97, type == "R")) {
sequences <- matrix(c(1, 5, 4, 3, 5, 3, 1, 4, 3, 4, 5, 1, 4, 1, 3, 5, 1, 5,
8, 7, 5, 7, 1, 8, 7, 8, 5, 1, 8, 1, 7, 5, 2, 6, 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5, 2, 6,
7, 3, 6, 3, 2, 7, 3, 7, 6, 2, 7, 2, 3, 6), 80, 4,
byrow = T)
} else if (all(williams_D == 4, selection == 104, type == "R")) {
sequences <- matrix(c(1, 4, 2, 7, 4, 7, 1, 2, 7, 2, 4, 1, 2, 1, 7, 4, 2, 5,
3, 8, 5, 8, 2, 3, 8, 3, 5, 2, 3, 2, 8, 5, 3, 6, 4, 9,
6, 9, 3, 4, 9, 4, 6, 3, 4, 3, 9, 6, 4, 7, 5, 1, 7, 1,
4, 5, 1, 5, 7, 4, 5, 4, 1, 7, 5, 8, 6, 2, 8, 2, 5, 6,
2, 6, 8, 5, 6, 5, 2, 8, 6, 9, 7, 3, 9, 3, 6, 7, 3, 7,
9, 6, 7, 6, 3, 9, 7, 1, 8, 4, 1, 4, 7, 8, 4, 8, 1, 7,
8, 7, 4, 1, 8, 2, 9, 5, 2, 5, 8, 9, 5, 9, 2, 8, 9, 8,
5, 2, 9, 3, 1, 6, 3, 6, 9, 1, 6, 1, 3, 9, 1, 9, 6, 3),
36, 4, byrow = T)
} else if (all(williams_D == 4, selection == 106, type == "R")) {
sequences <- matrix(c(1, 7, 10, 8, 7, 8, 1, 10, 8, 10, 7, 1, 10, 1, 8, 7, 2,
8, 6, 9, 8, 9, 2, 6, 9, 6, 8, 2, 6, 2, 9, 8, 3, 9, 7,
10, 9, 10, 3, 7, 10, 7, 9, 3, 7, 3, 10, 9, 4, 10, 8,
6, 10, 6, 4, 8, 6, 8, 10, 4, 8, 4, 6, 10, 5, 6, 9, 7,
6, 7, 5, 9, 7, 9, 6, 5, 9, 5, 7, 6, 6, 2, 5, 3, 2, 3,
6, 5, 3, 5, 2, 6, 5, 6, 3, 2, 7, 3, 1, 4, 3, 4, 7, 1,
4, 1, 3, 7, 1, 7, 4, 3, 8, 4, 2, 5, 4, 5, 8, 2, 5, 2,
4, 8, 2, 8, 5, 4, 9, 5, 3, 1, 5, 1, 9, 3, 1, 3, 5, 9,
3, 9, 1, 5, 10, 1, 4, 2, 1, 2, 10, 4, 2, 4, 1, 10, 4,
10, 2, 1, 1, 8, 10, 9, 8, 9, 1, 10, 9, 10, 8, 1, 10,
1, 9, 8, 2, 9, 6, 10, 9, 10, 2, 6, 10, 6, 9, 2, 6, 2,
10, 9, 3, 10, 7, 6, 10, 6, 3, 7, 6, 7, 10, 3, 7, 3, 6,
10, 4, 6, 8, 7, 6, 7, 4, 8, 7, 8, 6, 4, 8, 4, 7, 6, 5,
7, 9, 8, 7, 8, 5, 9, 8, 9, 7, 5, 9, 5, 8, 7, 6, 3, 5,
4, 3, 4, 6, 5, 4, 5, 3, 6, 5, 6, 4, 3, 7, 4, 1, 5, 4,
5, 7, 1, 5, 1, 4, 7, 1, 7, 5, 4, 8, 5, 2, 1, 5, 1, 8,
2, 1, 2, 5, 8, 2, 8, 1, 5, 9, 1, 3, 2, 1, 2, 9, 3, 2,
3, 1, 9, 3, 9, 2, 1, 10, 2, 4, 3, 2, 3, 10, 4, 3, 4,
2, 10, 4, 10, 3, 2), 80, 4, byrow = T)
} else if (all(williams_D == 4, selection == 109, type == "R")) {
sequences <- matrix(c(1, 2, 7, 5, 2, 5, 1, 7, 5, 7, 2, 1, 7, 1, 5, 2, 2, 3,
8, 6, 3, 6, 2, 8, 6, 8, 3, 2, 8, 2, 6, 3, 3, 4, 9, 7,
4, 7, 3, 9, 7, 9, 4, 3, 9, 3, 7, 4, 4, 5, 10, 8, 5, 8,
4, 10, 8, 10, 5, 4, 10, 4, 8, 5, 5, 6, 11, 9, 6, 9, 5,
11, 9, 11, 6, 5, 11, 5, 9, 6, 6, 7, 12, 10, 7, 10, 6,
12, 10, 12, 7, 6, 12, 6, 10, 7, 7, 8, 1, 11, 8, 11, 7,
1, 11, 1, 8, 7, 1, 7, 11, 8, 8, 9, 2, 12, 9, 12, 8, 2,
12, 2, 9, 8, 2, 8, 12, 9, 9, 10, 3, 1, 10, 1, 9, 3, 1,
3, 10, 9, 3, 9, 1, 10, 10, 11, 4, 2, 11, 2, 10, 4, 2,
4, 11, 10, 4, 10, 2, 11, 11, 12, 5, 3, 12, 3, 11, 5,
3, 5, 12, 11, 5, 11, 3, 12, 12, 1, 6, 4, 1, 4, 12, 6,
4, 6, 1, 12, 6, 12, 4, 1), 48, 4, byrow = T)
} else if (all(williams_D == 4, selection == 111, type == "R")) {
sequences <- matrix(c(1, 3, 5, 7, 3, 7, 1, 5, 7, 5, 3, 1, 5, 1, 7, 3, 4, 6,
2, 10, 6, 10, 4, 2, 10, 2, 6, 4, 2, 4, 10, 6, 8, 9, 6,
7, 9, 7, 8, 6, 7, 6, 9, 8, 6, 8, 7, 9, 11, 12, 3, 10,
12, 10, 11, 3, 10, 3, 12, 11, 3, 11, 10, 12, 8, 11, 4,
1, 11, 1, 8, 4, 1, 4, 11, 8, 4, 8, 1, 11, 9, 12, 5, 2,
12, 2, 9, 5, 2, 5, 12, 9, 5, 9, 2, 12, 9, 2, 4, 3, 2,
3, 9, 4, 3, 4, 2, 9, 4, 9, 3, 2, 6, 11, 7, 12, 11, 12,
6, 7, 12, 7, 11, 6, 7, 6, 12, 11, 10, 12, 8, 4, 12, 4,
10, 8, 4, 8, 12, 10, 8, 10, 4, 12, 1, 2, 11, 9, 2, 9,
1, 11, 9, 11, 2, 1, 11, 1, 9, 2, 7, 8, 5, 3, 8, 3, 7,
5, 3, 5, 8, 7, 5, 7, 3, 8, 6, 10, 1, 5, 10, 5, 6, 1,
5, 1, 10, 6, 1, 6, 5, 10, 3, 8, 10, 9, 8, 9, 3, 10, 9,
10, 8, 3, 10, 3, 9, 8, 7, 9, 11, 1, 9, 1, 7, 11, 1,
11, 9, 7, 11, 7, 1, 9, 12, 5, 1, 6, 5, 6, 12, 1, 6, 1,
5, 12, 1, 12, 6, 5, 3, 7, 4, 2, 7, 2, 3, 4, 2, 4, 7,
3, 4, 3, 2, 7, 4, 5, 8, 12, 5, 12, 4, 8, 12, 8, 5, 4,
8, 4, 12, 5, 10, 11, 2, 6, 11, 6, 10, 2, 6, 2, 11, 10,
2, 10, 6, 11, 2, 7, 6, 8, 7, 8, 2, 6, 8, 6, 7, 2, 6,
2, 8, 7, 5, 10, 3, 11, 10, 11, 5, 3, 11, 3, 10, 5, 3,
5, 11, 10, 2, 3, 12, 1, 3, 1, 2, 12, 1, 12, 3, 2, 12,
2, 1, 3, 9, 1, 10, 8, 1, 8, 9, 10, 8, 10, 1, 9, 10, 9,
8, 1, 5, 6, 9, 4, 6, 4, 5, 9, 4, 9, 6, 5, 9, 5, 4, 6,
12, 4, 7, 11, 4, 11, 12, 7, 11, 7, 4, 12, 7, 12, 11,
4, 8, 1, 12, 2, 1, 2, 8, 12, 2, 12, 1, 8, 12, 8, 2, 1,
11, 4, 9, 5, 4, 5, 11, 9, 5, 9, 4, 11, 9, 11, 5, 4, 1,
4, 6, 3, 4, 3, 1, 6, 3, 6, 4, 1, 6, 1, 3, 4, 2, 5, 10,
7, 5, 7, 2, 10, 7, 10, 5, 2, 10, 2, 7, 5, 3, 6, 11, 8,
6, 8, 3, 11, 8, 11, 6, 3, 11, 3, 8, 6, 7, 10, 12, 9,
10, 9, 7, 12, 9, 12, 10, 7, 12, 7, 9, 10), 120, 4,
byrow = T)
} else if (all(williams_D == 4, selection == 112, type == "R")) {
sequences <- matrix(c(1, 2, 7, 5, 2, 5, 1, 7, 5, 7, 2, 1, 7, 1, 5, 2, 2, 3,
8, 6, 3, 6, 2, 8, 6, 8, 3, 2, 8, 2, 6, 3, 3, 4, 9, 7,
4, 7, 3, 9, 7, 9, 4, 3, 9, 3, 7, 4, 4, 5, 10, 8, 5, 8,
4, 10, 8, 10, 5, 4, 10, 4, 8, 5, 5, 6, 11, 9, 6, 9, 5,
11, 9, 11, 6, 5, 11, 5, 9, 6, 6, 7, 12, 10, 7, 10, 6,
12, 10, 12, 7, 6, 12, 6, 10, 7, 7, 8, 13, 11, 8, 11,
7, 13, 11, 13, 8, 7, 13, 7, 11, 8, 8, 9, 14, 12, 9,
12, 8, 14, 12, 14, 9, 8, 14, 8, 12, 9, 9, 10, 1, 13,
10, 13, 9, 1, 13, 1, 10, 9, 1, 9, 13, 10, 10, 11, 2,
14, 11, 14, 10, 2, 14, 2, 11, 10, 2, 10, 14, 11, 11,
12, 3, 1, 12, 1, 11, 3, 1, 3, 12, 11, 3, 11, 1, 12,
12, 13, 4, 2, 13, 2, 12, 4, 2, 4, 13, 12, 4, 12, 2,
13, 13, 14, 5, 3, 14, 3, 13, 5, 3, 5, 14, 13, 5, 13,
3, 14, 14, 1, 6, 4, 1, 4, 14, 6, 4, 6, 1, 14, 6, 14,
4, 1), 56, 4, byrow = T)
} else if (all(williams_D == 4, selection == 114, type == "R")) {
sequences <- matrix(c(2, 4, 13, 5, 4, 5, 2, 13, 5, 13, 4, 2, 13, 2, 5, 4, 3,
5, 14, 6, 5, 6, 3, 14, 6, 14, 5, 3, 14, 3, 6, 5, 4, 6,
15, 7, 6, 7, 4, 15, 7, 15, 6, 4, 15, 4, 7, 6, 5, 7, 1,
8, 7, 8, 5, 1, 8, 1, 7, 5, 1, 5, 8, 7, 6, 8, 2, 9, 8,
9, 6, 2, 9, 2, 8, 6, 2, 6, 9, 8, 7, 9, 3, 10, 9, 10,
7, 3, 10, 3, 9, 7, 3, 7, 10, 9, 8, 10, 4, 11, 10, 11,
8, 4, 11, 4, 10, 8, 4, 8, 11, 10, 9, 11, 5, 12, 11,
12, 9, 5, 12, 5, 11, 9, 5, 9, 12, 11, 10, 12, 6, 13,
12, 13, 10, 6, 13, 6, 12, 10, 6, 10, 13, 12, 11, 13,
7, 14, 13, 14, 11, 7, 14, 7, 13, 11, 7, 11, 14, 13,
12, 14, 8, 15, 14, 15, 12, 8, 15, 8, 14, 12, 8, 12,
15, 14, 13, 15, 9, 1, 15, 1, 13, 9, 1, 9, 15, 13, 9,
13, 1, 15, 14, 1, 10, 2, 1, 2, 14, 10, 2, 10, 1, 14,
10, 14, 2, 1, 15, 2, 11, 3, 2, 3, 15, 11, 3, 11, 2,
15, 11, 15, 3, 2, 1, 3, 12, 4, 3, 4, 1, 12, 4, 12, 3,
1, 12, 1, 4, 3), 60, 4, byrow = T)
} else if (all(williams_D == 4, selection == 115, type == "R")) {
sequences <- matrix(c(1, 6, 2, 11, 6, 11, 1, 2, 11, 2, 6, 1, 2, 1, 11, 6, 2,
7, 3, 12, 7, 12, 2, 3, 12, 3, 7, 2, 3, 2, 12, 7, 3, 8,
4, 13, 8, 13, 3, 4, 13, 4, 8, 3, 4, 3, 13, 8, 4, 9, 5,
14, 9, 14, 4, 5, 14, 5, 9, 4, 5, 4, 14, 9, 5, 10, 1,
15, 10, 15, 5, 1, 15, 1, 10, 5, 1, 5, 15, 10, 7, 1,
11, 6, 1, 6, 7, 11, 6, 11, 1, 7, 11, 7, 6, 1, 8, 2,
12, 7, 2, 7, 8, 12, 7, 12, 2, 8, 12, 8, 7, 2, 9, 3,
13, 8, 3, 8, 9, 13, 8, 13, 3, 9, 13, 9, 8, 3, 10, 4,
14, 9, 4, 9, 10, 14, 9, 14, 4, 10, 14, 10, 9, 4, 6, 5,
15, 10, 5, 10, 6, 15, 10, 15, 5, 6, 15, 6, 10, 5, 11,
12, 6, 1, 12, 1, 11, 6, 1, 6, 12, 11, 6, 11, 1, 12,
12, 13, 7, 2, 13, 2, 12, 7, 2, 7, 13, 12, 7, 12, 2,
13, 13, 14, 8, 3, 14, 3, 13, 8, 3, 8, 14, 13, 8, 13,
3, 14, 14, 15, 9, 4, 15, 4, 14, 9, 4, 9, 15, 14, 9,
14, 4, 15, 15, 11, 10, 5, 11, 5, 15, 10, 5, 10, 11,
15, 10, 15, 5, 11, 1, 6, 3, 11, 6, 11, 1, 3, 11, 3, 6,
1, 3, 1, 11, 6, 2, 7, 4, 12, 7, 12, 2, 4, 12, 4, 7, 2,
4, 2, 12, 7, 3, 8, 5, 13, 8, 13, 3, 5, 13, 5, 8, 3, 5,
3, 13, 8, 4, 9, 1, 14, 9, 14, 4, 1, 14, 1, 9, 4, 1, 4,
14, 9, 5, 10, 2, 15, 10, 15, 5, 2, 15, 2, 10, 5, 2, 5,
15, 10, 8, 1, 11, 6, 1, 6, 8, 11, 6, 11, 1, 8, 11, 8,
6, 1, 9, 2, 12, 7, 2, 7, 9, 12, 7, 12, 2, 9, 12, 9, 7,
2, 10, 3, 13, 8, 3, 8, 10, 13, 8, 13, 3, 10, 13, 10,
8, 3, 6, 4, 14, 9, 4, 9, 6, 14, 9, 14, 4, 6, 14, 6, 9,
4, 7, 5, 15, 10, 5, 10, 7, 15, 10, 15, 5, 7, 15, 7,
10, 5, 13, 11, 6, 1, 11, 1, 13, 6, 1, 6, 11, 13, 6,
13, 1, 11, 14, 12, 7, 2, 12, 2, 14, 7, 2, 7, 12, 14,
7, 14, 2, 12, 15, 13, 8, 3, 13, 3, 15, 8, 3, 8, 13,
15, 8, 15, 3, 13, 11, 14, 9, 4, 14, 4, 11, 9, 4, 9,
14, 11, 9, 11, 4, 14, 12, 15, 10, 5, 15, 5, 12, 10, 5,
10, 15, 12, 10, 12, 5, 15), 120, 4, byrow = T)
} else if (all(williams_D == 4, selection == 117, type == "R")) {
sequences <- matrix(c(1, 13, 9, 8, 13, 8, 1, 9, 8, 9, 13, 1, 9, 1, 8, 13, 4,
1, 12, 11, 1, 11, 4, 12, 11, 12, 1, 4, 12, 4, 11, 1,
7, 4, 15, 14, 4, 14, 7, 15, 14, 15, 4, 7, 15, 7, 14,
4, 10, 7, 3, 2, 7, 2, 10, 3, 2, 3, 7, 10, 3, 10, 2, 7,
13, 10, 6, 5, 10, 5, 13, 6, 5, 6, 10, 13, 6, 13, 5,
10, 2, 14, 7, 9, 14, 9, 2, 7, 9, 7, 14, 2, 7, 2, 9,
14, 5, 2, 10, 12, 2, 12, 5, 10, 12, 10, 2, 5, 10, 5,
12, 2, 8, 5, 13, 15, 5, 15, 8, 13, 15, 13, 5, 8, 13,
8, 15, 5, 11, 8, 1, 3, 8, 3, 11, 1, 3, 1, 8, 11, 1,
11, 3, 8, 14, 11, 4, 6, 11, 6, 14, 4, 6, 4, 11, 14, 4,
14, 6, 11, 3, 15, 8, 7, 15, 7, 3, 8, 7, 8, 15, 3, 8,
3, 7, 15, 6, 3, 11, 10, 3, 10, 6, 11, 10, 11, 3, 6,
11, 6, 10, 3, 9, 6, 14, 13, 6, 13, 9, 14, 13, 14, 6,
9, 14, 9, 13, 6, 12, 9, 2, 1, 9, 1, 12, 2, 1, 2, 9,
12, 2, 12, 1, 9, 15, 12, 5, 4, 12, 4, 15, 5, 4, 5, 12,
15, 5, 15, 4, 12, 1, 7, 6, 5, 7, 5, 1, 6, 5, 6, 7, 1,
6, 1, 5, 7, 4, 10, 9, 8, 10, 8, 4, 9, 8, 9, 10, 4, 9,
4, 8, 10, 7, 13, 12, 11, 13, 11, 7, 12, 11, 12, 13, 7,
12, 7, 11, 13, 10, 1, 15, 14, 1, 14, 10, 15, 14, 15,
1, 10, 15, 10, 14, 1, 13, 4, 3, 2, 4, 2, 13, 3, 2, 3,
4, 13, 3, 13, 2, 4, 2, 8, 4, 6, 8, 6, 2, 4, 6, 4, 8,
2, 4, 2, 6, 8, 5, 11, 7, 9, 11, 9, 5, 7, 9, 7, 11, 5,
7, 5, 9, 11, 8, 14, 10, 12, 14, 12, 8, 10, 12, 10, 14,
8, 10, 8, 12, 14, 11, 2, 13, 15, 2, 15, 11, 13, 15,
13, 2, 11, 13, 11, 15, 2, 14, 5, 1, 3, 5, 3, 14, 1, 3,
1, 5, 14, 1, 14, 3, 5, 3, 9, 5, 4, 9, 4, 3, 5, 4, 5,
9, 3, 5, 3, 4, 9, 6, 12, 8, 7, 12, 7, 6, 8, 7, 8, 12,
6, 8, 6, 7, 12, 9, 15, 11, 10, 15, 10, 9, 11, 10, 11,
15, 9, 11, 9, 10, 15, 12, 3, 14, 13, 3, 13, 12, 14,
13, 14, 3, 12, 14, 12, 13, 3, 15, 6, 2, 1, 6, 1, 15,
2, 1, 2, 6, 15, 2, 15, 1, 6), 120, 4, byrow = T)
} else if (all(williams_D == 4, selection == 118, type == "R")) {
sequences <- matrix(c(1, 2, 9, 6, 2, 6, 1, 9, 6, 9, 2, 1, 9, 1, 6, 2, 3, 4,
11, 8, 4, 8, 3, 11, 8, 11, 4, 3, 11, 3, 8, 4, 5, 10,
14, 13, 10, 13, 5, 14, 13, 14, 10, 5, 14, 5, 13, 10,
7, 12, 16, 15, 12, 15, 7, 16, 15, 16, 12, 7, 16, 7,
15, 12, 2, 5, 13, 6, 5, 6, 2, 13, 6, 13, 5, 2, 13, 2,
6, 5, 4, 7, 15, 8, 7, 8, 4, 15, 8, 15, 7, 4, 15, 4, 8,
7, 1, 9, 14, 10, 9, 10, 1, 14, 10, 14, 9, 1, 14, 1,
10, 9, 3, 11, 16, 12, 11, 12, 3, 16, 12, 16, 11, 3,
16, 3, 12, 11, 15, 13, 1, 3, 13, 3, 15, 1, 3, 1, 13,
15, 1, 15, 3, 13, 16, 14, 2, 4, 14, 4, 16, 2, 4, 2,
14, 16, 2, 16, 4, 14, 5, 7, 11, 9, 7, 9, 5, 11, 9, 11,
7, 5, 11, 5, 9, 7, 6, 8, 12, 10, 8, 10, 6, 12, 10, 12,
8, 6, 12, 6, 10, 8, 2, 3, 10, 7, 3, 7, 2, 10, 7, 10,
3, 2, 10, 2, 7, 3, 1, 4, 12, 5, 4, 5, 1, 12, 5, 12, 4,
1, 12, 1, 5, 4, 6, 11, 15, 14, 11, 14, 6, 15, 14, 15,
11, 6, 15, 6, 14, 11, 8, 9, 16, 13, 9, 13, 8, 16, 13,
16, 9, 8, 16, 8, 13, 9, 14, 6, 3, 7, 6, 7, 14, 3, 7,
3, 6, 14, 3, 14, 7, 6, 16, 8, 1, 5, 8, 5, 16, 1, 5, 1,
8, 16, 1, 16, 5, 8, 15, 10, 2, 11, 10, 11, 15, 2, 11,
2, 10, 15, 2, 15, 11, 10, 13, 12, 4, 9, 12, 9, 13, 4,
9, 4, 12, 13, 4, 13, 9, 12, 16, 10, 4, 6, 10, 6, 16,
4, 6, 4, 10, 16, 4, 16, 6, 10, 15, 9, 3, 5, 9, 5, 15,
3, 5, 3, 9, 15, 3, 15, 5, 9, 13, 11, 1, 7, 11, 7, 13,
1, 7, 1, 11, 13, 1, 13, 7, 11, 14, 12, 2, 8, 12, 8,
14, 2, 8, 2, 12, 14, 2, 14, 8, 12), 96, 4, byrow = T)
} else if (all(williams_D == 4, selection == 119, type == "R")) {
sequences <- matrix(c(1, 2, 4, 3, 2, 3, 1, 4, 3, 4, 2, 1, 4, 1, 3, 2, 5, 6,
8, 7, 6, 7, 5, 8, 7, 8, 6, 5, 8, 5, 7, 6, 9, 10, 12,
11, 10, 11, 9, 12, 11, 12, 10, 9, 12, 9, 11, 10, 13,
14, 16, 15, 14, 15, 13, 16, 15, 16, 14, 13, 16, 13,
15, 14, 1, 5, 13, 9, 5, 9, 1, 13, 9, 13, 5, 1, 13, 1,
9, 5, 2, 6, 14, 10, 6, 10, 2, 14, 10, 14, 6, 2, 14, 2,
10, 6, 3, 7, 15, 11, 7, 11, 3, 15, 11, 15, 7, 3, 15,
3, 11, 7, 4, 8, 16, 12, 8, 12, 4, 16, 12, 16, 8, 4,
16, 4, 12, 8, 1, 5, 13, 9, 5, 9, 1, 13, 9, 13, 5, 1,
13, 1, 9, 5, 2, 6, 14, 10, 6, 10, 2, 14, 10, 14, 6, 2,
14, 2, 10, 6, 3, 7, 15, 11, 7, 11, 3, 15, 11, 15, 7,
3, 15, 3, 11, 7, 4, 8, 16, 12, 8, 12, 4, 16, 12, 16,
8, 4, 16, 4, 12, 8, 1, 5, 13, 9, 5, 9, 1, 13, 9, 13,
5, 1, 13, 1, 9, 5, 2, 6, 14, 10, 6, 10, 2, 14, 10, 14,
6, 2, 14, 2, 10, 6, 3, 7, 15, 11, 7, 11, 3, 15, 11,
15, 7, 3, 15, 3, 11, 7, 4, 8, 16, 12, 8, 12, 4, 16,
12, 16, 8, 4, 16, 4, 12, 8, 1, 6, 16, 11, 6, 11, 1,
16, 11, 16, 6, 1, 16, 1, 11, 6, 2, 5, 15, 12, 5, 12,
2, 15, 12, 15, 5, 2, 15, 2, 12, 5, 3, 8, 14, 9, 8, 9,
3, 14, 9, 14, 8, 3, 14, 3, 9, 8, 4, 7, 13, 10, 7, 10,
4, 13, 10, 13, 7, 4, 13, 4, 10, 7, 1, 7, 14, 12, 7,
12, 1, 14, 12, 14, 7, 1, 14, 1, 12, 7, 2, 8, 13, 11,
8, 11, 2, 13, 11, 13, 8, 2, 13, 2, 11, 8, 3, 5, 16,
10, 5, 10, 3, 16, 10, 16, 5, 3, 16, 3, 10, 5, 4, 6,
15, 9, 6, 9, 4, 15, 9, 15, 6, 4, 15, 4, 9, 6, 1, 8,
15, 10, 8, 10, 1, 15, 10, 15, 8, 1, 15, 1, 10, 8, 2,
7, 16, 9, 7, 9, 2, 16, 9, 16, 7, 2, 16, 2, 9, 7, 3, 6,
13, 12, 6, 12, 3, 13, 12, 13, 6, 3, 13, 3, 12, 6, 4,
5, 14, 11, 5, 11, 4, 14, 11, 14, 5, 4, 14, 4, 11, 5),
112, 4, byrow = T)
} else if (all(williams_D == 4, selection == 1, type == "S")) {
sequences <- matrix(c(1, 4, 5, 2, 4, 2, 1, 5, 2, 5, 4, 1, 5, 1, 2, 4, 2, 5,
6, 3, 5, 3, 2, 6, 3, 6, 5, 2, 6, 2, 3, 5, 3, 6, 4, 1,
6, 1, 3, 4, 1, 4, 6, 3, 4, 3, 1, 6), 12, 4, byrow = T)
} else if (all(williams_D == 4, selection == 3, type == "S")) {
sequences <- matrix(c(1, 4, 5, 2, 4, 2, 1, 5, 2, 5, 4, 1, 5, 1, 2, 4, 2, 5,
6, 3, 5, 3, 2, 6, 3, 6, 5, 2, 6, 2, 3, 5, 3, 6, 4, 1,
6, 1, 3, 4, 1, 4, 6, 3, 4, 3, 1, 6, 1, 4, 5, 2, 4, 2,
1, 5, 2, 5, 4, 1, 5, 1, 2, 4, 2, 5, 6, 3, 5, 3, 2, 6,
3, 6, 5, 2, 6, 2, 3, 5, 3, 6, 4, 1, 6, 1, 3, 4, 1, 4,
6, 3, 4, 3, 1, 6, 1, 4, 5, 2, 4, 2, 1, 5, 2, 5, 4, 1,
5, 1, 2, 4, 2, 5, 6, 3, 5, 3, 2, 6, 3, 6, 5, 2, 6, 2,
3, 5, 3, 6, 4, 1, 6, 1, 3, 4, 1, 4, 6, 3, 4, 3, 1, 6),
36, 4, byrow = T)
} else if (all(williams_D == 4, selection == 6, type == "S")) {
sequences <- matrix(c(1, 5, 6, 2, 5, 2, 1, 6, 2, 6, 5, 1, 6, 1, 2, 5, 3, 7,
8, 4, 7, 4, 3, 8, 4, 8, 7, 3, 8, 3, 4, 7, 1, 5, 7, 3,
5, 3, 1, 7, 3, 7, 5, 1, 7, 1, 3, 5, 2, 6, 8, 4, 6, 4,
2, 8, 4, 8, 6, 2, 8, 2, 4, 6, 1, 5, 8, 4, 5, 4, 1, 8,
4, 8, 5, 1, 8, 1, 4, 5, 2, 6, 7, 3, 6, 3, 2, 7, 3, 7,
6, 2, 7, 2, 3, 6), 24, 4, byrow = T)
} else if (all(williams_D == 4, selection == 7, type == "S")) {
sequences <- matrix(c(1, 5, 7, 3, 5, 3, 1, 7, 3, 7, 5, 1, 7, 1, 3, 5, 2, 6,
8, 4, 6, 4, 2, 8, 4, 8, 6, 2, 8, 2, 4, 6, 3, 7, 5, 1,
7, 1, 3, 5, 1, 5, 7, 3, 5, 3, 1, 7, 4, 8, 6, 2, 8, 2,
4, 6, 2, 6, 8, 4, 6, 4, 2, 8, 1, 5, 6, 2, 5, 2, 1, 6,
2, 6, 5, 1, 6, 1, 2, 5, 3, 7, 8, 4, 7, 4, 3, 8, 4, 8,
7, 3, 8, 3, 4, 7, 2, 6, 5, 1, 6, 1, 2, 5, 1, 5, 6, 2,
5, 2, 1, 6, 4, 8, 7, 3, 8, 3, 4, 7, 3, 7, 8, 4, 7, 4,
3, 8, 1, 5, 8, 4, 5, 4, 1, 8, 4, 8, 5, 1, 8, 1, 4, 5,
2, 6, 7, 3, 6, 3, 2, 7, 3, 7, 6, 2, 7, 2, 3, 6, 4, 8,
5, 1, 8, 1, 4, 5, 1, 5, 8, 4, 5, 4, 1, 8, 3, 7, 6, 2,
7, 2, 3, 6, 2, 6, 7, 3, 6, 3, 2, 7), 48, 4, byrow = T)
} else if (all(williams_D == 4, selection == 9, type == "S")) {
sequences <- matrix(c(1, 6, 7, 2, 6, 2, 1, 7, 2, 7, 6, 1, 7, 1, 2, 6, 2, 7,
8, 3, 7, 3, 2, 8, 3, 8, 7, 2, 8, 2, 3, 7, 3, 8, 9, 4,
8, 4, 3, 9, 4, 9, 8, 3, 9, 3, 4, 8, 4, 9, 10, 5, 9, 5,
4, 10, 5, 10, 9, 4, 10, 4, 5, 9, 5, 10, 6, 1, 10, 1,
5, 6, 1, 6, 10, 5, 6, 5, 1, 10, 6, 1, 3, 8, 1, 8, 6,
3, 8, 3, 1, 6, 3, 6, 8, 1, 7, 2, 4, 9, 2, 9, 7, 4, 9,
4, 2, 7, 4, 7, 9, 2, 8, 3, 5, 10, 3, 10, 8, 5, 10, 5,
3, 8, 5, 8, 10, 3, 9, 4, 1, 6, 4, 6, 9, 1, 6, 1, 4, 9,
1, 9, 6, 4, 10, 5, 2, 7, 5, 7, 10, 2, 7, 2, 5, 10, 2,
10, 7, 5), 40, 4, byrow = T)
} else if (all(williams_D == 4, selection == 11, type == "S")) {
sequences <- matrix(c(1, 7, 8, 2, 7, 2, 1, 8, 2, 8, 7, 1, 8, 1, 2, 7, 3, 9,
10, 4, 9, 4, 3, 10, 4, 10, 9, 3, 10, 3, 4, 9, 5, 11,
12, 6, 11, 6, 5, 12, 6, 12, 11, 5, 12, 5, 6, 11, 1, 7,
10, 4, 7, 4, 1, 10, 4, 10, 7, 1, 10, 1, 4, 7, 2, 8,
11, 5, 8, 5, 2, 11, 5, 11, 8, 2, 11, 2, 5, 8, 3, 9,
12, 6, 9, 6, 3, 12, 6, 12, 9, 3, 12, 3, 6, 9, 1, 7,
12, 6, 7, 6, 1, 12, 6, 12, 7, 1, 12, 1, 6, 7, 2, 8,
10, 4, 8, 4, 2, 10, 4, 10, 8, 2, 10, 2, 4, 8, 3, 9,
11, 5, 9, 5, 3, 11, 5, 11, 9, 3, 11, 3, 5, 9, 1, 7, 9,
3, 7, 3, 1, 9, 3, 9, 7, 1, 9, 1, 3, 7, 2, 8, 12, 6, 8,
6, 2, 12, 6, 12, 8, 2, 12, 2, 6, 8, 4, 10, 11, 5, 10,
5, 4, 11, 5, 11, 10, 4, 11, 4, 5, 10, 1, 7, 11, 5, 7,
5, 1, 11, 5, 11, 7, 1, 11, 1, 5, 7, 2, 8, 9, 3, 8, 3,
2, 9, 3, 9, 8, 2, 9, 2, 3, 8, 4, 10, 12, 6, 10, 6, 4,
12, 6, 12, 10, 4, 12, 4, 6, 10), 60, 4, byrow = T)
} else if (all(williams_D == 4, selection == 35, type == "SR")) {
sequences <- matrix(c(1, 2, 4, 3, 2, 3, 1, 4, 3, 4, 2, 1, 4, 1, 3, 2, 5, 6,
2, 1, 6, 1, 5, 2, 1, 2, 6, 5, 2, 5, 1, 6, 3, 4, 6, 5,
4, 5, 3, 6, 5, 6, 4, 3, 6, 3, 5, 4, 1, 4, 6, 3, 4, 3,
1, 6, 3, 6, 4, 1, 6, 1, 3, 4, 5, 2, 4, 1, 2, 1, 5, 4,
1, 4, 2, 5, 4, 5, 1, 2, 3, 6, 2, 5, 6, 5, 3, 2, 5, 2,
6, 3, 2, 3, 5, 6, 1, 6, 2, 3, 6, 3, 1, 2, 3, 2, 6, 1,
2, 1, 3, 6, 5, 4, 6, 1, 4, 1, 5, 6, 1, 6, 4, 5, 6, 5,
1, 4, 3, 2, 4, 5, 2, 5, 3, 4, 5, 4, 2, 3, 4, 3, 5, 2),
36, 4, byrow = T)
} else if (all(williams_D == 4, selection == 36, type == "SR")) {
sequences <- matrix(c(1, 2, 4, 3, 2, 3, 1, 4, 3, 4, 2, 1, 4, 1, 3, 2, 5, 6,
8, 7, 6, 7, 5, 8, 7, 8, 6, 5, 8, 5, 7, 6, 2, 7, 1, 8,
7, 8, 2, 1, 8, 1, 7, 2, 1, 2, 8, 7, 6, 3, 5, 4, 3, 4,
6, 5, 4, 5, 3, 6, 5, 6, 4, 3, 3, 8, 6, 1, 8, 1, 3, 6,
1, 6, 8, 3, 6, 3, 1, 8, 7, 4, 2, 5, 4, 5, 7, 2, 5, 2,
4, 7, 2, 7, 5, 4, 4, 1, 7, 6, 1, 6, 4, 7, 6, 7, 1, 4,
7, 4, 6, 1, 8, 5, 3, 2, 5, 2, 8, 3, 2, 3, 5, 8, 3, 8,
2, 5), 32, 4, byrow = T)
} else if (all(williams_D == 4, selection == 37, type == "SR")) {
sequences <- matrix(c(1, 4, 7, 6, 4, 6, 1, 7, 6, 7, 4, 1, 7, 1, 6, 4, 3, 5,
8, 6, 5, 6, 3, 8, 6, 8, 5, 3, 8, 3, 6, 5, 2, 5, 8, 7,
5, 7, 2, 8, 7, 8, 5, 2, 8, 2, 7, 5, 1, 3, 8, 6, 3, 6,
1, 8, 6, 8, 3, 1, 8, 1, 6, 3, 1, 2, 7, 4, 2, 4, 1, 7,
4, 7, 2, 1, 7, 1, 4, 2, 2, 3, 5, 4, 3, 4, 2, 5, 4, 5,
3, 2, 5, 2, 4, 3, 1, 2, 4, 3, 2, 3, 1, 4, 3, 4, 2, 1,
4, 1, 3, 2, 1, 2, 8, 3, 2, 3, 1, 8, 3, 8, 2, 1, 8, 1,
3, 2, 3, 4, 6, 5, 4, 5, 3, 6, 5, 6, 4, 3, 6, 3, 5, 4,
4, 5, 7, 6, 5, 6, 4, 7, 6, 7, 5, 4, 7, 4, 6, 5, 1, 6,
8, 7, 6, 7, 1, 8, 7, 8, 6, 1, 8, 1, 7, 6, 2, 5, 8, 7,
5, 7, 2, 8, 7, 8, 5, 2, 8, 2, 7, 5), 48, 4, byrow = T)
} else if (all(williams_D == 4, selection == 41, type == "SR")) {
sequences <- matrix(c(1, 2, 4, 3, 2, 3, 1, 4, 3, 4, 2, 1, 4, 1, 3, 2, 7, 10,
4, 5, 10, 5, 7, 4, 5, 4, 10, 7, 4, 7, 5, 10, 6, 11, 4,
9, 11, 9, 6, 4, 9, 4, 11, 6, 4, 6, 9, 11, 1, 7, 8, 6,
7, 6, 1, 8, 6, 8, 7, 1, 8, 1, 6, 7, 11, 5, 8, 2, 5, 2,
11, 8, 2, 8, 5, 11, 8, 11, 2, 5, 10, 9, 8, 3, 9, 3,
10, 8, 3, 8, 9, 10, 8, 10, 3, 9, 1, 11, 12, 10, 11,
10, 1, 12, 10, 12, 11, 1, 12, 1, 10, 11, 9, 2, 12, 7,
2, 7, 9, 12, 7, 12, 2, 9, 12, 9, 7, 2, 5, 3, 12, 6, 3,
6, 5, 12, 6, 12, 3, 5, 12, 5, 6, 3), 36, 4, byrow = T)
} else if (all(williams_D == 4, selection == 42, type == "SR")) {
sequences <- matrix(c(1, 2, 4, 3, 2, 3, 1, 4, 3, 4, 2, 1, 4, 1, 3, 2, 5, 6,
8, 7, 6, 7, 5, 8, 7, 8, 6, 5, 8, 5, 7, 6, 9, 10, 12,
11, 10, 11, 9, 12, 11, 12, 10, 9, 12, 9, 11, 10, 7, 8,
10, 1, 8, 1, 7, 10, 1, 10, 8, 7, 10, 7, 1, 8, 11, 12,
2, 5, 12, 5, 11, 2, 5, 2, 12, 11, 2, 11, 5, 12, 3, 4,
6, 9, 4, 9, 3, 6, 9, 6, 4, 3, 6, 3, 9, 4, 1, 6, 12, 3,
6, 3, 1, 12, 3, 12, 6, 1, 12, 1, 3, 6, 5, 10, 4, 7,
10, 7, 5, 4, 7, 4, 10, 5, 4, 5, 7, 10, 9, 2, 8, 11, 2,
11, 9, 8, 11, 8, 2, 9, 8, 9, 11, 2, 1, 2, 12, 7, 2, 7,
1, 12, 7, 12, 2, 1, 12, 1, 7, 2, 5, 6, 4, 11, 6, 11,
5, 4, 11, 4, 6, 5, 4, 5, 11, 6, 9, 10, 8, 3, 10, 3, 9,
8, 3, 8, 10, 9, 8, 9, 3, 10, 11, 4, 10, 1, 4, 1, 11,
10, 1, 10, 4, 11, 10, 11, 1, 4, 3, 8, 2, 5, 8, 5, 3,
2, 5, 2, 8, 3, 2, 3, 5, 8, 7, 12, 6, 9, 12, 9, 7, 6,
9, 6, 12, 7, 6, 7, 9, 12, 11, 8, 6, 1, 8, 1, 11, 6, 1,
6, 8, 11, 6, 11, 1, 8, 3, 12, 10, 5, 12, 5, 3, 10, 5,
10, 12, 3, 10, 3, 5, 12, 7, 4, 2, 9, 4, 9, 7, 2, 9, 2,
4, 7, 2, 7, 9, 4), 72, 4, byrow = T)
} else if (all(williams_D == 4, selection == 44, type == "SR")) {
sequences <- matrix(c(1, 2, 4, 3, 2, 3, 1, 4, 3, 4, 2, 1, 4, 1, 3, 2, 5, 6,
8, 7, 6, 7, 5, 8, 7, 8, 6, 5, 8, 5, 7, 6, 9, 10, 12,
11, 10, 11, 9, 12, 11, 12, 10, 9, 12, 9, 11, 10, 13,
14, 16, 15, 14, 15, 13, 16, 15, 16, 14, 13, 16, 13,
15, 14, 1, 6, 16, 11, 6, 11, 1, 16, 11, 16, 6, 1, 16,
1, 11, 6, 2, 5, 15, 12, 5, 12, 2, 15, 12, 15, 5, 2,
15, 2, 12, 5, 3, 8, 14, 9, 8, 9, 3, 14, 9, 14, 8, 3,
14, 3, 9, 8, 4, 7, 13, 10, 7, 10, 4, 13, 10, 13, 7, 4,
13, 4, 10, 7, 1, 7, 14, 12, 7, 12, 1, 14, 12, 14, 7,
1, 14, 1, 12, 7, 2, 8, 13, 11, 8, 11, 2, 13, 11, 13,
8, 2, 13, 2, 11, 8, 3, 5, 16, 10, 5, 10, 3, 16, 10,
16, 5, 3, 16, 3, 10, 5, 4, 6, 15, 9, 6, 9, 4, 15, 9,
15, 6, 4, 15, 4, 9, 6, 1, 8, 15, 10, 8, 10, 1, 15, 10,
15, 8, 1, 15, 1, 10, 8, 2, 7, 16, 9, 7, 9, 2, 16, 9,
16, 7, 2, 16, 2, 9, 7, 3, 6, 13, 12, 6, 12, 3, 13, 12,
13, 6, 3, 13, 3, 12, 6, 4, 5, 14, 11, 5, 11, 4, 14,
11, 14, 5, 4, 14, 4, 11, 5), 64, 4, byrow = T)
} else if (all(williams_D == 4, selection == 46, type == "SR")) {
sequences <- matrix(c(1, 19, 18, 20, 19, 20, 1, 18, 20, 18, 19, 1, 18, 1,
20, 19, 1, 12, 11, 10, 12, 10, 1, 11, 10, 11, 12, 1,
11, 1, 10, 12, 6, 16, 11, 17, 16, 17, 6, 11, 17, 11,
16, 6, 11, 6, 17, 16, 16, 3, 5, 18, 3, 18, 16, 5, 18,
5, 3, 16, 5, 16, 18, 3, 7, 5, 12, 2, 5, 2, 7, 12, 2,
12, 5, 7, 12, 7, 2, 5, 4, 19, 9, 6, 19, 6, 4, 9, 6, 9,
19, 4, 9, 4, 6, 19, 8, 14, 3, 9, 14, 9, 8, 3, 9, 3,
14, 8, 3, 8, 9, 14, 14, 20, 13, 7, 20, 7, 14, 13, 7,
13, 20, 14, 13, 14, 7, 20, 15, 13, 10, 4, 13, 4, 15,
10, 4, 10, 13, 15, 10, 15, 4, 13, 15, 2, 17, 8, 2, 8,
15, 17, 8, 17, 2, 15, 17, 15, 8, 2, 1, 2, 4, 3, 2, 3,
1, 4, 3, 4, 2, 1, 4, 1, 3, 2, 1, 6, 8, 7, 6, 7, 1, 8,
7, 8, 6, 1, 8, 1, 7, 6, 19, 12, 17, 14, 12, 14, 19,
17, 14, 17, 12, 19, 17, 19, 14, 12, 12, 9, 15, 18, 9,
18, 12, 15, 18, 15, 9, 12, 15, 12, 18, 9, 20, 15, 6,
5, 15, 5, 20, 6, 5, 6, 15, 20, 6, 20, 5, 15, 13, 2,
16, 19, 2, 19, 13, 16, 19, 16, 2, 13, 16, 13, 19, 2,
10, 16, 7, 9, 16, 9, 10, 7, 9, 7, 16, 10, 7, 10, 9,
16, 10, 17, 20, 3, 17, 3, 10, 20, 3, 20, 17, 10, 20,
10, 3, 17, 18, 11, 8, 13, 11, 13, 18, 8, 13, 8, 11,
18, 8, 18, 13, 11, 11, 5, 14, 4, 5, 4, 11, 14, 4, 14,
5, 11, 14, 11, 4, 5, 1, 16, 15, 14, 16, 14, 1, 15, 14,
15, 16, 1, 15, 1, 14, 16, 9, 20, 2, 11, 20, 11, 9, 2,
11, 2, 20, 9, 2, 9, 11, 20, 13, 6, 3, 12, 6, 12, 13,
3, 12, 3, 6, 13, 3, 13, 12, 6, 17, 18, 4, 7, 18, 7,
17, 4, 7, 4, 18, 17, 4, 17, 7, 18, 5, 19, 10, 8, 19,
8, 5, 10, 8, 10, 19, 5, 10, 5, 8, 19), 100, 4,
byrow = T)
} else if (all(williams_D == 5, selection == 133, type == "R")) {
sequences <- matrix(c(1, 2, 7, 3, 5, 2, 3, 1, 5, 7, 3, 5, 2, 7, 1, 5, 7, 3,
1, 2, 7, 1, 5, 2, 3, 5, 3, 7, 2, 1, 7, 5, 1, 3, 2, 1,
7, 2, 5, 3, 2, 1, 3, 7, 5, 3, 2, 5, 1, 7, 2, 3, 8, 4,
6, 3, 4, 2, 6, 8, 4, 6, 3, 8, 2, 6, 8, 4, 2, 3, 8, 2,
6, 3, 4, 6, 4, 8, 3, 2, 8, 6, 2, 4, 3, 2, 8, 3, 6, 4,
3, 2, 4, 8, 6, 4, 3, 6, 2, 8, 3, 4, 1, 5, 7, 4, 5, 3,
7, 1, 5, 7, 4, 1, 3, 7, 1, 5, 3, 4, 1, 3, 7, 4, 5, 7,
5, 1, 4, 3, 1, 7, 3, 5, 4, 3, 1, 4, 7, 5, 4, 3, 5, 1,
7, 5, 4, 7, 3, 1, 4, 5, 2, 6, 8, 5, 6, 4, 8, 2, 6, 8,
5, 2, 4, 8, 2, 6, 4, 5, 2, 4, 8, 5, 6, 8, 6, 2, 5, 4,
2, 8, 4, 6, 5, 4, 2, 5, 8, 6, 5, 4, 6, 2, 8, 6, 5, 8,
4, 2, 5, 6, 3, 7, 1, 6, 7, 5, 1, 3, 7, 1, 6, 3, 5, 1,
3, 7, 5, 6, 3, 5, 1, 6, 7, 1, 7, 3, 6, 5, 3, 1, 5, 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9, 3, 6, 9, 5, 3, 4, 9, 3, 6, 4,
5, 6, 5, 9, 4, 3, 9, 6, 3, 5, 4, 3, 9, 4, 6, 5, 4, 3,
5, 9, 6, 5, 4, 6, 3, 9, 2, 3, 9, 4, 8, 3, 4, 2, 8, 9,
4, 8, 3, 9, 2, 8, 9, 4, 2, 3, 9, 2, 8, 3, 4, 8, 4, 9,
3, 2, 9, 8, 2, 4, 3, 2, 9, 3, 8, 4, 3, 2, 4, 9, 8, 4,
3, 8, 2, 9, 2, 5, 10, 8, 9, 5, 8, 2, 9, 10, 8, 9, 5,
10, 2, 9, 10, 8, 2, 5, 10, 2, 9, 5, 8, 9, 8, 10, 5, 2,
10, 9, 2, 8, 5, 2, 10, 5, 9, 8, 5, 2, 8, 10, 9, 8, 5,
9, 2, 10, 3, 5, 10, 7, 8, 5, 7, 3, 8, 10, 7, 8, 5, 10,
3, 8, 10, 7, 3, 5, 10, 3, 8, 5, 7, 8, 7, 10, 5, 3, 10,
8, 3, 7, 5, 3, 10, 5, 8, 7, 5, 3, 7, 10, 8, 7, 5, 8,
3, 10, 4, 5, 10, 7, 9, 5, 7, 4, 9, 10, 7, 9, 5, 10, 4,
9, 10, 7, 4, 5, 10, 4, 9, 5, 7, 9, 7, 10, 5, 4, 10, 9,
4, 7, 5, 4, 10, 5, 9, 7, 5, 4, 7, 10, 9, 7, 5, 9, 4,
10), 140, 5, byrow = T)
} else if (all(williams_D == 5, selection == 143, type == "R")) {
sequences <- matrix(c(1, 2, 10, 4, 7, 2, 4, 1, 7, 10, 4, 7, 2, 10, 1, 7, 10,
4, 1, 2, 10, 1, 7, 2, 4, 7, 4, 10, 2, 1, 10, 7, 1, 4,
2, 1, 10, 2, 7, 4, 2, 1, 4, 10, 7, 4, 2, 7, 1, 10, 2,
3, 11, 5, 8, 3, 5, 2, 8, 11, 5, 8, 3, 11, 2, 8, 11, 5,
2, 3, 11, 2, 8, 3, 5, 8, 5, 11, 3, 2, 11, 8, 2, 5, 3,
2, 11, 3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 9, 6, 3, 9, 12, 10, 9, 6, 10, 3,
12, 10, 9, 12, 6, 3, 12, 10, 3, 9, 6, 10, 11, 7, 1, 4,
11, 1, 10, 4, 7, 1, 4, 11, 7, 10, 4, 7, 1, 10, 11, 7,
10, 4, 11, 1, 4, 1, 7, 11, 10, 7, 4, 10, 1, 11, 10, 7,
11, 4, 1, 11, 10, 1, 7, 4, 1, 11, 4, 10, 7, 11, 12, 8,
2, 5, 12, 2, 11, 5, 8, 2, 5, 12, 8, 11, 5, 8, 2, 11,
12, 8, 11, 5, 12, 2, 5, 2, 8, 12, 11, 8, 5, 11, 2, 12,
11, 8, 12, 5, 2, 12, 11, 2, 8, 5, 2, 12, 5, 11, 8, 12,
1, 9, 3, 6, 1, 3, 12, 6, 9, 3, 6, 1, 9, 12, 6, 9, 3,
12, 1, 9, 12, 6, 1, 3, 6, 3, 9, 1, 12, 9, 6, 12, 3, 1,
12, 9, 1, 6, 3, 1, 12, 3, 9, 6, 3, 1, 6, 12, 9), 120,
5, byrow = T)
} else if (all(williams_D == 5, selection == 144, type == "R")) {
sequences <- matrix(c(1, 2, 12, 4, 9, 2, 4, 1, 9, 12, 4, 9, 2, 12, 1, 9, 12,
4, 1, 2, 12, 1, 9, 2, 4, 9, 4, 12, 2, 1, 12, 9, 1, 4,
2, 1, 12, 2, 9, 4, 2, 1, 4, 12, 9, 4, 2, 9, 1, 12, 2,
3, 1, 5, 10, 3, 5, 2, 10, 1, 5, 10, 3, 1, 2, 10, 1, 5,
2, 3, 1, 2, 10, 3, 5, 10, 5, 1, 3, 2, 1, 10, 2, 5, 3,
2, 1, 3, 10, 5, 3, 2, 5, 1, 10, 5, 3, 10, 2, 1, 3, 4,
2, 6, 11, 4, 6, 3, 11, 2, 6, 11, 4, 2, 3, 11, 2, 6, 3,
4, 2, 3, 11, 4, 6, 11, 6, 2, 4, 3, 2, 11, 3, 6, 4, 3,
2, 4, 11, 6, 4, 3, 6, 2, 11, 6, 4, 11, 3, 2, 4, 5, 3,
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, 1, 11, 6, 10, 9, 11, 12, 10, 2, 7, 12, 2,
11, 7, 10, 2, 7, 12, 10, 11, 7, 10, 2, 11, 12, 10, 11,
7, 12, 2, 7, 2, 10, 12, 11, 10, 7, 11, 2, 12, 11, 10,
12, 7, 2, 12, 11, 2, 10, 7, 2, 12, 7, 11, 10, 12, 1,
11, 3, 8, 1, 3, 12, 8, 11, 3, 8, 1, 11, 12, 8, 11, 3,
12, 1, 11, 12, 8, 1, 3, 8, 3, 11, 1, 12, 11, 8, 12, 3,
1, 12, 11, 1, 8, 3, 1, 12, 3, 11, 8, 3, 1, 8, 12, 11),
120, 5, byrow = T)
} else if (all(williams_D == 5, selection == 145, type == "R")) {
sequences <- matrix(c(1, 2, 7, 4, 6, 2, 4, 1, 6, 7, 4, 6, 2, 7, 1, 6, 7, 4,
1, 2, 7, 1, 6, 2, 4, 6, 4, 7, 2, 1, 7, 6, 1, 4, 2, 1,
7, 2, 6, 4, 2, 1, 4, 7, 6, 4, 2, 6, 1, 7, 2, 3, 8, 5,
7, 3, 5, 2, 7, 8, 5, 7, 3, 8, 2, 7, 8, 5, 2, 3, 8, 2,
7, 3, 5, 7, 5, 8, 3, 2, 8, 7, 2, 5, 3, 2, 8, 3, 7, 5,
3, 2, 5, 8, 7, 5, 3, 7, 2, 8, 3, 4, 9, 6, 8, 4, 6, 3,
8, 9, 6, 8, 4, 9, 3, 8, 9, 6, 3, 4, 9, 3, 8, 4, 6, 8,
6, 9, 4, 3, 9, 8, 3, 6, 4, 3, 9, 4, 8, 6, 4, 3, 6, 9,
8, 6, 4, 8, 3, 9, 4, 5, 10, 7, 9, 5, 7, 4, 9, 10, 7,
9, 5, 10, 4, 9, 10, 7, 4, 5, 10, 4, 9, 5, 7, 9, 7, 10,
5, 4, 10, 9, 4, 7, 5, 4, 10, 5, 9, 7, 5, 4, 7, 10, 9,
7, 5, 9, 4, 10, 5, 6, 11, 8, 10, 6, 8, 5, 10, 11, 8,
10, 6, 11, 5, 10, 11, 8, 5, 6, 11, 5, 10, 6, 8, 10, 8,
11, 6, 5, 11, 10, 5, 8, 6, 5, 11, 6, 10, 8, 6, 5, 8,
11, 10, 8, 6, 10, 5, 11, 6, 7, 12, 9, 11, 7, 9, 6, 11,
12, 9, 11, 7, 12, 6, 11, 12, 9, 6, 7, 12, 6, 11, 7, 9,
11, 9, 12, 7, 6, 12, 11, 6, 9, 7, 6, 12, 7, 11, 9, 7,
6, 9, 12, 11, 9, 7, 11, 6, 12, 7, 8, 1, 10, 12, 8, 10,
7, 12, 1, 10, 12, 8, 1, 7, 12, 1, 10, 7, 8, 1, 7, 12,
8, 10, 12, 10, 1, 8, 7, 1, 12, 7, 10, 8, 7, 1, 8, 12,
10, 8, 7, 10, 1, 12, 10, 8, 12, 7, 1, 8, 9, 2, 11, 1,
9, 11, 8, 1, 2, 11, 1, 9, 2, 8, 1, 2, 11, 8, 9, 2, 8,
1, 9, 11, 1, 11, 2, 9, 8, 2, 1, 8, 11, 9, 8, 2, 9, 1,
11, 9, 8, 11, 2, 1, 11, 9, 1, 8, 2, 9, 10, 3, 12, 2,
10, 12, 9, 2, 3, 12, 2, 10, 3, 9, 2, 3, 12, 9, 10, 3,
9, 2, 10, 12, 2, 12, 3, 10, 9, 3, 2, 9, 12, 10, 9, 3,
10, 2, 12, 10, 9, 12, 3, 2, 12, 10, 2, 9, 3, 10, 11,
4, 1, 3, 11, 1, 10, 3, 4, 1, 3, 11, 4, 10, 3, 4, 1,
10, 11, 4, 10, 3, 11, 1, 3, 1, 4, 11, 10, 4, 3, 10, 1,
11, 10, 4, 11, 3, 1, 11, 10, 1, 4, 3, 1, 11, 3, 10, 4,
11, 12, 5, 2, 4, 12, 2, 11, 4, 5, 2, 4, 12, 5, 11, 4,
5, 2, 11, 12, 5, 11, 4, 12, 2, 4, 2, 5, 12, 11, 5, 4,
11, 2, 12, 11, 5, 12, 4, 2, 12, 11, 2, 5, 4, 2, 12, 4,
11, 5, 12, 1, 6, 3, 5, 1, 3, 12, 5, 6, 3, 5, 1, 6, 12,
5, 6, 3, 12, 1, 6, 12, 5, 1, 3, 5, 3, 6, 1, 12, 6, 5,
12, 3, 1, 12, 6, 1, 5, 3, 1, 12, 3, 6, 5, 3, 1, 5, 12,
6), 120, 5, byrow = T)
} else if (all(williams_D == 5, selection == 150, type == "R")) {
sequences <- matrix(c(1, 6, 15, 12, 13, 6, 12, 1, 13, 15, 12, 13, 6, 15, 1,
13, 15, 12, 1, 6, 15, 1, 13, 6, 12, 13, 12, 15, 6, 1,
15, 13, 1, 12, 6, 1, 15, 6, 13, 12, 6, 1, 12, 15, 13,
12, 6, 13, 1, 15, 2, 7, 11, 13, 14, 7, 13, 2, 14, 11,
13, 14, 7, 11, 2, 14, 11, 13, 2, 7, 11, 2, 14, 7, 13,
14, 13, 11, 7, 2, 11, 14, 2, 13, 7, 2, 11, 7, 14, 13,
7, 2, 13, 11, 14, 13, 7, 14, 2, 11, 3, 8, 12, 14, 15,
8, 14, 3, 15, 12, 14, 15, 8, 12, 3, 15, 12, 14, 3, 8,
12, 3, 15, 8, 14, 15, 14, 12, 8, 3, 12, 15, 3, 14, 8,
3, 12, 8, 15, 14, 8, 3, 14, 12, 15, 14, 8, 15, 3, 12,
4, 9, 13, 15, 11, 9, 15, 4, 11, 13, 15, 11, 9, 13, 4,
11, 13, 15, 4, 9, 13, 4, 11, 9, 15, 11, 15, 13, 9, 4,
13, 11, 4, 15, 9, 4, 13, 9, 11, 15, 9, 4, 15, 13, 11,
15, 9, 11, 4, 13, 5, 10, 14, 11, 12, 10, 11, 5, 12,
14, 11, 12, 10, 14, 5, 12, 14, 11, 5, 10, 14, 5, 12,
10, 11, 12, 11, 14, 10, 5, 14, 12, 5, 11, 10, 5, 14,
10, 12, 11, 10, 5, 11, 14, 12, 11, 10, 12, 5, 14, 6,
11, 5, 2, 3, 11, 2, 6, 3, 5, 2, 3, 11, 5, 6, 3, 5, 2,
6, 11, 5, 6, 3, 11, 2, 3, 2, 5, 11, 6, 5, 3, 6, 2, 11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 9, 7, 3, 13, 7, 10, 13, 9,
3, 13, 7, 3, 10, 9, 3, 13, 9, 7, 10, 9, 3, 10, 13, 7,
14, 4, 8, 10, 6, 4, 10, 14, 6, 8, 10, 6, 4, 8, 14, 6,
8, 10, 14, 4, 8, 14, 6, 4, 10, 6, 10, 8, 4, 14, 8, 6,
14, 10, 4, 14, 8, 4, 6, 10, 4, 14, 10, 8, 6, 10, 4, 6,
14, 8, 15, 5, 9, 6, 7, 5, 6, 15, 7, 9, 6, 7, 5, 9, 15,
7, 9, 6, 15, 5, 9, 15, 7, 5, 6, 7, 6, 9, 5, 15, 9, 7,
15, 6, 5, 15, 9, 5, 7, 6, 5, 15, 6, 9, 7, 6, 5, 7, 15,
9, 1, 6, 14, 12, 13, 6, 12, 1, 13, 14, 12, 13, 6, 14,
1, 13, 14, 12, 1, 6, 14, 1, 13, 6, 12, 13, 12, 14, 6,
1, 14, 13, 1, 12, 6, 1, 14, 6, 13, 12, 6, 1, 12, 14,
13, 12, 6, 13, 1, 14, 2, 7, 15, 13, 14, 7, 13, 2, 14,
15, 13, 14, 7, 15, 2, 14, 15, 13, 2, 7, 15, 2, 14, 7,
13, 14, 13, 15, 7, 2, 15, 14, 2, 13, 7, 2, 15, 7, 14,
13, 7, 2, 13, 15, 14, 13, 7, 14, 2, 15, 3, 8, 11, 14,
15, 8, 14, 3, 15, 11, 14, 15, 8, 11, 3, 15, 11, 14, 3,
8, 11, 3, 15, 8, 14, 15, 14, 11, 8, 3, 11, 15, 3, 14,
8, 3, 11, 8, 15, 14, 8, 3, 14, 11, 15, 14, 8, 15, 3,
11, 4, 9, 12, 15, 11, 9, 15, 4, 11, 12, 15, 11, 9, 12,
4, 11, 12, 15, 4, 9, 12, 4, 11, 9, 15, 11, 15, 12, 9,
4, 12, 11, 4, 15, 9, 4, 12, 9, 11, 15, 9, 4, 15, 12,
11, 15, 9, 11, 4, 12, 5, 10, 13, 11, 12, 10, 11, 5,
12, 13, 11, 12, 10, 13, 5, 12, 13, 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, 10, 8, 9, 2, 10, 12, 9, 10, 8,
12, 2, 10, 12, 9, 2, 8, 9, 8, 10, 2, 12, 10, 9, 12, 8,
2, 12, 10, 2, 9, 8, 2, 12, 8, 10, 9, 8, 2, 9, 12, 10,
13, 3, 6, 9, 10, 3, 9, 13, 10, 6, 9, 10, 3, 6, 13, 10,
6, 9, 13, 3, 6, 13, 10, 3, 9, 10, 9, 6, 3, 13, 6, 10,
13, 9, 3, 13, 6, 3, 10, 9, 3, 13, 9, 6, 10, 9, 3, 10,
13, 6, 14, 4, 7, 10, 6, 4, 10, 14, 6, 7, 10, 6, 4, 7,
14, 6, 7, 10, 14, 4, 7, 14, 6, 4, 10, 6, 10, 7, 4, 14,
7, 6, 14, 10, 4, 14, 7, 4, 6, 10, 4, 14, 10, 7, 6, 10,
4, 6, 14, 7, 15, 5, 8, 6, 7, 5, 6, 15, 7, 8, 6, 7, 5,
8, 15, 7, 8, 6, 15, 5, 8, 15, 7, 5, 6, 7, 6, 8, 5, 15,
8, 7, 15, 6, 5, 15, 8, 5, 7, 6, 5, 15, 6, 8, 7, 6, 5,
7, 15, 8), 300, 5, byrow = T)
} else if (all(williams_D == 5, selection == 153, type == "R")) {
sequences <- matrix(c(1, 2, 12, 5, 10, 2, 5, 1, 10, 12, 5, 10, 2, 12, 1, 10,
12, 5, 1, 2, 12, 1, 10, 2, 5, 10, 5, 12, 2, 1, 12, 10,
1, 5, 2, 1, 12, 2, 10, 5, 2, 1, 5, 12, 10, 5, 2, 10,
1, 12, 2, 3, 13, 6, 11, 3, 6, 2, 11, 13, 6, 11, 3, 13,
2, 11, 13, 6, 2, 3, 13, 2, 11, 3, 6, 11, 6, 13, 3, 2,
13, 11, 2, 6, 3, 2, 13, 3, 11, 6, 3, 2, 6, 13, 11, 6,
3, 11, 2, 13, 3, 4, 14, 7, 12, 4, 7, 3, 12, 14, 7, 12,
4, 14, 3, 12, 14, 7, 3, 4, 14, 3, 12, 4, 7, 12, 7, 14,
4, 3, 14, 12, 3, 7, 4, 3, 14, 4, 12, 7, 4, 3, 7, 14,
12, 7, 4, 12, 3, 14, 4, 5, 15, 8, 13, 5, 8, 4, 13, 15,
8, 13, 5, 15, 4, 13, 15, 8, 4, 5, 15, 4, 13, 5, 8, 13,
8, 15, 5, 4, 15, 13, 4, 8, 5, 4, 15, 5, 13, 8, 5, 4,
8, 15, 13, 8, 5, 13, 4, 15, 5, 6, 16, 9, 14, 6, 9, 5,
14, 16, 9, 14, 6, 16, 5, 14, 16, 9, 5, 6, 16, 5, 14,
6, 9, 14, 9, 16, 6, 5, 16, 14, 5, 9, 6, 5, 16, 6, 14,
9, 6, 5, 9, 16, 14, 9, 6, 14, 5, 16, 6, 7, 17, 10, 15,
7, 10, 6, 15, 17, 10, 15, 7, 17, 6, 15, 17, 10, 6, 7,
17, 6, 15, 7, 10, 15, 10, 17, 7, 6, 17, 15, 6, 10, 7,
6, 17, 7, 15, 10, 7, 6, 10, 17, 15, 10, 7, 15, 6, 17,
7, 8, 18, 11, 16, 8, 11, 7, 16, 18, 11, 16, 8, 18, 7,
16, 18, 11, 7, 8, 18, 7, 16, 8, 11, 16, 11, 18, 8, 7,
18, 16, 7, 11, 8, 7, 18, 8, 16, 11, 8, 7, 11, 18, 16,
11, 8, 16, 7, 18, 8, 9, 19, 12, 17, 9, 12, 8, 17, 19,
12, 17, 9, 19, 8, 17, 19, 12, 8, 9, 19, 8, 17, 9, 12,
17, 12, 19, 9, 8, 19, 17, 8, 12, 9, 8, 19, 9, 17, 12,
9, 8, 12, 19, 17, 12, 9, 17, 8, 19, 9, 10, 20, 13, 18,
10, 13, 9, 18, 20, 13, 18, 10, 20, 9, 18, 20, 13, 9,
10, 20, 9, 18, 10, 13, 18, 13, 20, 10, 9, 20, 18, 9,
13, 10, 9, 20, 10, 18, 13, 10, 9, 13, 20, 18, 13, 10,
18, 9, 20, 10, 11, 21, 14, 19, 11, 14, 10, 19, 21, 14,
19, 11, 21, 10, 19, 21, 14, 10, 11, 21, 10, 19, 11,
14, 19, 14, 21, 11, 10, 21, 19, 10, 14, 11, 10, 21,
11, 19, 14, 11, 10, 14, 21, 19, 14, 11, 19, 10, 21,
11, 12, 22, 15, 20, 12, 15, 11, 20, 22, 15, 20, 12,
22, 11, 20, 22, 15, 11, 12, 22, 11, 20, 12, 15, 20,
15, 22, 12, 11, 22, 20, 11, 15, 12, 11, 22, 12, 20,
15, 12, 11, 15, 22, 20, 15, 12, 20, 11, 22, 12, 13,
23, 16, 21, 13, 16, 12, 21, 23, 16, 21, 13, 23, 12,
21, 23, 16, 12, 13, 23, 12, 21, 13, 16, 21, 16, 23,
13, 12, 23, 21, 12, 16, 13, 12, 23, 13, 21, 16, 13,
12, 16, 23, 21, 16, 13, 21, 12, 23, 13, 14, 24, 17,
22, 14, 17, 13, 22, 24, 17, 22, 14, 24, 13, 22, 24,
17, 13, 14, 24, 13, 22, 14, 17, 22, 17, 24, 14, 13,
24, 22, 13, 17, 14, 13, 24, 14, 22, 17, 14, 13, 17,
24, 22, 17, 14, 22, 13, 24, 14, 15, 1, 18, 23, 15, 18,
14, 23, 1, 18, 23, 15, 1, 14, 23, 1, 18, 14, 15, 1,
14, 23, 15, 18, 23, 18, 1, 15, 14, 1, 23, 14, 18, 15,
14, 1, 15, 23, 18, 15, 14, 18, 1, 23, 18, 15, 23, 14,
1, 15, 16, 2, 19, 24, 16, 19, 15, 24, 2, 19, 24, 16,
2, 15, 24, 2, 19, 15, 16, 2, 15, 24, 16, 19, 24, 19,
2, 16, 15, 2, 24, 15, 19, 16, 15, 2, 16, 24, 19, 16,
15, 19, 2, 24, 19, 16, 24, 15, 2, 16, 17, 3, 20, 1,
17, 20, 16, 1, 3, 20, 1, 17, 3, 16, 1, 3, 20, 16, 17,
3, 16, 1, 17, 20, 1, 20, 3, 17, 16, 3, 1, 16, 20, 17,
16, 3, 17, 1, 20, 17, 16, 20, 3, 1, 20, 17, 1, 16, 3,
17, 18, 4, 21, 2, 18, 21, 17, 2, 4, 21, 2, 18, 4, 17,
2, 4, 21, 17, 18, 4, 17, 2, 18, 21, 2, 21, 4, 18, 17,
4, 2, 17, 21, 18, 17, 4, 18, 2, 21, 18, 17, 21, 4, 2,
21, 18, 2, 17, 4, 18, 19, 5, 22, 3, 19, 22, 18, 3, 5,
22, 3, 19, 5, 18, 3, 5, 22, 18, 19, 5, 18, 3, 19, 22,
3, 22, 5, 19, 18, 5, 3, 18, 22, 19, 18, 5, 19, 3, 22,
19, 18, 22, 5, 3, 22, 19, 3, 18, 5, 19, 20, 6, 23, 4,
20, 23, 19, 4, 6, 23, 4, 20, 6, 19, 4, 6, 23, 19, 20,
6, 19, 4, 20, 23, 4, 23, 6, 20, 19, 6, 4, 19, 23, 20,
19, 6, 20, 4, 23, 20, 19, 23, 6, 4, 23, 20, 4, 19, 6,
20, 21, 7, 24, 5, 21, 24, 20, 5, 7, 24, 5, 21, 7, 20,
5, 7, 24, 20, 21, 7, 20, 5, 21, 24, 5, 24, 7, 21, 20,
7, 5, 20, 24, 21, 20, 7, 21, 5, 24, 21, 20, 24, 7, 5,
24, 21, 5, 20, 7, 21, 22, 8, 1, 6, 22, 1, 21, 6, 8, 1,
6, 22, 8, 21, 6, 8, 1, 21, 22, 8, 21, 6, 22, 1, 6, 1,
8, 22, 21, 8, 6, 21, 1, 22, 21, 8, 22, 6, 1, 22, 21,
1, 8, 6, 1, 22, 6, 21, 8, 22, 23, 9, 2, 7, 23, 2, 22,
7, 9, 2, 7, 23, 9, 22, 7, 9, 2, 22, 23, 9, 22, 7, 23,
2, 7, 2, 9, 23, 22, 9, 7, 22, 2, 23, 22, 9, 23, 7, 2,
23, 22, 2, 9, 7, 2, 23, 7, 22, 9, 23, 24, 10, 3, 8,
24, 3, 23, 8, 10, 3, 8, 24, 10, 23, 8, 10, 3, 23, 24,
10, 23, 8, 24, 3, 8, 3, 10, 24, 23, 10, 8, 23, 3, 24,
23, 10, 24, 8, 3, 24, 23, 3, 10, 8, 3, 24, 8, 23, 10,
24, 1, 11, 4, 9, 1, 4, 24, 9, 11, 4, 9, 1, 11, 24, 9,
11, 4, 24, 1, 11, 24, 9, 1, 4, 9, 4, 11, 1, 24, 11, 9,
24, 4, 1, 24, 11, 1, 9, 4, 1, 24, 4, 11, 9, 4, 1, 9,
24, 11), 240, 5, byrow = T)
} else if (all(williams_D == 5, selection == "153a", type == "R")) {
sequences <- matrix(c(1, 2, 12, 5, 10, 2, 5, 1, 10, 12, 5, 10, 2, 12, 1, 10,
12, 5, 1, 2, 12, 1, 10, 2, 5, 10, 5, 12, 2, 1, 12, 10,
1, 5, 2, 1, 12, 2, 10, 5, 2, 1, 5, 12, 10, 5, 2, 10,
1, 12, 2, 3, 13, 6, 11, 3, 6, 2, 11, 13, 6, 11, 3, 13,
2, 11, 13, 6, 2, 3, 13, 2, 11, 3, 6, 11, 6, 13, 3, 2,
13, 11, 2, 6, 3, 2, 13, 3, 11, 6, 3, 2, 6, 13, 11, 6,
3, 11, 2, 13, 3, 4, 14, 7, 12, 4, 7, 3, 12, 14, 7, 12,
4, 14, 3, 12, 14, 7, 3, 4, 14, 3, 12, 4, 7, 12, 7, 14,
4, 3, 14, 12, 3, 7, 4, 3, 14, 4, 12, 7, 4, 3, 7, 14,
12, 7, 4, 12, 3, 14, 4, 5, 15, 8, 13, 5, 8, 4, 13, 15,
8, 13, 5, 15, 4, 13, 15, 8, 4, 5, 15, 4, 13, 5, 8, 13,
8, 15, 5, 4, 15, 13, 4, 8, 5, 4, 15, 5, 13, 8, 5, 4,
8, 15, 13, 8, 5, 13, 4, 15, 5, 6, 16, 9, 14, 6, 9, 5,
14, 16, 9, 14, 6, 16, 5, 14, 16, 9, 5, 6, 16, 5, 14,
6, 9, 14, 9, 16, 6, 5, 16, 14, 5, 9, 6, 5, 16, 6, 14,
9, 6, 5, 9, 16, 14, 9, 6, 14, 5, 16, 6, 7, 17, 10, 15,
7, 10, 6, 15, 17, 10, 15, 7, 17, 6, 15, 17, 10, 6, 7,
17, 6, 15, 7, 10, 15, 10, 17, 7, 6, 17, 15, 6, 10, 7,
6, 17, 7, 15, 10, 7, 6, 10, 17, 15, 10, 7, 15, 6, 17,
7, 8, 18, 11, 16, 8, 11, 7, 16, 18, 11, 16, 8, 18, 7,
16, 18, 11, 7, 8, 18, 7, 16, 8, 11, 16, 11, 18, 8, 7,
18, 16, 7, 11, 8, 7, 18, 8, 16, 11, 8, 7, 11, 18, 16,
11, 8, 16, 7, 18, 8, 9, 19, 12, 17, 9, 12, 8, 17, 19,
12, 17, 9, 19, 8, 17, 19, 12, 8, 9, 19, 8, 17, 9, 12,
17, 12, 19, 9, 8, 19, 17, 8, 12, 9, 8, 19, 9, 17, 12,
9, 8, 12, 19, 17, 12, 9, 17, 8, 19, 9, 10, 20, 13, 18,
10, 13, 9, 18, 20, 13, 18, 10, 20, 9, 18, 20, 13, 9,
10, 20, 9, 18, 10, 13, 18, 13, 20, 10, 9, 20, 18, 9,
13, 10, 9, 20, 10, 18, 13, 10, 9, 13, 20, 18, 13, 10,
18, 9, 20, 10, 11, 21, 14, 19, 11, 14, 10, 19, 21, 14,
19, 11, 21, 10, 19, 21, 14, 10, 11, 21, 10, 19, 11,
14, 19, 14, 21, 11, 10, 21, 19, 10, 14, 11, 10, 21,
11, 19, 14, 11, 10, 14, 21, 19, 14, 11, 19, 10, 21,
11, 12, 22, 15, 20, 12, 15, 11, 20, 22, 15, 20, 12,
22, 11, 20, 22, 15, 11, 12, 22, 11, 20, 12, 15, 20,
15, 22, 12, 11, 22, 20, 11, 15, 12, 11, 22, 12, 20,
15, 12, 11, 15, 22, 20, 15, 12, 20, 11, 22, 12, 13,
23, 16, 21, 13, 16, 12, 21, 23, 16, 21, 13, 23, 12,
21, 23, 16, 12, 13, 23, 12, 21, 13, 16, 21, 16, 23,
13, 12, 23, 21, 12, 16, 13, 12, 23, 13, 21, 16, 13,
12, 16, 23, 21, 16, 13, 21, 12, 23, 13, 14, 24, 17,
22, 14, 17, 13, 22, 24, 17, 22, 14, 24, 13, 22, 24,
17, 13, 14, 24, 13, 22, 14, 17, 22, 17, 24, 14, 13,
24, 22, 13, 17, 14, 13, 24, 14, 22, 17, 14, 13, 17,
24, 22, 17, 14, 22, 13, 24, 14, 15, 1, 18, 23, 15, 18,
14, 23, 1, 18, 23, 15, 1, 14, 23, 1, 18, 14, 15, 1,
14, 23, 15, 18, 23, 18, 1, 15, 14, 1, 23, 14, 18, 15,
14, 1, 15, 23, 18, 15, 14, 18, 1, 23, 18, 15, 23, 14,
1, 15, 16, 2, 19, 24, 16, 19, 15, 24, 2, 19, 24, 16,
2, 15, 24, 2, 19, 15, 16, 2, 15, 24, 16, 19, 24, 19,
2, 16, 15, 2, 24, 15, 19, 16, 15, 2, 16, 24, 19, 16,
15, 19, 2, 24, 19, 16, 24, 15, 2, 16, 17, 3, 20, 1,
17, 20, 16, 1, 3, 20, 1, 17, 3, 16, 1, 3, 20, 16, 17,
3, 16, 1, 17, 20, 1, 20, 3, 17, 16, 3, 1, 16, 20, 17,
16, 3, 17, 1, 20, 17, 16, 20, 3, 1, 20, 17, 1, 16, 3,
17, 18, 4, 21, 2, 18, 21, 17, 2, 4, 21, 2, 18, 4, 17,
2, 4, 21, 17, 18, 4, 17, 2, 18, 21, 2, 21, 4, 18, 17,
4, 2, 17, 21, 18, 17, 4, 18, 2, 21, 18, 17, 21, 4, 2,
21, 18, 2, 17, 4, 18, 19, 5, 22, 3, 19, 22, 18, 3, 5,
22, 3, 19, 5, 18, 3, 5, 22, 18, 19, 5, 18, 3, 19, 22,
3, 22, 5, 19, 18, 5, 3, 18, 22, 19, 18, 5, 19, 3, 22,
19, 18, 22, 5, 3, 22, 19, 3, 18, 5, 19, 20, 6, 23, 4,
20, 23, 19, 4, 6, 23, 4, 20, 6, 19, 4, 6, 23, 19, 20,
6, 19, 4, 20, 23, 4, 23, 6, 20, 19, 6, 4, 19, 23, 20,
19, 6, 20, 4, 23, 20, 19, 23, 6, 4, 23, 20, 4, 19, 6,
20, 21, 7, 24, 5, 21, 24, 20, 5, 7, 24, 5, 21, 7, 20,
5, 7, 24, 20, 21, 7, 20, 5, 21, 24, 5, 24, 7, 21, 20,
7, 5, 20, 24, 21, 20, 7, 21, 5, 24, 21, 20, 24, 7, 5,
24, 21, 5, 20, 7, 21, 22, 8, 1, 6, 22, 1, 21, 6, 8, 1,
6, 22, 8, 21, 6, 8, 1, 21, 22, 8, 21, 6, 22, 1, 6, 1,
8, 22, 21, 8, 6, 21, 1, 22, 21, 8, 22, 6, 1, 22, 21,
1, 8, 6, 1, 22, 6, 21, 8, 22, 23, 9, 2, 7, 23, 2, 22,
7, 9, 2, 7, 23, 9, 22, 7, 9, 2, 22, 23, 9, 22, 7, 23,
2, 7, 2, 9, 23, 22, 9, 7, 22, 2, 23, 22, 9, 23, 7, 2,
23, 22, 2, 9, 7, 2, 23, 7, 22, 9, 23, 24, 10, 3, 8,
24, 3, 23, 8, 10, 3, 8, 24, 10, 23, 8, 10, 3, 23, 24,
10, 23, 8, 24, 3, 8, 3, 10, 24, 23, 10, 8, 23, 3, 24,
23, 10, 24, 8, 3, 24, 23, 3, 10, 8, 3, 24, 8, 23, 10,
24, 1, 11, 4, 9, 1, 4, 24, 9, 11, 4, 9, 1, 11, 24, 9,
11, 4, 24, 1, 11, 24, 9, 1, 4, 9, 4, 11, 1, 24, 11, 9,
24, 4, 1, 24, 11, 1, 9, 4, 1, 24, 4, 11, 9, 4, 1, 9,
24, 11), 240, 5, byrow = T)
} else if (all(williams_D == 5, selection == 52, type == "SR")) {
sequences <- matrix(c(1, 2, 5, 3, 4, 2, 3, 1, 4, 5, 3, 4, 2, 5, 1, 4, 5, 3,
1, 2, 5, 1, 4, 2, 3, 4, 3, 5, 2, 1, 5, 4, 1, 3, 2, 1,
5, 2, 4, 3, 2, 1, 3, 5, 4, 3, 2, 4, 1, 5, 6, 7, 5, 8,
9, 7, 8, 6, 9, 5, 8, 9, 7, 5, 6, 9, 5, 8, 6, 7, 5, 6,
9, 7, 8, 9, 8, 5, 7, 6, 5, 9, 6, 8, 7, 6, 5, 7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 9, 2, 10, 6, 9, 10, 3, 6, 2, 3, 2, 9, 6,
10, 9, 3, 10, 2, 6, 10, 9, 6, 3, 2, 6, 10, 2, 9, 3, 2,
6, 3, 10, 9), 200, 5, byrow = T)
} else if (all(williams_D == 5, selection == 56, type == "SR")) {
sequences <- matrix(c(1, 2, 5, 3, 4, 2, 3, 1, 4, 5, 3, 4, 2, 5, 1, 4, 5, 3,
1, 2, 5, 1, 4, 2, 3, 4, 3, 5, 2, 1, 5, 4, 1, 3, 2, 1,
5, 2, 4, 3, 2, 1, 3, 5, 4, 3, 2, 4, 1, 5, 6, 7, 10, 8,
9, 7, 8, 6, 9, 10, 8, 9, 7, 10, 6, 9, 10, 8, 6, 7, 10,
6, 9, 7, 8, 9, 8, 10, 7, 6, 10, 9, 6, 8, 7, 6, 10, 7,
9, 8, 7, 6, 8, 10, 9, 8, 7, 9, 6, 10, 11, 12, 15, 13,
14, 12, 13, 11, 14, 15, 13, 14, 12, 15, 11, 14, 15,
13, 11, 12, 15, 11, 14, 12, 13, 14, 13, 15, 12, 11,
15, 14, 11, 13, 12, 11, 15, 12, 14, 13, 12, 11, 13,
15, 14, 13, 12, 14, 11, 15, 1, 7, 15, 3, 14, 7, 3, 1,
14, 15, 3, 14, 7, 15, 1, 14, 15, 3, 1, 7, 15, 1, 14,
7, 3, 14, 3, 15, 7, 1, 15, 14, 1, 3, 7, 1, 15, 7, 14,
3, 7, 1, 3, 15, 14, 3, 7, 14, 1, 15, 6, 12, 5, 8, 4,
12, 8, 6, 4, 5, 8, 4, 12, 5, 6, 4, 5, 8, 6, 12, 5, 6,
4, 12, 8, 4, 8, 5, 12, 6, 5, 4, 6, 8, 12, 6, 5, 12, 4,
8, 12, 6, 8, 5, 4, 8, 12, 4, 6, 5, 11, 2, 10, 13, 9,
2, 13, 11, 9, 10, 13, 9, 2, 10, 11, 9, 10, 13, 11, 2,
10, 11, 9, 2, 13, 9, 13, 10, 2, 11, 10, 9, 11, 13, 2,
11, 10, 2, 9, 13, 2, 11, 13, 10, 9, 13, 2, 9, 11, 10,
1, 7, 5, 13, 9, 7, 13, 1, 9, 5, 13, 9, 7, 5, 1, 9, 5,
13, 1, 7, 5, 1, 9, 7, 13, 9, 13, 5, 7, 1, 5, 9, 1, 13,
7, 1, 5, 7, 9, 13, 7, 1, 13, 5, 9, 13, 7, 9, 1, 5, 6,
12, 10, 3, 14, 12, 3, 6, 14, 10, 3, 14, 12, 10, 6, 14,
10, 3, 6, 12, 10, 6, 14, 12, 3, 14, 3, 10, 12, 6, 10,
14, 6, 3, 12, 6, 10, 12, 14, 3, 12, 6, 3, 10, 14, 3,
12, 14, 6, 10, 11, 2, 15, 8, 4, 2, 8, 11, 4, 15, 8, 4,
2, 15, 11, 4, 15, 8, 11, 2, 15, 11, 4, 2, 8, 4, 8, 15,
2, 11, 15, 4, 11, 8, 2, 11, 15, 2, 4, 8, 2, 11, 8, 15,
4, 8, 2, 4, 11, 15, 1, 2, 10, 8, 14, 2, 8, 1, 14, 10,
8, 14, 2, 10, 1, 14, 10, 8, 1, 2, 10, 1, 14, 2, 8, 14,
8, 10, 2, 1, 10, 14, 1, 8, 2, 1, 10, 2, 14, 8, 2, 1,
8, 10, 14, 8, 2, 14, 1, 10, 6, 7, 15, 13, 4, 7, 13, 6,
4, 15, 13, 4, 7, 15, 6, 4, 15, 13, 6, 7, 15, 6, 4, 7,
13, 4, 13, 15, 7, 6, 15, 4, 6, 13, 7, 6, 15, 7, 4, 13,
7, 6, 13, 15, 4, 13, 7, 4, 6, 15, 11, 12, 5, 3, 9, 12,
3, 11, 9, 5, 3, 9, 12, 5, 11, 9, 5, 3, 11, 12, 5, 11,
9, 12, 3, 9, 3, 5, 12, 11, 5, 9, 11, 3, 12, 11, 5, 12,
9, 3, 12, 11, 3, 5, 9, 3, 12, 9, 11, 5, 1, 12, 10, 13,
4, 12, 13, 1, 4, 10, 13, 4, 12, 10, 1, 4, 10, 13, 1,
12, 10, 1, 4, 12, 13, 4, 13, 10, 12, 1, 10, 4, 1, 13,
12, 1, 10, 12, 4, 13, 12, 1, 13, 10, 4, 13, 12, 4, 1,
10, 6, 2, 15, 3, 9, 2, 3, 6, 9, 15, 3, 9, 2, 15, 6, 9,
15, 3, 6, 2, 15, 6, 9, 2, 3, 9, 3, 15, 2, 6, 15, 9, 6,
3, 2, 6, 15, 2, 9, 3, 2, 6, 3, 15, 9, 3, 2, 9, 6, 15,
11, 7, 5, 8, 14, 7, 8, 11, 14, 5, 8, 14, 7, 5, 11, 14,
5, 8, 11, 7, 5, 11, 14, 7, 8, 14, 8, 5, 7, 11, 5, 14,
11, 8, 7, 11, 5, 7, 14, 8, 7, 11, 8, 5, 14, 8, 7, 14,
11, 5, 1, 12, 15, 8, 9, 12, 8, 1, 9, 15, 8, 9, 12, 15,
1, 9, 15, 8, 1, 12, 15, 1, 9, 12, 8, 9, 8, 15, 12, 1,
15, 9, 1, 8, 12, 1, 15, 12, 9, 8, 12, 1, 8, 15, 9, 8,
12, 9, 1, 15, 6, 2, 5, 13, 14, 2, 13, 6, 14, 5, 13,
14, 2, 5, 6, 14, 5, 13, 6, 2, 5, 6, 14, 2, 13, 14, 13,
5, 2, 6, 5, 14, 6, 13, 2, 6, 5, 2, 14, 13, 2, 6, 13,
5, 14, 13, 2, 14, 6, 5, 11, 7, 10, 3, 4, 7, 3, 11, 4,
10, 3, 4, 7, 10, 11, 4, 10, 3, 11, 7, 10, 11, 4, 7, 3,
4, 3, 10, 7, 11, 10, 4, 11, 3, 7, 11, 10, 7, 4, 3, 7,
11, 3, 10, 4, 3, 7, 4, 11, 10), 180, 5, byrow = T)
} else if (all(williams_D == 5, selection == 60, type == "SR")) {
sequences <- matrix(c(1, 2, 5, 3, 4, 2, 3, 1, 4, 5, 3, 4, 2, 5, 1, 4, 5, 3,
1, 2, 5, 1, 4, 2, 3, 4, 3, 5, 2, 1, 5, 4, 1, 3, 2, 1,
5, 2, 4, 3, 2, 1, 3, 5, 4, 3, 2, 4, 1, 5, 6, 7, 10, 8,
9, 7, 8, 6, 9, 10, 8, 9, 7, 10, 6, 9, 10, 8, 6, 7, 10,
6, 9, 7, 8, 9, 8, 10, 7, 6, 10, 9, 6, 8, 7, 6, 10, 7,
9, 8, 7, 6, 8, 10, 9, 8, 7, 9, 6, 10, 11, 12, 15, 13,
14, 12, 13, 11, 14, 15, 13, 14, 12, 15, 11, 14, 15,
13, 11, 12, 15, 11, 14, 12, 13, 14, 13, 15, 12, 11,
15, 14, 11, 13, 12, 11, 15, 12, 14, 13, 12, 11, 13,
15, 14, 13, 12, 14, 11, 15, 16, 17, 20, 18, 19, 17,
18, 16, 19, 20, 18, 19, 17, 20, 16, 19, 20, 18, 16,
17, 20, 16, 19, 17, 18, 19, 18, 20, 17, 16, 20, 19,
16, 18, 17, 16, 20, 17, 19, 18, 17, 16, 18, 20, 19,
18, 17, 19, 16, 20, 21, 22, 25, 23, 24, 22, 23, 21,
24, 25, 23, 24, 22, 25, 21, 24, 25, 23, 21, 22, 25,
21, 24, 22, 23, 24, 23, 25, 22, 21, 25, 24, 21, 23,
22, 21, 25, 22, 24, 23, 22, 21, 23, 25, 24, 23, 22,
24, 21, 25, 1, 7, 25, 13, 19, 7, 13, 1, 19, 25, 13,
19, 7, 25, 1, 19, 25, 13, 1, 7, 25, 1, 19, 7, 13, 19,
13, 25, 7, 1, 25, 19, 1, 13, 7, 1, 25, 7, 19, 13, 7,
1, 13, 25, 19, 13, 7, 19, 1, 25, 2, 8, 21, 14, 20, 8,
14, 2, 20, 21, 14, 20, 8, 21, 2, 20, 21, 14, 2, 8, 21,
2, 20, 8, 14, 20, 14, 21, 8, 2, 21, 20, 2, 14, 8, 2,
21, 8, 20, 14, 8, 2, 14, 21, 20, 14, 8, 20, 2, 21, 3,
9, 22, 15, 16, 9, 15, 3, 16, 22, 15, 16, 9, 22, 3, 16,
22, 15, 3, 9, 22, 3, 16, 9, 15, 16, 15, 22, 9, 3, 22,
16, 3, 15, 9, 3, 22, 9, 16, 15, 9, 3, 15, 22, 16, 15,
9, 16, 3, 22, 4, 10, 23, 11, 17, 10, 11, 4, 17, 23,
11, 17, 10, 23, 4, 17, 23, 11, 4, 10, 23, 4, 17, 10,
11, 17, 11, 23, 10, 4, 23, 17, 4, 11, 10, 4, 23, 10,
17, 11, 10, 4, 11, 23, 17, 11, 10, 17, 4, 23, 5, 6,
24, 12, 18, 6, 12, 5, 18, 24, 12, 18, 6, 24, 5, 18,
24, 12, 5, 6, 24, 5, 18, 6, 12, 18, 12, 24, 6, 5, 24,
18, 5, 12, 6, 5, 24, 6, 18, 12, 6, 5, 12, 24, 18, 12,
6, 18, 5, 24, 1, 10, 22, 14, 18, 10, 14, 1, 18, 22,
14, 18, 10, 22, 1, 18, 22, 14, 1, 10, 22, 1, 18, 10,
14, 18, 14, 22, 10, 1, 22, 18, 1, 14, 10, 1, 22, 10,
18, 14, 10, 1, 14, 22, 18, 14, 10, 18, 1, 22, 2, 6,
23, 15, 19, 6, 15, 2, 19, 23, 15, 19, 6, 23, 2, 19,
23, 15, 2, 6, 23, 2, 19, 6, 15, 19, 15, 23, 6, 2, 23,
19, 2, 15, 6, 2, 23, 6, 19, 15, 6, 2, 15, 23, 19, 15,
6, 19, 2, 23, 3, 7, 24, 11, 20, 7, 11, 3, 20, 24, 11,
20, 7, 24, 3, 20, 24, 11, 3, 7, 24, 3, 20, 7, 11, 20,
11, 24, 7, 3, 24, 20, 3, 11, 7, 3, 24, 7, 20, 11, 7,
3, 11, 24, 20, 11, 7, 20, 3, 24, 4, 8, 25, 12, 16, 8,
12, 4, 16, 25, 12, 16, 8, 25, 4, 16, 25, 12, 4, 8, 25,
4, 16, 8, 12, 16, 12, 25, 8, 4, 25, 16, 4, 12, 8, 4,
25, 8, 16, 12, 8, 4, 12, 25, 16, 12, 8, 16, 4, 25, 5,
9, 21, 13, 17, 9, 13, 5, 17, 21, 13, 17, 9, 21, 5, 17,
21, 13, 5, 9, 21, 5, 17, 9, 13, 17, 13, 21, 9, 5, 21,
17, 5, 13, 9, 5, 21, 9, 17, 13, 9, 5, 13, 21, 17, 13,
9, 17, 5, 21, 1, 9, 23, 12, 20, 9, 12, 1, 20, 23, 12,
20, 9, 23, 1, 20, 23, 12, 1, 9, 23, 1, 20, 9, 12, 20,
12, 23, 9, 1, 23, 20, 1, 12, 9, 1, 23, 9, 20, 12, 9,
1, 12, 23, 20, 12, 9, 20, 1, 23, 2, 10, 24, 13, 16,
10, 13, 2, 16, 24, 13, 16, 10, 24, 2, 16, 24, 13, 2,
10, 24, 2, 16, 10, 13, 16, 13, 24, 10, 2, 24, 16, 2,
13, 10, 2, 24, 10, 16, 13, 10, 2, 13, 24, 16, 13, 10,
16, 2, 24, 3, 6, 25, 14, 17, 6, 14, 3, 17, 25, 14, 17,
6, 25, 3, 17, 25, 14, 3, 6, 25, 3, 17, 6, 14, 17, 14,
25, 6, 3, 25, 17, 3, 14, 6, 3, 25, 6, 17, 14, 6, 3,
14, 25, 17, 14, 6, 17, 3, 25, 4, 7, 21, 15, 18, 7, 15,
4, 18, 21, 15, 18, 7, 21, 4, 18, 21, 15, 4, 7, 21, 4,
18, 7, 15, 18, 15, 21, 7, 4, 21, 18, 4, 15, 7, 4, 21,
7, 18, 15, 7, 4, 15, 21, 18, 15, 7, 18, 4, 21, 5, 8,
22, 11, 19, 8, 11, 5, 19, 22, 11, 19, 8, 22, 5, 19,
22, 11, 5, 8, 22, 5, 19, 8, 11, 19, 11, 22, 8, 5, 22,
19, 5, 11, 8, 5, 22, 8, 19, 11, 8, 5, 11, 22, 19, 11,
8, 19, 5, 22, 1, 8, 24, 15, 17, 8, 15, 1, 17, 24, 15,
17, 8, 24, 1, 17, 24, 15, 1, 8, 24, 1, 17, 8, 15, 17,
15, 24, 8, 1, 24, 17, 1, 15, 8, 1, 24, 8, 17, 15, 8,
1, 15, 24, 17, 15, 8, 17, 1, 24, 2, 9, 25, 11, 18, 9,
11, 2, 18, 25, 11, 18, 9, 25, 2, 18, 25, 11, 2, 9, 25,
2, 18, 9, 11, 18, 11, 25, 9, 2, 25, 18, 2, 11, 9, 2,
25, 9, 18, 11, 9, 2, 11, 25, 18, 11, 9, 18, 2, 25, 3,
10, 21, 12, 19, 10, 12, 3, 19, 21, 12, 19, 10, 21, 3,
19, 21, 12, 3, 10, 21, 3, 19, 10, 12, 19, 12, 21, 10,
3, 21, 19, 3, 12, 10, 3, 21, 10, 19, 12, 10, 3, 12,
21, 19, 12, 10, 19, 3, 21, 4, 6, 22, 13, 20, 6, 13, 4,
20, 22, 13, 20, 6, 22, 4, 20, 22, 13, 4, 6, 22, 4, 20,
6, 13, 20, 13, 22, 6, 4, 22, 20, 4, 13, 6, 4, 22, 6,
20, 13, 6, 4, 13, 22, 20, 13, 6, 20, 4, 22, 5, 7, 23,
14, 16, 7, 14, 5, 16, 23, 14, 16, 7, 23, 5, 16, 23,
14, 5, 7, 23, 5, 16, 7, 14, 16, 14, 23, 7, 5, 23, 16,
5, 14, 7, 5, 23, 7, 16, 14, 7, 5, 14, 23, 16, 14, 7,
16, 5, 23), 250, 5, byrow = T)
} else if (all(williams_D == 6, selection == 164, type == "R")) {
sequences <- matrix(c(1, 3, 4, 5, 2, 7, 3, 5, 1, 7, 4, 2, 5, 7, 3, 2, 1, 4,
7, 2, 5, 4, 3, 1, 2, 4, 7, 1, 5, 3, 4, 1, 2, 3, 7, 5,
1, 3, 8, 5, 6, 7, 3, 5, 1, 7, 8, 6, 5, 7, 3, 6, 1, 8,
7, 6, 5, 8, 3, 1, 6, 8, 7, 1, 5, 3, 8, 1, 6, 3, 7, 5,
2, 4, 3, 6, 1, 8, 4, 6, 2, 8, 3, 1, 6, 8, 4, 1, 2, 3,
8, 1, 6, 3, 4, 2, 1, 3, 8, 2, 6, 4, 3, 2, 1, 4, 8, 6,
2, 4, 7, 6, 5, 8, 4, 6, 2, 8, 7, 5, 6, 8, 4, 5, 2, 7,
8, 5, 6, 7, 4, 2, 5, 7, 8, 2, 6, 4, 7, 2, 5, 4, 8, 6,
1, 3, 6, 5, 2, 7, 3, 5, 1, 7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1, 8, 6, 7, 1, 5, 6, 3, 8,
1, 6, 9, 8, 4, 2, 6, 8, 1, 2, 9, 4, 8, 2, 6, 4, 1, 9,
2, 4, 8, 9, 6, 1, 4, 9, 2, 1, 8, 6, 9, 1, 4, 6, 2, 8,
1, 4, 8, 7, 5, 2, 4, 7, 1, 2, 8, 5, 7, 2, 4, 5, 1, 8,
2, 5, 7, 8, 4, 1, 5, 8, 2, 1, 7, 4, 8, 1, 5, 4, 2, 7,
2, 5, 9, 8, 6, 3, 5, 8, 2, 3, 9, 6, 8, 3, 5, 6, 2, 9,
3, 6, 8, 9, 5, 2, 6, 9, 3, 2, 8, 5, 9, 2, 6, 5, 3, 8,
3, 6, 7, 9, 4, 1, 6, 9, 3, 1, 7, 4, 9, 1, 6, 4, 3, 7,
1, 4, 9, 7, 6, 3, 4, 7, 1, 3, 9, 6, 7, 3, 4, 6, 1, 9),
90, 6, byrow = T)
} else if (all(williams_D == 6, selection == 169, type == "R")) {
sequences <- matrix(c(1, 7, 14, 13, 8, 2, 7, 13, 1, 2, 14, 8, 13, 2, 7, 8,
1, 14, 2, 8, 13, 14, 7, 1, 8, 14, 2, 1, 13, 7, 14, 1,
8, 7, 2, 13, 1, 7, 15, 13, 9, 3, 7, 13, 1, 3, 15, 9,
13, 3, 7, 9, 1, 15, 3, 9, 13, 15, 7, 1, 9, 15, 3, 1,
13, 7, 15, 1, 9, 7, 3, 13, 2, 8, 15, 14, 9, 3, 8, 14,
2, 3, 15, 9, 14, 3, 8, 9, 2, 15, 3, 9, 14, 15, 8, 2,
9, 15, 3, 2, 14, 8, 15, 2, 9, 8, 3, 14, 4, 10, 17, 16,
11, 5, 10, 16, 4, 5, 17, 11, 16, 5, 10, 11, 4, 17, 5,
11, 16, 17, 10, 4, 11, 17, 5, 4, 16, 10, 17, 4, 11,
10, 5, 16, 4, 10, 18, 16, 12, 6, 10, 16, 4, 6, 18, 12,
16, 6, 10, 12, 4, 18, 6, 12, 16, 18, 10, 4, 12, 18, 6,
4, 16, 10, 18, 4, 12, 10, 6, 16, 5, 11, 18, 17, 12, 6,
11, 17, 5, 6, 18, 12, 17, 6, 11, 12, 5, 18, 6, 12, 17,
18, 11, 5, 12, 18, 6, 5, 17, 11, 18, 5, 12, 11, 6, 17,
1, 7, 6, 13, 5, 4, 7, 13, 1, 4, 6, 5, 13, 4, 7, 5, 1,
6, 4, 5, 13, 6, 7, 1, 5, 6, 4, 1, 13, 7, 6, 1, 5, 7,
4, 13, 1, 7, 12, 13, 11, 10, 7, 13, 1, 10, 12, 11, 13,
10, 7, 11, 1, 12, 10, 11, 13, 12, 7, 1, 11, 12, 10, 1,
13, 7, 12, 1, 11, 7, 10, 13, 1, 7, 18, 13, 17, 16, 7,
13, 1, 16, 18, 17, 13, 16, 7, 17, 1, 18, 16, 17, 13,
18, 7, 1, 17, 18, 16, 1, 13, 7, 18, 1, 17, 7, 16, 13,
2, 8, 18, 14, 11, 4, 8, 14, 2, 4, 18, 11, 14, 4, 8,
11, 2, 18, 4, 11, 14, 18, 8, 2, 11, 18, 4, 2, 14, 8,
18, 2, 11, 8, 4, 14, 2, 8, 17, 14, 10, 6, 8, 14, 2, 6,
17, 10, 14, 6, 8, 10, 2, 17, 6, 10, 14, 17, 8, 2, 10,
17, 6, 2, 14, 8, 17, 2, 10, 8, 6, 14, 2, 8, 16, 14,
12, 5, 8, 14, 2, 5, 16, 12, 14, 5, 8, 12, 2, 16, 5,
12, 14, 16, 8, 2, 12, 16, 5, 2, 14, 8, 16, 2, 12, 8,
5, 14, 3, 9, 17, 15, 12, 4, 9, 15, 3, 4, 17, 12, 15,
4, 9, 12, 3, 17, 4, 12, 15, 17, 9, 3, 12, 17, 4, 3,
15, 9, 17, 3, 12, 9, 4, 15, 3, 9, 18, 15, 10, 5, 9,
15, 3, 5, 18, 10, 15, 5, 9, 10, 3, 18, 5, 10, 15, 18,
9, 3, 10, 18, 5, 3, 15, 9, 18, 3, 10, 9, 5, 15, 3, 9,
16, 15, 11, 6, 9, 15, 3, 6, 16, 11, 15, 6, 9, 11, 3,
16, 6, 11, 15, 16, 9, 3, 11, 16, 6, 3, 15, 9, 16, 3,
11, 9, 6, 15, 4, 10, 3, 16, 2, 1, 10, 16, 4, 1, 3, 2,
16, 1, 10, 2, 4, 3, 1, 2, 16, 3, 10, 4, 2, 3, 1, 4,
16, 10, 3, 4, 2, 10, 1, 16, 4, 10, 9, 16, 8, 7, 10,
16, 4, 7, 9, 8, 16, 7, 10, 8, 4, 9, 7, 8, 16, 9, 10,
4, 8, 9, 7, 4, 16, 10, 9, 4, 8, 10, 7, 16, 4, 10, 15,
16, 14, 13, 10, 16, 4, 13, 15, 14, 16, 13, 10, 14, 4,
15, 13, 14, 16, 15, 10, 4, 14, 15, 13, 4, 16, 10, 15,
4, 14, 10, 13, 16, 5, 11, 15, 17, 8, 1, 11, 17, 5, 1,
15, 8, 17, 1, 11, 8, 5, 15, 1, 8, 17, 15, 11, 5, 8,
15, 1, 5, 17, 11, 15, 5, 8, 11, 1, 17, 5, 11, 14, 17,
7, 3, 11, 17, 5, 3, 14, 7, 17, 3, 11, 7, 5, 14, 3, 7,
17, 14, 11, 5, 7, 14, 3, 5, 17, 11, 14, 5, 7, 11, 3,
17, 5, 11, 13, 17, 9, 2, 11, 17, 5, 2, 13, 9, 17, 2,
11, 9, 5, 13, 2, 9, 17, 13, 11, 5, 9, 13, 2, 5, 17,
11, 13, 5, 9, 11, 2, 17, 6, 12, 14, 18, 9, 1, 12, 18,
6, 1, 14, 9, 18, 1, 12, 9, 6, 14, 1, 9, 18, 14, 12, 6,
9, 14, 1, 6, 18, 12, 14, 6, 9, 12, 1, 18, 6, 12, 15,
18, 7, 2, 12, 18, 6, 2, 15, 7, 18, 2, 12, 7, 6, 15, 2,
7, 18, 15, 12, 6, 7, 15, 2, 6, 18, 12, 15, 6, 7, 12,
2, 18, 6, 12, 13, 18, 8, 3, 12, 18, 6, 3, 13, 8, 18,
3, 12, 8, 6, 13, 3, 8, 18, 13, 12, 6, 8, 13, 3, 6, 18,
12, 13, 6, 8, 12, 3, 18), 144, 6, byrow = T)
} else if (all(williams_D == 6, selection == 170, type == "R")) {
sequences <- matrix(c(1, 10, 4, 19, 5, 6, 10, 19, 1, 6, 4, 5, 19, 6, 10, 5,
1, 4, 6, 5, 19, 4, 10, 1, 5, 4, 6, 1, 19, 10, 4, 1, 5,
10, 6, 19, 14, 1, 15, 10, 19, 13, 1, 10, 14, 13, 15,
19, 10, 13, 1, 19, 14, 15, 13, 19, 10, 15, 1, 14, 19,
15, 13, 14, 10, 1, 15, 14, 19, 1, 13, 10, 19, 22, 24,
1, 10, 23, 22, 1, 19, 23, 24, 10, 1, 23, 22, 10, 19,
24, 23, 10, 1, 24, 22, 19, 10, 24, 23, 19, 1, 22, 24,
19, 10, 22, 23, 1, 2, 11, 14, 20, 4, 24, 11, 20, 2,
24, 14, 4, 20, 24, 11, 4, 2, 14, 24, 4, 20, 14, 11, 2,
4, 14, 24, 2, 20, 11, 14, 2, 4, 11, 24, 20, 15, 2, 5,
11, 22, 20, 2, 11, 15, 20, 5, 22, 11, 20, 2, 22, 15,
5, 20, 22, 11, 5, 2, 15, 22, 5, 20, 15, 11, 2, 5, 15,
22, 2, 20, 11, 20, 23, 13, 2, 6, 11, 23, 2, 20, 11,
13, 6, 2, 11, 23, 6, 20, 13, 11, 6, 2, 13, 23, 20, 6,
13, 11, 20, 2, 23, 13, 20, 6, 23, 11, 2, 3, 15, 21,
23, 12, 4, 15, 23, 3, 4, 21, 12, 23, 4, 15, 12, 3, 21,
4, 12, 23, 21, 15, 3, 12, 21, 4, 3, 23, 15, 21, 3, 12,
15, 4, 23, 5, 13, 12, 24, 3, 21, 13, 24, 5, 21, 12, 3,
24, 21, 13, 3, 5, 12, 21, 3, 24, 12, 13, 5, 3, 12, 21,
5, 24, 13, 12, 5, 3, 13, 21, 24, 6, 12, 3, 22, 21, 14,
12, 22, 6, 14, 3, 21, 22, 14, 12, 21, 6, 3, 14, 21,
22, 3, 12, 6, 21, 3, 14, 6, 22, 12, 3, 6, 21, 12, 14,
22, 22, 4, 9, 13, 8, 7, 4, 13, 22, 7, 9, 8, 13, 7, 4,
8, 22, 9, 7, 8, 13, 9, 4, 22, 8, 9, 7, 22, 13, 4, 9,
22, 8, 4, 7, 13, 13, 16, 18, 4, 17, 22, 16, 4, 13, 22,
18, 17, 4, 22, 16, 17, 13, 18, 22, 17, 4, 18, 16, 13,
17, 18, 22, 13, 4, 16, 18, 13, 17, 16, 22, 4, 4, 26,
22, 27, 13, 25, 26, 27, 4, 25, 22, 13, 27, 25, 26, 13,
4, 22, 25, 13, 27, 22, 26, 4, 13, 22, 25, 4, 27, 26,
22, 4, 13, 26, 25, 27, 23, 5, 17, 14, 7, 27, 5, 14,
23, 27, 17, 7, 14, 27, 5, 7, 23, 17, 27, 7, 14, 17, 5,
23, 7, 17, 27, 23, 14, 5, 17, 23, 7, 5, 27, 14, 8, 25,
23, 5, 14, 18, 25, 5, 8, 18, 23, 14, 5, 18, 25, 14, 8,
23, 18, 14, 5, 23, 25, 8, 14, 23, 18, 8, 5, 25, 23, 8,
14, 25, 18, 5, 16, 14, 26, 9, 23, 5, 14, 9, 16, 5, 26,
23, 9, 5, 14, 23, 16, 26, 5, 23, 9, 26, 14, 16, 23,
26, 5, 16, 9, 14, 26, 16, 23, 14, 5, 9, 18, 6, 7, 26,
24, 15, 6, 26, 18, 15, 7, 24, 26, 15, 6, 24, 18, 7,
15, 24, 26, 7, 6, 18, 24, 7, 15, 18, 26, 6, 7, 18, 24,
6, 15, 26, 24, 27, 8, 6, 15, 16, 27, 6, 24, 16, 8, 15,
6, 16, 27, 15, 24, 8, 16, 15, 6, 8, 27, 24, 15, 8, 16,
24, 6, 27, 8, 24, 15, 27, 16, 6, 9, 24, 6, 15, 25, 17,
24, 15, 9, 17, 6, 25, 15, 17, 24, 25, 9, 6, 17, 25,
15, 6, 24, 9, 25, 6, 17, 9, 15, 24, 6, 9, 25, 24, 17,
15, 7, 3, 25, 16, 2, 1, 3, 16, 7, 1, 25, 2, 16, 1, 3,
2, 7, 25, 1, 2, 16, 25, 3, 7, 2, 25, 1, 7, 16, 3, 25,
7, 2, 3, 1, 16, 12, 7, 16, 25, 11, 10, 7, 25, 12, 10,
16, 11, 25, 10, 7, 11, 12, 16, 10, 11, 25, 16, 7, 12,
11, 16, 10, 12, 25, 7, 16, 12, 11, 7, 10, 25, 25, 21,
20, 7, 16, 19, 21, 7, 25, 19, 20, 16, 7, 19, 21, 16,
25, 20, 19, 16, 7, 20, 21, 25, 16, 20, 19, 25, 7, 21,
20, 25, 16, 21, 19, 7, 21, 8, 11, 17, 1, 26, 8, 17,
21, 26, 11, 1, 17, 26, 8, 1, 21, 11, 26, 1, 17, 11, 8,
21, 1, 11, 26, 21, 17, 8, 11, 21, 1, 8, 26, 17, 17,
19, 2, 8, 26, 12, 19, 8, 17, 12, 2, 26, 8, 12, 19, 26,
17, 2, 12, 26, 8, 2, 19, 17, 26, 2, 12, 17, 8, 19, 2,
17, 26, 19, 12, 8, 26, 17, 10, 3, 20, 8, 17, 3, 26, 8,
10, 20, 3, 8, 17, 20, 26, 10, 8, 20, 3, 10, 17, 26,
20, 10, 8, 26, 3, 17, 10, 26, 20, 17, 8, 3, 27, 20, 1,
12, 18, 9, 20, 12, 27, 9, 1, 18, 12, 9, 20, 18, 27, 1,
9, 18, 12, 1, 20, 27, 18, 1, 9, 27, 12, 20, 1, 27, 18,
20, 9, 12, 10, 18, 27, 21, 9, 2, 18, 21, 10, 2, 27, 9,
21, 2, 18, 9, 10, 27, 2, 9, 21, 27, 18, 10, 9, 27, 2,
10, 21, 18, 27, 10, 9, 18, 2, 21, 11, 9, 19, 18, 27,
3, 9, 18, 11, 3, 19, 27, 18, 3, 9, 27, 11, 19, 3, 27,
18, 19, 9, 11, 27, 19, 3, 11, 18, 9, 19, 11, 27, 9, 3,
18), 162, 6, byrow = T)
} else if (all(williams_D == 6, selection == 171, type == "R")) {
sequences <- matrix(c(2, 9, 26, 3, 17, 5, 9, 3, 2, 5, 26, 17, 3, 5, 9, 17,
2, 26, 5, 17, 3, 26, 9, 2, 17, 26, 5, 2, 3, 9, 26, 2,
17, 9, 5, 3, 17, 16, 12, 23, 19, 3, 16, 23, 17, 3, 12,
19, 23, 3, 16, 19, 17, 12, 3, 19, 23, 12, 16, 17, 19,
12, 3, 17, 23, 16, 12, 17, 19, 16, 3, 23, 9, 2, 24,
19, 12, 10, 2, 19, 9, 10, 24, 12, 19, 10, 2, 12, 9,
24, 10, 12, 19, 24, 2, 9, 12, 24, 10, 9, 19, 2, 24, 9,
12, 2, 10, 19, 16, 23, 5, 10, 26, 24, 23, 10, 16, 24,
5, 26, 10, 24, 23, 26, 16, 5, 24, 26, 10, 5, 23, 16,
26, 5, 24, 16, 10, 23, 5, 16, 26, 23, 24, 10, 1, 15,
3, 7, 24, 14, 15, 7, 1, 14, 3, 24, 7, 14, 15, 24, 1,
3, 14, 24, 7, 3, 15, 1, 24, 3, 14, 1, 7, 15, 3, 1, 24,
15, 14, 7, 10, 17, 28, 1, 21, 15, 17, 1, 10, 15, 28,
21, 1, 15, 17, 21, 10, 28, 15, 21, 1, 28, 17, 10, 21,
28, 15, 10, 1, 17, 28, 10, 21, 17, 15, 1, 22, 8, 21,
24, 3, 28, 8, 24, 22, 28, 21, 3, 24, 28, 8, 3, 22, 21,
28, 3, 24, 21, 8, 22, 3, 21, 28, 22, 24, 8, 21, 22, 3,
8, 28, 24, 8, 22, 17, 14, 10, 7, 22, 14, 8, 7, 17, 10,
14, 7, 22, 10, 8, 17, 7, 10, 14, 17, 22, 8, 10, 17, 7,
8, 14, 22, 17, 8, 10, 22, 7, 14, 4, 1, 16, 25, 8, 2,
1, 25, 4, 2, 16, 8, 25, 2, 1, 8, 4, 16, 2, 8, 25, 16,
1, 4, 8, 16, 2, 4, 25, 1, 16, 4, 8, 1, 2, 25, 23, 25,
4, 15, 22, 9, 25, 15, 23, 9, 4, 22, 15, 9, 25, 22, 23,
4, 9, 22, 15, 4, 25, 23, 22, 4, 9, 23, 15, 25, 4, 23,
22, 25, 9, 15, 18, 11, 8, 9, 1, 23, 11, 9, 18, 23, 8,
1, 9, 23, 11, 1, 18, 8, 23, 1, 9, 8, 11, 18, 1, 8, 23,
18, 9, 11, 8, 18, 1, 11, 23, 9, 11, 18, 15, 2, 16, 22,
18, 2, 11, 22, 15, 16, 2, 22, 18, 16, 11, 15, 22, 16,
2, 15, 18, 11, 16, 15, 22, 11, 2, 18, 15, 11, 16, 18,
22, 2, 3, 10, 27, 6, 4, 18, 10, 6, 3, 18, 27, 4, 6,
18, 10, 4, 3, 27, 18, 4, 6, 27, 10, 3, 4, 27, 18, 3,
6, 10, 27, 3, 4, 10, 18, 6, 27, 24, 25, 17, 6, 11, 24,
17, 27, 11, 25, 6, 17, 11, 24, 6, 27, 25, 11, 6, 17,
25, 24, 27, 6, 25, 11, 27, 17, 24, 25, 27, 6, 24, 11,
17, 24, 4, 20, 18, 13, 17, 4, 18, 24, 17, 20, 13, 18,
17, 4, 13, 24, 20, 17, 13, 18, 20, 4, 24, 13, 20, 17,
24, 18, 4, 20, 24, 13, 4, 17, 18, 25, 3, 10, 13, 11,
20, 3, 13, 25, 20, 10, 11, 13, 20, 3, 11, 25, 10, 20,
11, 13, 10, 3, 25, 11, 10, 20, 25, 13, 3, 10, 25, 11,
3, 20, 13, 6, 5, 22, 12, 20, 1, 5, 12, 6, 1, 22, 20,
12, 1, 5, 20, 6, 22, 1, 20, 12, 22, 5, 6, 20, 22, 1,
6, 12, 5, 22, 6, 20, 5, 1, 12, 15, 27, 13, 8, 5, 12,
27, 8, 15, 12, 13, 5, 8, 12, 27, 5, 15, 13, 12, 5, 8,
13, 27, 15, 5, 13, 12, 15, 8, 27, 13, 15, 5, 27, 12,
8, 20, 19, 6, 26, 15, 8, 19, 26, 20, 8, 6, 15, 26, 8,
19, 15, 20, 6, 8, 15, 26, 6, 19, 20, 15, 6, 8, 20, 26,
19, 6, 20, 15, 19, 8, 26, 26, 13, 1, 22, 27, 19, 13,
22, 26, 19, 1, 27, 22, 19, 13, 27, 26, 1, 19, 27, 22,
1, 13, 26, 27, 1, 19, 26, 22, 13, 1, 26, 27, 13, 19,
22, 5, 28, 19, 11, 7, 4, 28, 11, 5, 4, 19, 7, 11, 4,
28, 7, 5, 19, 4, 7, 11, 19, 28, 5, 7, 19, 4, 5, 11,
28, 19, 5, 7, 28, 4, 11, 7, 12, 18, 28, 25, 26, 12,
28, 7, 26, 18, 25, 28, 26, 12, 25, 7, 18, 26, 25, 28,
18, 12, 7, 25, 18, 26, 7, 28, 12, 18, 7, 25, 12, 26,
28, 19, 21, 14, 5, 18, 25, 21, 5, 19, 25, 14, 18, 5,
25, 21, 18, 19, 14, 25, 18, 5, 14, 21, 19, 18, 14, 25,
19, 5, 21, 14, 19, 18, 21, 25, 5, 12, 26, 11, 4, 14,
21, 26, 4, 12, 21, 11, 14, 4, 21, 26, 14, 12, 11, 21,
14, 4, 11, 26, 12, 14, 11, 21, 12, 4, 26, 11, 12, 14,
26, 21, 4, 13, 7, 2, 21, 23, 6, 7, 21, 13, 6, 2, 23,
21, 6, 7, 23, 13, 2, 6, 23, 21, 2, 7, 13, 23, 2, 6,
13, 21, 7, 2, 13, 23, 7, 6, 21, 28, 14, 23, 20, 2, 27,
14, 20, 28, 27, 23, 2, 20, 27, 14, 2, 28, 23, 27, 2,
20, 23, 14, 28, 2, 23, 27, 28, 20, 14, 23, 28, 2, 14,
27, 20, 21, 20, 7, 27, 9, 16, 20, 27, 21, 16, 7, 9,
27, 16, 20, 9, 21, 7, 16, 9, 27, 7, 20, 21, 9, 7, 16,
21, 27, 20, 7, 21, 9, 20, 16, 27, 14, 6, 9, 16, 28,
13, 6, 16, 14, 13, 9, 28, 16, 13, 6, 28, 14, 9, 13,
28, 16, 9, 6, 14, 28, 9, 13, 14, 16, 6, 9, 14, 28, 6,
13, 16), 168, 6, byrow = T)
} else if (all(williams_D == 6, selection == 18, type == "S")) {
sequences <- matrix(c(1, 5, 6, 2, 3, 7, 5, 2, 1, 7, 6, 3, 2, 7, 5, 3, 1, 6,
7, 3, 2, 6, 5, 1, 3, 6, 7, 1, 2, 5, 6, 1, 3, 5, 7, 2,
2, 6, 7, 3, 4, 8, 6, 3, 2, 8, 7, 4, 3, 8, 6, 4, 2, 7,
8, 4, 3, 7, 6, 2, 4, 7, 8, 2, 3, 6, 7, 2, 4, 6, 8, 3,
3, 7, 8, 4, 1, 5, 7, 4, 3, 5, 8, 1, 4, 5, 7, 1, 3, 8,
5, 1, 4, 8, 7, 3, 1, 8, 5, 3, 4, 7, 8, 3, 1, 7, 5, 4,
4, 8, 5, 1, 2, 6, 8, 1, 4, 6, 5, 2, 1, 6, 8, 2, 4, 5,
6, 2, 1, 5, 8, 4, 2, 5, 6, 4, 1, 8, 5, 4, 2, 8, 6, 1),
24, 6, byrow = T)
} else if (all(williams_D == 6, selection == 21, type == "S")) {
sequences <- matrix(c(1, 4, 8, 7, 5, 2, 4, 7, 1, 2, 8, 5, 7, 2, 4, 5, 1, 8,
2, 5, 7, 8, 4, 1, 5, 8, 2, 1, 7, 4, 8, 1, 5, 4, 2, 7,
2, 5, 9, 8, 6, 3, 5, 8, 2, 3, 9, 6, 8, 3, 5, 6, 2, 9,
3, 6, 8, 9, 5, 2, 6, 9, 3, 2, 8, 5, 9, 2, 6, 5, 3, 8,
3, 6, 7, 9, 4, 1, 6, 9, 3, 1, 7, 4, 9, 1, 6, 4, 3, 7,
1, 4, 9, 7, 6, 3, 4, 7, 1, 3, 9, 6, 7, 3, 4, 6, 1, 9),
18, 6, byrow = T)
} else if (all(williams_D == 6, selection == 24, type == "S")) {
sequences <- matrix(c(1, 4, 8, 7, 5, 2, 4, 7, 1, 2, 8, 5, 7, 2, 4, 5, 1, 8,
2, 5, 7, 8, 4, 1, 5, 8, 2, 1, 7, 4, 8, 1, 5, 4, 2, 7,
2, 5, 9, 8, 6, 3, 5, 8, 2, 3, 9, 6, 8, 3, 5, 6, 2, 9,
3, 6, 8, 9, 5, 2, 6, 9, 3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6, 2, 4, 9,
7, 2, 1, 9, 6, 4, 2, 9, 7, 4, 1, 6, 9, 4, 2, 6, 7, 1,
4, 6, 9, 1, 2, 7, 7, 2, 5, 8, 10, 3, 2, 8, 7, 3, 5,
10, 8, 3, 2, 10, 7, 5, 3, 10, 8, 5, 2, 7, 10, 5, 3, 7,
8, 2, 5, 7, 10, 2, 3, 8, 8, 3, 1, 9, 6, 4, 3, 9, 8, 4,
1, 6, 9, 4, 3, 6, 8, 1, 4, 6, 9, 1, 3, 8, 6, 1, 4, 8,
9, 3, 1, 8, 6, 3, 4, 9, 9, 4, 2, 10, 7, 5, 4, 10, 9,
5, 2, 7, 10, 5, 4, 7, 9, 2, 5, 7, 10, 2, 4, 9, 7, 2,
5, 9, 10, 4, 2, 9, 7, 4, 5, 10, 10, 5, 3, 6, 8, 1, 5,
6, 10, 1, 3, 8, 6, 1, 5, 8, 10, 3, 1, 8, 6, 3, 5, 10,
8, 3, 1, 10, 6, 5, 3, 10, 8, 5, 1, 6), 60, 6,
byrow = T)
} else if (all(williams_D == 6, selection == 27, type == "S")) {
sequences <- matrix(c(1, 2, 10, 5, 9, 6, 2, 5, 1, 6, 10, 9, 5, 6, 2, 9, 1,
10, 6, 9, 5, 10, 2, 1, 9, 10, 6, 1, 5, 2, 10, 1, 9, 2,
6, 5, 3, 4, 12, 7, 11, 8, 4, 7, 3, 8, 12, 11, 7, 8, 4,
11, 3, 12, 8, 11, 7, 12, 4, 3, 11, 12, 8, 3, 7, 4, 12,
3, 11, 4, 8, 7, 9, 11, 7, 1, 5, 3, 11, 1, 9, 3, 7, 5,
1, 3, 11, 5, 9, 7, 3, 5, 1, 7, 11, 9, 5, 7, 3, 9, 1,
11, 7, 9, 5, 11, 3, 1, 10, 12, 8, 2, 6, 4, 12, 2, 10,
4, 8, 6, 2, 4, 12, 6, 10, 8, 4, 6, 2, 8, 12, 10, 6, 8,
4, 10, 2, 12, 8, 10, 6, 12, 4, 2, 5, 8, 4, 9, 1, 12,
8, 9, 5, 12, 4, 1, 9, 12, 8, 1, 5, 4, 12, 1, 9, 4, 8,
5, 1, 4, 12, 5, 9, 8, 4, 5, 1, 8, 12, 9, 6, 7, 3, 10,
2, 11, 7, 10, 6, 11, 3, 2, 10, 11, 7, 2, 6, 3, 11, 2,
10, 3, 7, 6, 2, 3, 11, 6, 10, 7, 3, 6, 2, 7, 11, 10),
36, 6, byrow = T)
} else if (all(williams_D == 6, selection == 28, type == "S")) {
sequences <- matrix(c(1, 7, 9, 2, 3, 8, 7, 2, 1, 8, 9, 3, 2, 8, 7, 3, 1, 9,
8, 3, 2, 9, 7, 1, 3, 9, 8, 1, 2, 7, 9, 1, 3, 7, 8, 2,
2, 8, 10, 3, 4, 9, 8, 3, 2, 9, 10, 4, 3, 9, 8, 4, 2,
10, 9, 4, 3, 10, 8, 2, 4, 10, 9, 2, 3, 8, 10, 2, 4, 8,
9, 3, 3, 9, 11, 4, 5, 10, 9, 4, 3, 10, 11, 5, 4, 10,
9, 5, 3, 11, 10, 5, 4, 11, 9, 3, 5, 11, 10, 3, 4, 9,
11, 3, 5, 9, 10, 4, 4, 10, 7, 5, 1, 11, 10, 5, 4, 11,
7, 1, 5, 11, 10, 1, 4, 7, 11, 1, 5, 7, 10, 4, 1, 7,
11, 4, 5, 10, 7, 4, 1, 10, 11, 5, 5, 11, 8, 1, 2, 7,
11, 1, 5, 7, 8, 2, 1, 7, 11, 2, 5, 8, 7, 2, 1, 8, 11,
5, 2, 8, 7, 5, 1, 11, 8, 5, 2, 11, 7, 1, 5, 11, 12, 2,
6, 8, 11, 2, 5, 8, 12, 6, 2, 8, 11, 6, 5, 12, 8, 6, 2,
12, 11, 5, 6, 12, 8, 5, 2, 11, 12, 5, 6, 11, 8, 2, 1,
7, 12, 3, 6, 9, 7, 3, 1, 9, 12, 6, 3, 9, 7, 6, 1, 12,
9, 6, 3, 12, 7, 1, 6, 12, 9, 1, 3, 7, 12, 1, 6, 7, 9,
3, 2, 8, 12, 4, 6, 10, 8, 4, 2, 10, 12, 6, 4, 10, 8,
6, 2, 12, 10, 6, 4, 12, 8, 2, 6, 12, 10, 2, 4, 8, 12,
2, 6, 8, 10, 4, 3, 9, 12, 5, 6, 11, 9, 5, 3, 11, 12,
6, 5, 11, 9, 6, 3, 12, 11, 6, 5, 12, 9, 3, 6, 12, 11,
3, 5, 9, 12, 3, 6, 9, 11, 5, 4, 10, 12, 1, 6, 7, 10,
1, 4, 7, 12, 6, 1, 7, 10, 6, 4, 12, 7, 6, 1, 12, 10,
4, 6, 12, 7, 4, 1, 10, 12, 4, 6, 10, 7, 1), 60, 6,
byrow = T)
} else if (all(williams_D == 6, selection == 29, type == "S")) {
sequences <- matrix(c(1, 2, 10, 5, 9, 6, 2, 5, 1, 6, 10, 9, 5, 6, 2, 9, 1,
10, 6, 9, 5, 10, 2, 1, 9, 10, 6, 1, 5, 2, 10, 1, 9, 2,
6, 5, 3, 4, 12, 7, 11, 8, 4, 7, 3, 8, 12, 11, 7, 8, 4,
11, 3, 12, 8, 11, 7, 12, 4, 3, 11, 12, 8, 3, 7, 4, 12,
3, 11, 4, 8, 7, 9, 11, 7, 1, 5, 3, 11, 1, 9, 3, 7, 5,
1, 3, 11, 5, 9, 7, 3, 5, 1, 7, 11, 9, 5, 7, 3, 9, 1,
11, 7, 9, 5, 11, 3, 1, 10, 12, 8, 2, 6, 4, 12, 2, 10,
4, 8, 6, 2, 4, 12, 6, 10, 8, 4, 6, 2, 8, 12, 10, 6, 8,
4, 10, 2, 12, 8, 10, 6, 12, 4, 2, 5, 8, 4, 9, 1, 12,
8, 9, 5, 12, 4, 1, 9, 12, 8, 1, 5, 4, 12, 1, 9, 4, 8,
5, 1, 4, 12, 5, 9, 8, 4, 5, 1, 8, 12, 9, 6, 7, 3, 10,
2, 11, 7, 10, 6, 11, 3, 2, 10, 11, 7, 2, 6, 3, 11, 2,
10, 3, 7, 6, 2, 3, 11, 6, 10, 7, 3, 6, 2, 7, 11, 10,
2, 1, 9, 6, 10, 5, 1, 6, 2, 5, 9, 10, 6, 5, 1, 10, 2,
9, 5, 10, 6, 9, 1, 2, 10, 9, 5, 2, 6, 1, 9, 2, 10, 1,
5, 6, 4, 3, 11, 8, 12, 7, 3, 8, 4, 7, 11, 12, 8, 7, 3,
12, 4, 11, 7, 12, 8, 11, 3, 4, 12, 11, 7, 4, 8, 3, 11,
4, 12, 3, 7, 8, 11, 9, 5, 3, 7, 1, 9, 3, 11, 1, 5, 7,
3, 1, 9, 7, 11, 5, 1, 7, 3, 5, 9, 11, 7, 5, 1, 11, 3,
9, 5, 11, 7, 9, 1, 3, 12, 10, 6, 4, 8, 2, 10, 4, 12,
2, 6, 8, 4, 2, 10, 8, 12, 6, 2, 8, 4, 6, 10, 12, 8, 6,
2, 12, 4, 10, 6, 12, 8, 10, 2, 4, 8, 5, 1, 12, 4, 9,
5, 12, 8, 9, 1, 4, 12, 9, 5, 4, 8, 1, 9, 4, 12, 1, 5,
8, 4, 1, 9, 8, 12, 5, 1, 8, 4, 5, 9, 12, 7, 6, 2, 11,
3, 10, 6, 11, 7, 10, 2, 3, 11, 10, 6, 3, 7, 2, 10, 3,
11, 2, 6, 7, 3, 2, 10, 7, 11, 6, 2, 7, 3, 6, 10, 11),
72, 6, byrow = T)
} else if (all(williams_D == 6, selection == 31, type == "S")) {
sequences <- matrix(c(1, 7, 11, 4, 5, 10, 7, 4, 1, 10, 11, 5, 4, 10, 7, 5,
1, 11, 10, 5, 4, 11, 7, 1, 5, 11, 10, 1, 4, 7, 11, 1,
5, 7, 10, 4, 2, 8, 12, 3, 6, 9, 8, 3, 2, 9, 12, 6, 3,
9, 8, 6, 2, 12, 9, 6, 3, 12, 8, 2, 6, 12, 9, 2, 3, 8,
12, 2, 6, 8, 9, 3, 1, 7, 11, 2, 5, 8, 7, 2, 1, 8, 11,
5, 2, 8, 7, 5, 1, 11, 8, 5, 2, 11, 7, 1, 5, 11, 8, 1,
2, 7, 11, 1, 5, 7, 8, 2, 6, 12, 10, 3, 4, 9, 12, 3, 6,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9, 1, 3, 7, 10,
1, 4, 7, 9, 3, 2, 8, 12, 5, 6, 11, 8, 5, 2, 11, 12, 6,
5, 11, 8, 6, 2, 12, 11, 6, 5, 12, 8, 2, 6, 12, 11, 2,
5, 8, 12, 2, 6, 8, 11, 5, 2, 8, 11, 4, 5, 10, 8, 4, 2,
10, 11, 5, 4, 10, 8, 5, 2, 11, 10, 5, 4, 11, 8, 2, 5,
11, 10, 2, 4, 8, 11, 2, 5, 8, 10, 4, 6, 12, 9, 1, 3,
7, 12, 1, 6, 7, 9, 3, 1, 7, 12, 3, 6, 9, 7, 3, 1, 9,
12, 6, 3, 9, 7, 6, 1, 12, 9, 6, 3, 12, 7, 1, 3, 9, 7,
5, 1, 11, 9, 5, 3, 11, 7, 1, 5, 11, 9, 1, 3, 7, 11, 1,
5, 7, 9, 3, 1, 7, 11, 3, 5, 9, 7, 3, 1, 9, 11, 5, 6,
12, 10, 2, 4, 8, 12, 2, 6, 8, 10, 4, 2, 8, 12, 4, 6,
10, 8, 4, 2, 10, 12, 6, 4, 10, 8, 6, 2, 12, 10, 6, 4,
12, 8, 2, 4, 10, 8, 1, 2, 7, 10, 1, 4, 7, 8, 2, 1, 7,
10, 2, 4, 8, 7, 2, 1, 8, 10, 4, 2, 8, 7, 4, 1, 10, 8,
4, 2, 10, 7, 1, 6, 12, 11, 3, 5, 9, 12, 3, 6, 9, 11,
5, 3, 9, 12, 5, 6, 11, 9, 5, 3, 11, 12, 6, 5, 11, 9,
6, 3, 12, 11, 6, 5, 12, 9, 3), 120, 6, byrow = T)
} else if (all(williams_D == 6, selection == 32, type == "S")) {
sequences <- matrix(c(1, 8, 11, 2, 4, 9, 8, 2, 1, 9, 11, 4, 2, 9, 8, 4, 1,
11, 9, 4, 2, 11, 8, 1, 4, 11, 9, 1, 2, 8, 11, 1, 4, 8,
9, 2, 2, 9, 12, 3, 5, 10, 9, 3, 2, 10, 12, 5, 3, 10,
9, 5, 2, 12, 10, 5, 3, 12, 9, 2, 5, 12, 10, 2, 3, 9,
12, 2, 5, 9, 10, 3, 3, 10, 13, 4, 6, 11, 10, 4, 3, 11,
13, 6, 4, 11, 10, 6, 3, 13, 11, 6, 4, 13, 10, 3, 6,
13, 11, 3, 4, 10, 13, 3, 6, 10, 11, 4, 4, 11, 14, 5,
7, 12, 11, 5, 4, 12, 14, 7, 5, 12, 11, 7, 4, 14, 12,
7, 5, 14, 11, 4, 7, 14, 12, 4, 5, 11, 14, 4, 7, 11,
12, 5, 5, 12, 8, 6, 1, 13, 12, 6, 5, 13, 8, 1, 6, 13,
12, 1, 5, 8, 13, 1, 6, 8, 12, 5, 1, 8, 13, 5, 6, 12,
8, 5, 1, 12, 13, 6, 6, 13, 9, 7, 2, 14, 13, 7, 6, 14,
9, 2, 7, 14, 13, 2, 6, 9, 14, 2, 7, 9, 13, 6, 2, 9,
14, 6, 7, 13, 9, 6, 2, 13, 14, 7, 7, 14, 10, 1, 3, 8,
14, 1, 7, 8, 10, 3, 1, 8, 14, 3, 7, 10, 8, 3, 1, 10,
14, 7, 3, 10, 8, 7, 1, 14, 10, 7, 3, 14, 8, 1), 42, 6,
byrow = T)
} else if (all(williams_D == 6, selection == 34, type == "S")) {
sequences <- matrix(c(1, 8, 11, 2, 4, 9, 8, 2, 1, 9, 11, 4, 2, 9, 8, 4, 1,
11, 9, 4, 2, 11, 8, 1, 4, 11, 9, 1, 2, 8, 11, 1, 4, 8,
9, 2, 2, 9, 12, 3, 5, 10, 9, 3, 2, 10, 12, 5, 3, 10,
9, 5, 2, 12, 10, 5, 3, 12, 9, 2, 5, 12, 10, 2, 3, 9,
12, 2, 5, 9, 10, 3, 3, 10, 13, 4, 6, 11, 10, 4, 3, 11,
13, 6, 4, 11, 10, 6, 3, 13, 11, 6, 4, 13, 10, 3, 6,
13, 11, 3, 4, 10, 13, 3, 6, 10, 11, 4, 4, 11, 14, 5,
7, 12, 11, 5, 4, 12, 14, 7, 5, 12, 11, 7, 4, 14, 12,
7, 5, 14, 11, 4, 7, 14, 12, 4, 5, 11, 14, 4, 7, 11,
12, 5, 5, 12, 8, 6, 1, 13, 12, 6, 5, 13, 8, 1, 6, 13,
12, 1, 5, 8, 13, 1, 6, 8, 12, 5, 1, 8, 13, 5, 6, 12,
8, 5, 1, 12, 13, 6, 6, 13, 9, 7, 2, 14, 13, 7, 6, 14,
9, 2, 7, 14, 13, 2, 6, 9, 14, 2, 7, 9, 13, 6, 2, 9,
14, 6, 7, 13, 9, 6, 2, 13, 14, 7, 7, 14, 10, 1, 3, 8,
14, 1, 7, 8, 10, 3, 1, 8, 14, 3, 7, 10, 8, 3, 1, 10,
14, 7, 3, 10, 8, 7, 1, 14, 10, 7, 3, 14, 8, 1, 1, 8,
11, 2, 4, 9, 8, 2, 1, 9, 11, 4, 2, 9, 8, 4, 1, 11, 9,
4, 2, 11, 8, 1, 4, 11, 9, 1, 2, 8, 11, 1, 4, 8, 9, 2,
2, 9, 12, 3, 5, 10, 9, 3, 2, 10, 12, 5, 3, 10, 9, 5,
2, 12, 10, 5, 3, 12, 9, 2, 5, 12, 10, 2, 3, 9, 12, 2,
5, 9, 10, 3, 3, 10, 13, 4, 6, 11, 10, 4, 3, 11, 13, 6,
4, 11, 10, 6, 3, 13, 11, 6, 4, 13, 10, 3, 6, 13, 11,
3, 4, 10, 13, 3, 6, 10, 11, 4, 4, 11, 14, 5, 7, 12,
11, 5, 4, 12, 14, 7, 5, 12, 11, 7, 4, 14, 12, 7, 5,
14, 11, 4, 7, 14, 12, 4, 5, 11, 14, 4, 7, 11, 12, 5,
5, 12, 8, 6, 1, 13, 12, 6, 5, 13, 8, 1, 6, 13, 12, 1,
5, 8, 13, 1, 6, 8, 12, 5, 1, 8, 13, 5, 6, 12, 8, 5, 1,
12, 13, 6, 6, 13, 9, 7, 2, 14, 13, 7, 6, 14, 9, 2, 7,
14, 13, 2, 6, 9, 14, 2, 7, 9, 13, 6, 2, 9, 14, 6, 7,
13, 9, 6, 2, 13, 14, 7, 7, 14, 10, 1, 3, 8, 14, 1, 7,
8, 10, 3, 1, 8, 14, 3, 7, 10, 8, 3, 1, 10, 14, 7, 3,
10, 8, 7, 1, 14, 10, 7, 3, 14, 8, 1, 1, 8, 11, 2, 4,
9, 8, 2, 1, 9, 11, 4, 2, 9, 8, 4, 1, 11, 9, 4, 2, 11,
8, 1, 4, 11, 9, 1, 2, 8, 11, 1, 4, 8, 9, 2, 2, 9, 12,
3, 5, 10, 9, 3, 2, 10, 12, 5, 3, 10, 9, 5, 2, 12, 10,
5, 3, 12, 9, 2, 5, 12, 10, 2, 3, 9, 12, 2, 5, 9, 10,
3, 3, 10, 13, 4, 6, 11, 10, 4, 3, 11, 13, 6, 4, 11,
10, 6, 3, 13, 11, 6, 4, 13, 10, 3, 6, 13, 11, 3, 4,
10, 13, 3, 6, 10, 11, 4, 4, 11, 14, 5, 7, 12, 11, 5,
4, 12, 14, 7, 5, 12, 11, 7, 4, 14, 12, 7, 5, 14, 11,
4, 7, 14, 12, 4, 5, 11, 14, 4, 7, 11, 12, 5, 5, 12, 8,
6, 1, 13, 12, 6, 5, 13, 8, 1, 6, 13, 12, 1, 5, 8, 13,
1, 6, 8, 12, 5, 1, 8, 13, 5, 6, 12, 8, 5, 1, 12, 13,
6, 6, 13, 9, 7, 2, 14, 13, 7, 6, 14, 9, 2, 7, 14, 13,
2, 6, 9, 14, 2, 7, 9, 13, 6, 2, 9, 14, 6, 7, 13, 9, 6,
2, 13, 14, 7, 7, 14, 10, 1, 3, 8, 14, 1, 7, 8, 10, 3,
1, 8, 14, 3, 7, 10, 8, 3, 1, 10, 14, 7, 3, 10, 8, 7,
1, 14, 10, 7, 3, 14, 8, 1), 126, 6, byrow = T)
} else if (all(williams_D == 6, selection == 35, type == "S")) {
sequences <- matrix(c(1, 6, 12, 11, 7, 2, 6, 11, 1, 2, 12, 7, 11, 2, 6, 7,
1, 12, 2, 7, 11, 12, 6, 1, 7, 12, 2, 1, 11, 6, 12, 1,
7, 6, 2, 11, 2, 7, 13, 12, 8, 3, 7, 12, 2, 3, 13, 8,
12, 3, 7, 8, 2, 13, 3, 8, 12, 13, 7, 2, 8, 13, 3, 2,
12, 7, 13, 2, 8, 7, 3, 12, 3, 8, 14, 13, 9, 4, 8, 13,
3, 4, 14, 9, 13, 4, 8, 9, 3, 14, 4, 9, 13, 14, 8, 3,
9, 14, 4, 3, 13, 8, 14, 3, 9, 8, 4, 13, 4, 9, 15, 14,
10, 5, 9, 14, 4, 5, 15, 10, 14, 5, 9, 10, 4, 15, 5,
10, 14, 15, 9, 4, 10, 15, 5, 4, 14, 9, 15, 4, 10, 9,
5, 14, 5, 10, 11, 15, 6, 1, 10, 15, 5, 1, 11, 6, 15,
1, 10, 6, 5, 11, 1, 6, 15, 11, 10, 5, 6, 11, 1, 5, 15,
10, 11, 5, 6, 10, 1, 15, 1, 6, 13, 11, 8, 3, 6, 11, 1,
3, 13, 8, 11, 3, 6, 8, 1, 13, 3, 8, 11, 13, 6, 1, 8,
13, 3, 1, 11, 6, 13, 1, 8, 6, 3, 11, 2, 7, 14, 12, 9,
4, 7, 12, 2, 4, 14, 9, 12, 4, 7, 9, 2, 14, 4, 9, 12,
14, 7, 2, 9, 14, 4, 2, 12, 7, 14, 2, 9, 7, 4, 12, 3,
8, 15, 13, 10, 5, 8, 13, 3, 5, 15, 10, 13, 5, 8, 10,
3, 15, 5, 10, 13, 15, 8, 3, 10, 15, 5, 3, 13, 8, 15,
3, 10, 8, 5, 13, 4, 9, 11, 14, 6, 1, 9, 14, 4, 1, 11,
6, 14, 1, 9, 6, 4, 11, 1, 6, 14, 11, 9, 4, 6, 11, 1,
4, 14, 9, 11, 4, 6, 9, 1, 14, 5, 10, 12, 15, 7, 2, 10,
15, 5, 2, 12, 7, 15, 2, 10, 7, 5, 12, 2, 7, 15, 12,
10, 5, 7, 12, 2, 5, 15, 10, 12, 5, 7, 10, 2, 15), 60,
6, byrow = T)
} else if (all(williams_D == 6, selection == 37, type == "S")) {
sequences <- matrix(c(1, 10, 16, 4, 7, 13, 10, 4, 1, 13, 16, 7, 4, 13, 10,
7, 1, 16, 13, 7, 4, 16, 10, 1, 7, 16, 13, 1, 4, 10,
16, 1, 7, 10, 13, 4, 2, 11, 17, 5, 8, 14, 11, 5, 2,
14, 17, 8, 5, 14, 11, 8, 2, 17, 14, 8, 5, 17, 11, 2,
8, 17, 14, 2, 5, 11, 17, 2, 8, 11, 14, 5, 3, 12, 18,
6, 9, 15, 12, 6, 3, 15, 18, 9, 6, 15, 12, 9, 3, 18,
15, 9, 6, 18, 12, 3, 9, 18, 15, 3, 6, 12, 18, 3, 9,
12, 15, 6, 2, 11, 13, 3, 4, 12, 11, 3, 2, 12, 13, 4,
3, 12, 11, 4, 2, 13, 12, 4, 3, 13, 11, 2, 4, 13, 12,
2, 3, 11, 13, 2, 4, 11, 12, 3, 5, 14, 16, 6, 7, 15,
14, 6, 5, 15, 16, 7, 6, 15, 14, 7, 5, 16, 15, 7, 6,
16, 14, 5, 7, 16, 15, 5, 6, 14, 16, 5, 7, 14, 15, 6,
8, 17, 10, 9, 1, 18, 17, 9, 8, 18, 10, 1, 9, 18, 17,
1, 8, 10, 18, 1, 9, 10, 17, 8, 1, 10, 18, 8, 9, 17,
10, 8, 1, 17, 18, 9, 3, 12, 14, 1, 5, 10, 12, 1, 3,
10, 14, 5, 1, 10, 12, 5, 3, 14, 10, 5, 1, 14, 12, 3,
5, 14, 10, 3, 1, 12, 14, 3, 5, 12, 10, 1, 6, 15, 17,
4, 8, 13, 15, 4, 6, 13, 17, 8, 4, 13, 15, 8, 6, 17,
13, 8, 4, 17, 15, 6, 8, 17, 13, 6, 4, 15, 17, 6, 8,
15, 13, 4, 9, 18, 11, 7, 2, 16, 18, 7, 9, 16, 11, 2,
7, 16, 18, 2, 9, 11, 16, 2, 7, 11, 18, 9, 2, 11, 16,
9, 7, 18, 11, 9, 2, 18, 16, 7, 1, 10, 15, 2, 6, 11,
10, 2, 1, 11, 15, 6, 2, 11, 10, 6, 1, 15, 11, 6, 2,
15, 10, 1, 6, 15, 11, 1, 2, 10, 15, 1, 6, 10, 11, 2,
4, 13, 18, 5, 9, 14, 13, 5, 4, 14, 18, 9, 5, 14, 13,
9, 4, 18, 14, 9, 5, 18, 13, 4, 9, 18, 14, 4, 5, 13,
18, 4, 9, 13, 14, 5, 7, 16, 12, 8, 3, 17, 16, 8, 7,
17, 12, 3, 8, 17, 16, 3, 7, 12, 17, 3, 8, 12, 16, 7,
3, 12, 17, 7, 8, 16, 12, 7, 3, 16, 17, 8), 72, 6,
byrow = T)
} else if (all(williams_D == 6, selection == 38, type == "S")) {
sequences <- matrix(c(1, 7, 14, 13, 8, 2, 7, 13, 1, 2, 14, 8, 13, 2, 7, 8,
1, 14, 2, 8, 13, 14, 7, 1, 8, 14, 2, 1, 13, 7, 14, 1,
8, 7, 2, 13, 3, 9, 16, 15, 10, 4, 9, 15, 3, 4, 16, 10,
15, 4, 9, 10, 3, 16, 4, 10, 15, 16, 9, 3, 10, 16, 4,
3, 15, 9, 16, 3, 10, 9, 4, 15, 5, 11, 18, 17, 12, 6,
11, 17, 5, 6, 18, 12, 17, 6, 11, 12, 5, 18, 6, 12, 17,
18, 11, 5, 12, 18, 6, 5, 17, 11, 18, 5, 12, 11, 6, 17,
1, 7, 15, 13, 9, 3, 7, 13, 1, 3, 15, 9, 13, 3, 7, 9,
1, 15, 3, 9, 13, 15, 7, 1, 9, 15, 3, 1, 13, 7, 15, 1,
9, 7, 3, 13, 2, 8, 18, 14, 12, 6, 8, 14, 2, 6, 18, 12,
14, 6, 8, 12, 2, 18, 6, 12, 14, 18, 8, 2, 12, 18, 6,
2, 14, 8, 18, 2, 12, 8, 6, 14, 4, 10, 17, 16, 11, 5,
10, 16, 4, 5, 17, 11, 16, 5, 10, 11, 4, 17, 5, 11, 16,
17, 10, 4, 11, 17, 5, 4, 16, 10, 17, 4, 11, 10, 5, 16,
1, 7, 16, 13, 10, 4, 7, 13, 1, 4, 16, 10, 13, 4, 7,
10, 1, 16, 4, 10, 13, 16, 7, 1, 10, 16, 4, 1, 13, 7,
16, 1, 10, 7, 4, 13, 2, 8, 17, 14, 11, 5, 8, 14, 2, 5,
17, 11, 14, 5, 8, 11, 2, 17, 5, 11, 14, 17, 8, 2, 11,
17, 5, 2, 14, 8, 17, 2, 11, 8, 5, 14, 3, 9, 18, 15,
12, 6, 9, 15, 3, 6, 18, 12, 15, 6, 9, 12, 3, 18, 6,
12, 15, 18, 9, 3, 12, 18, 6, 3, 15, 9, 18, 3, 12, 9,
6, 15, 1, 7, 17, 13, 11, 5, 7, 13, 1, 5, 17, 11, 13,
5, 7, 11, 1, 17, 5, 11, 13, 17, 7, 1, 11, 17, 5, 1,
13, 7, 17, 1, 11, 7, 5, 13, 2, 8, 15, 14, 9, 3, 8, 14,
2, 3, 15, 9, 14, 3, 8, 9, 2, 15, 3, 9, 14, 15, 8, 2,
9, 15, 3, 2, 14, 8, 15, 2, 9, 8, 3, 14, 4, 10, 18, 16,
12, 6, 10, 16, 4, 6, 18, 12, 16, 6, 10, 12, 4, 18, 6,
12, 16, 18, 10, 4, 12, 18, 6, 4, 16, 10, 18, 4, 12,
10, 6, 16, 1, 7, 18, 13, 12, 6, 7, 13, 1, 6, 18, 12,
13, 6, 7, 12, 1, 18, 6, 12, 13, 18, 7, 1, 12, 18, 6,
1, 13, 7, 18, 1, 12, 7, 6, 13, 2, 8, 16, 14, 10, 4, 8,
14, 2, 4, 16, 10, 14, 4, 8, 10, 2, 16, 4, 10, 14, 16,
8, 2, 10, 16, 4, 2, 14, 8, 16, 2, 10, 8, 4, 14, 3, 9,
17, 15, 11, 5, 9, 15, 3, 5, 17, 11, 15, 5, 9, 11, 3,
17, 5, 11, 15, 17, 9, 3, 11, 17, 5, 3, 15, 9, 17, 3,
11, 9, 5, 15), 90, 6, byrow = T)
} else if (all(williams_D == 6, selection == "36a", type == "SR")) {
sequences <- matrix(c(2, 6, 8, 3, 4, 7, 6, 3, 2, 7, 8, 4, 3, 7, 6, 4, 2, 8,
7, 4, 3, 8, 6, 2, 4, 8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, 7, 2, 4, 6, 8, 2, 3, 6, 7, 4,
9, 8, 1, 6, 4, 2, 8, 6, 9, 2, 1, 4, 6, 2, 8, 4, 9, 1,
2, 4, 6, 1, 8, 9, 4, 1, 2, 9, 6, 8, 1, 9, 4, 8, 2, 6,
7, 5, 3, 8, 1, 6, 5, 8, 7, 6, 3, 1, 8, 6, 5, 1, 7, 3,
6, 1, 8, 3, 5, 7, 1, 3, 6, 7, 8, 5, 3, 7, 1, 5, 6, 8,
5, 3, 2, 9, 7, 4, 3, 9, 5, 4, 2, 7, 9, 4, 3, 7, 5, 2,
4, 7, 9, 2, 3, 5, 7, 2, 4, 5, 9, 3, 2, 5, 7, 3, 4, 9),
54, 6, byrow = T)
} else if (all(williams_D == 6, selection == 66, type == "SR")) {
sequences <- matrix(c(1, 2, 6, 3, 5, 4, 2, 3, 1, 4, 6, 5, 3, 4, 2, 5, 1, 6,
4, 5, 3, 6, 2, 1, 5, 6, 4, 1, 3, 2, 6, 1, 5, 2, 4, 3,
7, 8, 6, 9, 5, 10, 8, 9, 7, 10, 6, 5, 9, 10, 8, 5, 7,
6, 10, 5, 9, 6, 8, 7, 5, 6, 10, 7, 9, 8, 6, 7, 5, 8,
10, 9, 1, 2, 12, 9, 11, 10, 2, 9, 1, 10, 12, 11, 9,
10, 2, 11, 1, 12, 10, 11, 9, 12, 2, 1, 11, 12, 10, 1,
9, 2, 12, 1, 11, 2, 10, 9, 7, 8, 12, 3, 11, 4, 8, 3,
7, 4, 12, 11, 3, 4, 8, 11, 7, 12, 4, 11, 3, 12, 8, 7,
11, 12, 4, 7, 3, 8, 12, 7, 11, 8, 4, 3, 10, 5, 3, 12,
8, 1, 5, 12, 10, 1, 3, 8, 12, 1, 5, 8, 10, 3, 1, 8,
12, 3, 5, 10, 8, 3, 1, 10, 12, 5, 3, 10, 8, 5, 1, 12,
4, 5, 9, 12, 2, 7, 5, 12, 4, 7, 9, 2, 12, 7, 5, 2, 4,
9, 7, 2, 12, 9, 5, 4, 2, 9, 7, 4, 12, 5, 9, 4, 2, 5,
7, 12, 4, 11, 9, 6, 8, 1, 11, 6, 4, 1, 9, 8, 6, 1, 11,
8, 4, 9, 1, 8, 6, 9, 11, 4, 8, 9, 1, 4, 6, 11, 9, 4,
8, 11, 1, 6, 10, 11, 3, 6, 2, 7, 11, 6, 10, 7, 3, 2,
6, 7, 11, 2, 10, 3, 7, 2, 6, 3, 11, 10, 2, 3, 7, 10,
6, 11, 3, 10, 2, 11, 7, 6), 48, 6, byrow = T)
} else if (all(williams_D == 6, selection == 67, type == "SR")) {
sequences <- matrix(c(7, 8, 12, 10, 3, 11, 8, 10, 7, 11, 12, 3, 10, 11, 8,
3, 7, 12, 11, 3, 10, 12, 8, 7, 3, 12, 11, 7, 10, 8,
12, 7, 3, 8, 11, 10, 8, 9, 4, 11, 1, 12, 9, 11, 8, 12,
4, 1, 11, 12, 9, 1, 8, 4, 12, 1, 11, 4, 9, 8, 1, 4,
12, 8, 11, 9, 4, 8, 1, 9, 12, 11, 9, 10, 2, 12, 7, 5,
10, 12, 9, 5, 2, 7, 12, 5, 10, 7, 9, 2, 5, 7, 12, 2,
10, 9, 7, 2, 5, 9, 12, 10, 2, 9, 7, 10, 5, 12, 10, 11,
3, 6, 8, 1, 11, 6, 10, 1, 3, 8, 6, 1, 11, 8, 10, 3, 1,
8, 6, 3, 11, 10, 8, 3, 1, 10, 6, 11, 3, 10, 8, 11, 1,
6, 11, 12, 9, 1, 4, 2, 12, 1, 11, 2, 9, 4, 1, 2, 12,
4, 11, 9, 2, 4, 1, 9, 12, 11, 4, 9, 2, 11, 1, 12, 9,
11, 4, 12, 2, 1, 12, 1, 10, 2, 5, 3, 1, 2, 12, 3, 10,
5, 2, 3, 1, 5, 12, 10, 3, 5, 2, 10, 1, 12, 5, 10, 3,
12, 2, 1, 10, 12, 5, 1, 3, 2, 2, 3, 6, 4, 11, 7, 3, 4,
2, 7, 6, 11, 4, 7, 3, 11, 2, 6, 7, 11, 4, 6, 3, 2, 11,
6, 7, 2, 4, 3, 6, 2, 11, 3, 7, 4, 3, 4, 7, 5, 12, 8,
4, 5, 3, 8, 7, 12, 5, 8, 4, 12, 3, 7, 8, 12, 5, 7, 4,
3, 12, 7, 8, 3, 5, 4, 7, 3, 12, 4, 8, 5, 4, 5, 8, 7,
9, 6, 5, 7, 4, 6, 8, 9, 7, 6, 5, 9, 4, 8, 6, 9, 7, 8,
5, 4, 9, 8, 6, 4, 7, 5, 8, 4, 9, 5, 6, 7, 5, 6, 1, 8,
10, 9, 6, 8, 5, 9, 1, 10, 8, 9, 6, 10, 5, 1, 9, 10, 8,
1, 6, 5, 10, 1, 9, 5, 8, 6, 1, 5, 10, 6, 9, 8, 6, 7,
11, 9, 2, 10, 7, 9, 6, 10, 11, 2, 9, 10, 7, 2, 6, 11,
10, 2, 9, 11, 7, 6, 2, 11, 10, 6, 9, 7, 11, 6, 2, 7,
10, 9, 1, 2, 5, 3, 6, 4, 2, 3, 1, 4, 5, 6, 3, 4, 2, 6,
1, 5, 4, 6, 3, 5, 2, 1, 6, 5, 4, 1, 3, 2, 5, 1, 6, 2,
4, 3), 72, 6, byrow = T)
} else if (all(williams_D == 6, selection == 68, type == "SR")) {
sequences <- matrix(c(1, 4, 6, 2, 3, 5, 4, 2, 1, 5, 6, 3, 2, 5, 4, 3, 1, 6,
5, 3, 2, 6, 4, 1, 3, 6, 5, 1, 2, 4, 6, 1, 3, 4, 5, 2,
4, 8, 1, 12, 11, 9, 8, 12, 4, 9, 1, 11, 12, 9, 8, 11,
4, 1, 9, 11, 12, 1, 8, 4, 11, 1, 9, 4, 12, 8, 1, 4,
11, 8, 9, 12, 2, 5, 12, 9, 7, 10, 5, 9, 2, 10, 12, 7,
9, 10, 5, 7, 2, 12, 10, 7, 9, 12, 5, 2, 7, 12, 10, 2,
9, 5, 12, 2, 7, 5, 10, 9, 11, 3, 8, 6, 10, 7, 3, 6,
11, 7, 8, 10, 6, 7, 3, 10, 11, 8, 7, 10, 6, 8, 3, 11,
10, 8, 7, 11, 6, 3, 8, 11, 10, 3, 7, 6, 7, 2, 9, 8, 1,
3, 2, 8, 7, 3, 9, 1, 8, 3, 2, 1, 7, 9, 3, 1, 8, 9, 2,
7, 1, 9, 3, 7, 8, 2, 9, 7, 1, 2, 3, 8, 5, 12, 7, 11,
6, 1, 12, 11, 5, 1, 7, 6, 11, 1, 12, 6, 5, 7, 1, 6,
11, 7, 12, 5, 6, 7, 1, 5, 11, 12, 7, 5, 6, 12, 1, 11,
10, 6, 2, 4, 12, 8, 6, 4, 10, 8, 2, 12, 4, 8, 6, 12,
10, 2, 8, 12, 4, 2, 6, 10, 12, 2, 8, 10, 4, 6, 2, 10,
12, 6, 8, 4, 9, 10, 3, 5, 4, 11, 10, 5, 9, 11, 3, 4,
5, 11, 10, 4, 9, 3, 11, 4, 5, 3, 10, 9, 4, 3, 11, 9,
5, 10, 3, 9, 4, 10, 11, 5, 3, 1, 11, 10, 2, 12, 1, 10,
3, 12, 11, 2, 10, 12, 1, 2, 3, 11, 12, 2, 10, 11, 1,
3, 2, 11, 12, 3, 10, 1, 11, 3, 2, 1, 12, 10, 8, 9, 10,
1, 5, 6, 9, 1, 8, 6, 10, 5, 1, 6, 9, 5, 8, 10, 6, 5,
1, 10, 9, 8, 5, 10, 6, 8, 1, 9, 10, 8, 5, 9, 6, 1, 6,
11, 4, 7, 9, 2, 11, 7, 6, 2, 4, 9, 7, 2, 11, 9, 6, 4,
2, 9, 7, 4, 11, 6, 9, 4, 2, 6, 7, 11, 4, 6, 9, 11, 2,
7, 12, 7, 5, 3, 8, 4, 7, 3, 12, 4, 5, 8, 3, 4, 7, 8,
12, 5, 4, 8, 3, 5, 7, 12, 8, 5, 4, 12, 3, 7, 5, 12, 8,
7, 4, 3), 72, 6, byrow = T)
} else if (all(williams_D == 6, selection == 72, type == "SR")) {
sequences <- matrix(c(1, 2, 6, 3, 5, 4, 2, 3, 1, 4, 6, 5, 3, 4, 2, 5, 1, 6,
4, 5, 3, 6, 2, 1, 5, 6, 4, 1, 3, 2, 6, 1, 5, 2, 4, 3,
7, 8, 12, 9, 11, 10, 8, 9, 7, 10, 12, 11, 9, 10, 8,
11, 7, 12, 10, 11, 9, 12, 8, 7, 11, 12, 10, 7, 9, 8,
12, 7, 11, 8, 10, 9, 13, 14, 18, 15, 17, 16, 14, 15,
13, 16, 18, 17, 15, 16, 14, 17, 13, 18, 16, 17, 15,
18, 14, 13, 17, 18, 16, 13, 15, 14, 18, 13, 17, 14,
16, 15, 2, 9, 1, 16, 18, 11, 9, 16, 2, 11, 1, 18, 16,
11, 9, 18, 2, 1, 11, 18, 16, 1, 9, 2, 18, 1, 11, 2,
16, 9, 1, 2, 18, 9, 11, 16, 8, 15, 7, 4, 6, 17, 15, 4,
8, 17, 7, 6, 4, 17, 15, 6, 8, 7, 17, 6, 4, 7, 15, 8,
6, 7, 17, 8, 4, 15, 7, 8, 6, 15, 17, 4, 14, 3, 13, 10,
12, 5, 3, 10, 14, 5, 13, 12, 10, 5, 3, 12, 14, 13, 5,
12, 10, 13, 3, 14, 12, 13, 5, 14, 10, 3, 13, 14, 12,
3, 5, 10, 3, 16, 8, 17, 1, 12, 16, 17, 3, 12, 8, 1,
17, 12, 16, 1, 3, 8, 12, 1, 17, 8, 16, 3, 1, 8, 12, 3,
17, 16, 8, 3, 1, 16, 12, 17, 9, 4, 14, 5, 7, 18, 4, 5,
9, 18, 14, 7, 5, 18, 4, 7, 9, 14, 18, 7, 5, 14, 4, 9,
7, 14, 18, 9, 5, 4, 14, 9, 7, 4, 18, 5, 15, 10, 2, 11,
13, 6, 10, 11, 15, 6, 2, 13, 11, 6, 10, 13, 15, 2, 6,
13, 11, 2, 10, 15, 13, 2, 6, 15, 11, 10, 2, 15, 13,
10, 6, 11, 4, 11, 15, 12, 14, 1, 11, 12, 4, 1, 15, 14,
12, 1, 11, 14, 4, 15, 1, 14, 12, 15, 11, 4, 14, 15, 1,
4, 12, 11, 15, 4, 14, 11, 1, 12, 10, 17, 3, 18, 2, 7,
17, 18, 10, 7, 3, 2, 18, 7, 17, 2, 10, 3, 7, 2, 18, 3,
17, 10, 2, 3, 7, 10, 18, 17, 3, 10, 2, 17, 7, 18, 16,
5, 9, 6, 8, 13, 5, 6, 16, 13, 9, 8, 6, 13, 5, 8, 16,
9, 13, 8, 6, 9, 5, 16, 8, 9, 13, 16, 6, 5, 9, 16, 8,
5, 13, 6, 5, 18, 10, 1, 15, 8, 18, 1, 5, 8, 10, 15, 1,
8, 18, 15, 5, 10, 8, 15, 1, 10, 18, 5, 15, 10, 8, 5,
1, 18, 10, 5, 15, 18, 8, 1, 11, 6, 16, 7, 3, 14, 6, 7,
11, 14, 16, 3, 7, 14, 6, 3, 11, 16, 14, 3, 7, 16, 6,
11, 3, 16, 14, 11, 7, 6, 16, 11, 3, 6, 14, 7, 17, 12,
4, 13, 9, 2, 12, 13, 17, 2, 4, 9, 13, 2, 12, 9, 17, 4,
2, 9, 13, 4, 12, 17, 9, 4, 2, 17, 13, 12, 4, 17, 9,
12, 2, 13, 6, 1, 17, 14, 10, 9, 1, 14, 6, 9, 17, 10,
14, 9, 1, 10, 6, 17, 9, 10, 14, 17, 1, 6, 10, 17, 9,
6, 14, 1, 17, 6, 10, 1, 9, 14, 12, 7, 5, 2, 15, 16, 7,
2, 12, 16, 5, 15, 2, 16, 7, 15, 12, 5, 16, 15, 2, 5,
7, 12, 15, 5, 16, 12, 2, 7, 5, 12, 15, 7, 16, 2, 18,
13, 11, 8, 4, 3, 13, 8, 18, 3, 11, 4, 8, 3, 13, 4, 18,
11, 3, 4, 8, 11, 13, 18, 4, 11, 3, 18, 8, 13, 11, 18,
4, 13, 3, 8), 108, 6, byrow = T)
} else if (all(williams_D == 6, selection == 73, type == "SR")) {
sequences <- matrix(c(1, 2, 6, 3, 5, 4, 2, 3, 1, 4, 6, 5, 3, 4, 2, 5, 1, 6,
4, 5, 3, 6, 2, 1, 5, 6, 4, 1, 3, 2, 6, 1, 5, 2, 4, 3,
7, 8, 12, 9, 11, 10, 8, 9, 7, 10, 12, 11, 9, 10, 8,
11, 7, 12, 10, 11, 9, 12, 8, 7, 11, 12, 10, 7, 9, 8,
12, 7, 11, 8, 10, 9, 13, 14, 18, 15, 17, 16, 14, 15,
13, 16, 18, 17, 15, 16, 14, 17, 13, 18, 16, 17, 15,
18, 14, 13, 17, 18, 16, 13, 15, 14, 18, 13, 17, 14,
16, 15, 1, 2, 12, 3, 11, 10, 2, 3, 1, 10, 12, 11, 3,
10, 2, 11, 1, 12, 10, 11, 3, 12, 2, 1, 11, 12, 10, 1,
3, 2, 12, 1, 11, 2, 10, 3, 7, 8, 18, 9, 17, 16, 8, 9,
7, 16, 18, 17, 9, 16, 8, 17, 7, 18, 16, 17, 9, 18, 8,
7, 17, 18, 16, 7, 9, 8, 18, 7, 17, 8, 16, 9, 13, 14,
6, 15, 5, 4, 14, 15, 13, 4, 6, 5, 15, 4, 14, 5, 13, 6,
4, 5, 15, 6, 14, 13, 5, 6, 4, 13, 15, 14, 6, 13, 5,
14, 4, 15, 1, 2, 18, 3, 17, 16, 2, 3, 1, 16, 18, 17,
3, 16, 2, 17, 1, 18, 16, 17, 3, 18, 2, 1, 17, 18, 16,
1, 3, 2, 18, 1, 17, 2, 16, 3, 7, 8, 6, 9, 5, 4, 8, 9,
7, 4, 6, 5, 9, 4, 8, 5, 7, 6, 4, 5, 9, 6, 8, 7, 5, 6,
4, 7, 9, 8, 6, 7, 5, 8, 4, 9, 13, 14, 12, 15, 11, 10,
14, 15, 13, 10, 12, 11, 15, 10, 14, 11, 13, 12, 10,
11, 15, 12, 14, 13, 11, 12, 10, 13, 15, 14, 12, 13,
11, 14, 10, 15, 15, 4, 8, 11, 1, 18, 4, 11, 15, 18, 8,
1, 11, 18, 4, 1, 15, 8, 18, 1, 11, 8, 4, 15, 1, 8, 18,
15, 11, 4, 8, 15, 1, 4, 18, 11, 3, 10, 14, 17, 7, 6,
10, 17, 3, 6, 14, 7, 17, 6, 10, 7, 3, 14, 6, 7, 17,
14, 10, 3, 7, 14, 6, 3, 17, 10, 14, 3, 7, 10, 6, 17,
9, 16, 2, 5, 13, 12, 16, 5, 9, 12, 2, 13, 5, 12, 16,
13, 9, 2, 12, 13, 5, 2, 16, 9, 13, 2, 12, 9, 5, 16, 2,
9, 13, 16, 12, 5, 15, 10, 8, 17, 1, 6, 10, 17, 15, 6,
8, 1, 17, 6, 10, 1, 15, 8, 6, 1, 17, 8, 10, 15, 1, 8,
6, 15, 17, 10, 8, 15, 1, 10, 6, 17, 3, 16, 14, 5, 7,
12, 16, 5, 3, 12, 14, 7, 5, 12, 16, 7, 3, 14, 12, 7,
5, 14, 16, 3, 7, 14, 12, 3, 5, 16, 14, 3, 7, 16, 12,
5, 9, 4, 2, 11, 13, 18, 4, 11, 9, 18, 2, 13, 11, 18,
4, 13, 9, 2, 18, 13, 11, 2, 4, 9, 13, 2, 18, 9, 11, 4,
2, 9, 13, 4, 18, 11, 15, 16, 8, 5, 1, 12, 16, 5, 15,
12, 8, 1, 5, 12, 16, 1, 15, 8, 12, 1, 5, 8, 16, 15, 1,
8, 12, 15, 5, 16, 8, 15, 1, 16, 12, 5, 3, 4, 14, 11,
7, 18, 4, 11, 3, 18, 14, 7, 11, 18, 4, 7, 3, 14, 18,
7, 11, 14, 4, 3, 7, 14, 18, 3, 11, 4, 14, 3, 7, 4, 18,
11, 9, 10, 2, 17, 13, 6, 10, 17, 9, 6, 2, 13, 17, 6,
10, 13, 9, 2, 6, 13, 17, 2, 10, 9, 13, 2, 6, 9, 17,
10, 2, 9, 13, 10, 6, 17, 17, 12, 4, 1, 9, 14, 12, 1,
17, 14, 4, 9, 1, 14, 12, 9, 17, 4, 14, 9, 1, 4, 12,
17, 9, 4, 14, 17, 1, 12, 4, 17, 9, 12, 14, 1, 5, 18,
10, 7, 15, 2, 18, 7, 5, 2, 10, 15, 7, 2, 18, 15, 5,
10, 2, 15, 7, 10, 18, 5, 15, 10, 2, 5, 7, 18, 10, 5,
15, 18, 2, 7, 11, 6, 16, 13, 3, 8, 6, 13, 11, 8, 16,
3, 13, 8, 6, 3, 11, 16, 8, 3, 13, 16, 6, 11, 3, 16, 8,
11, 13, 6, 16, 11, 3, 6, 8, 13, 5, 18, 10, 1, 9, 14,
18, 1, 5, 14, 10, 9, 1, 14, 18, 9, 5, 10, 14, 9, 1,
10, 18, 5, 9, 10, 14, 5, 1, 18, 10, 5, 9, 18, 14, 1,
11, 6, 16, 7, 15, 2, 6, 7, 11, 2, 16, 15, 7, 2, 6, 15,
11, 16, 2, 15, 7, 16, 6, 11, 15, 16, 2, 11, 7, 6, 16,
11, 15, 6, 2, 7, 17, 12, 4, 13, 3, 8, 12, 13, 17, 8,
4, 3, 13, 8, 12, 3, 17, 4, 8, 3, 13, 4, 12, 17, 3, 4,
8, 17, 13, 12, 4, 17, 3, 12, 8, 13, 11, 6, 16, 1, 9,
14, 6, 1, 11, 14, 16, 9, 1, 14, 6, 9, 11, 16, 14, 9,
1, 16, 6, 11, 9, 16, 14, 11, 1, 6, 16, 11, 9, 6, 14,
1, 17, 12, 4, 7, 15, 2, 12, 7, 17, 2, 4, 15, 7, 2, 12,
15, 17, 4, 2, 15, 7, 4, 12, 17, 15, 4, 2, 17, 7, 12,
4, 17, 15, 12, 2, 7, 5, 18, 10, 13, 3, 8, 18, 13, 5,
8, 10, 3, 13, 8, 18, 3, 5, 10, 8, 3, 13, 10, 18, 5, 3,
10, 8, 5, 13, 18, 10, 5, 3, 18, 8, 13), 162, 6,
byrow = T)
} else if (all(williams_D == 6, selection == 75, type == "SR")) {
sequences <- matrix(c(5, 8, 25, 9, 24, 22, 8, 9, 5, 22, 25, 24, 9, 22, 8,
24, 5, 25, 22, 24, 9, 25, 8, 5, 24, 25, 22, 5, 9, 8,
25, 5, 24, 8, 22, 9, 6, 9, 26, 10, 1, 23, 9, 10, 6,
23, 26, 1, 10, 23, 9, 1, 6, 26, 23, 1, 10, 26, 9, 6,
1, 26, 23, 6, 10, 9, 26, 6, 1, 9, 23, 10, 7, 10, 27,
11, 2, 24, 10, 11, 7, 24, 27, 2, 11, 24, 10, 2, 7, 27,
24, 2, 11, 27, 10, 7, 2, 27, 24, 7, 11, 10, 27, 7, 2,
10, 24, 11, 8, 11, 28, 12, 3, 1, 11, 12, 8, 1, 28, 3,
12, 1, 11, 3, 8, 28, 1, 3, 12, 28, 11, 8, 3, 28, 1, 8,
12, 11, 28, 8, 3, 11, 1, 12, 9, 12, 29, 13, 4, 2, 12,
13, 9, 2, 29, 4, 13, 2, 12, 4, 9, 29, 2, 4, 13, 29,
12, 9, 4, 29, 2, 9, 13, 12, 29, 9, 4, 12, 2, 13, 10,
13, 30, 14, 5, 3, 13, 14, 10, 3, 30, 5, 14, 3, 13, 5,
10, 30, 3, 5, 14, 30, 13, 10, 5, 30, 3, 10, 14, 13,
30, 10, 5, 13, 3, 14, 11, 14, 25, 15, 6, 4, 14, 15,
11, 4, 25, 6, 15, 4, 14, 6, 11, 25, 4, 6, 15, 25, 14,
11, 6, 25, 4, 11, 15, 14, 25, 11, 6, 14, 4, 15, 12,
15, 26, 16, 7, 5, 15, 16, 12, 5, 26, 7, 16, 5, 15, 7,
12, 26, 5, 7, 16, 26, 15, 12, 7, 26, 5, 12, 16, 15,
26, 12, 7, 15, 5, 16, 13, 16, 27, 17, 8, 6, 16, 17,
13, 6, 27, 8, 17, 6, 16, 8, 13, 27, 6, 8, 17, 27, 16,
13, 8, 27, 6, 13, 17, 16, 27, 13, 8, 16, 6, 17, 14,
17, 28, 18, 9, 7, 17, 18, 14, 7, 28, 9, 18, 7, 17, 9,
14, 28, 7, 9, 18, 28, 17, 14, 9, 28, 7, 14, 18, 17,
28, 14, 9, 17, 7, 18, 15, 18, 29, 19, 10, 8, 18, 19,
15, 8, 29, 10, 19, 8, 18, 10, 15, 29, 8, 10, 19, 29,
18, 15, 10, 29, 8, 15, 19, 18, 29, 15, 10, 18, 8, 19,
16, 19, 30, 20, 11, 9, 19, 20, 16, 9, 30, 11, 20, 9,
19, 11, 16, 30, 9, 11, 20, 30, 19, 16, 11, 30, 9, 16,
20, 19, 30, 16, 11, 19, 9, 20, 17, 20, 25, 21, 12, 10,
20, 21, 17, 10, 25, 12, 21, 10, 20, 12, 17, 25, 10,
12, 21, 25, 20, 17, 12, 25, 10, 17, 21, 20, 25, 17,
12, 20, 10, 21, 18, 21, 26, 22, 13, 11, 21, 22, 18,
11, 26, 13, 22, 11, 21, 13, 18, 26, 11, 13, 22, 26,
21, 18, 13, 26, 11, 18, 22, 21, 26, 18, 13, 21, 11,
22, 19, 22, 27, 23, 14, 12, 22, 23, 19, 12, 27, 14,
23, 12, 22, 14, 19, 27, 12, 14, 23, 27, 22, 19, 14,
27, 12, 19, 23, 22, 27, 19, 14, 22, 12, 23, 20, 23,
28, 24, 15, 13, 23, 24, 20, 13, 28, 15, 24, 13, 23,
15, 20, 28, 13, 15, 24, 28, 23, 20, 15, 28, 13, 20,
24, 23, 28, 20, 15, 23, 13, 24, 21, 24, 29, 1, 16, 14,
24, 1, 21, 14, 29, 16, 1, 14, 24, 16, 21, 29, 14, 16,
1, 29, 24, 21, 16, 29, 14, 21, 1, 24, 29, 21, 16, 24,
14, 1, 22, 1, 30, 2, 17, 15, 1, 2, 22, 15, 30, 17, 2,
15, 1, 17, 22, 30, 15, 17, 2, 30, 1, 22, 17, 30, 15,
22, 2, 1, 30, 22, 17, 1, 15, 2, 23, 2, 25, 3, 18, 16,
2, 3, 23, 16, 25, 18, 3, 16, 2, 18, 23, 25, 16, 18, 3,
25, 2, 23, 18, 25, 16, 23, 3, 2, 25, 23, 18, 2, 16, 3,
24, 3, 26, 4, 19, 17, 3, 4, 24, 17, 26, 19, 4, 17, 3,
19, 24, 26, 17, 19, 4, 26, 3, 24, 19, 26, 17, 24, 4,
3, 26, 24, 19, 3, 17, 4, 1, 4, 27, 5, 20, 18, 4, 5, 1,
18, 27, 20, 5, 18, 4, 20, 1, 27, 18, 20, 5, 27, 4, 1,
20, 27, 18, 1, 5, 4, 27, 1, 20, 4, 18, 5, 2, 5, 28, 6,
21, 19, 5, 6, 2, 19, 28, 21, 6, 19, 5, 21, 2, 28, 19,
21, 6, 28, 5, 2, 21, 28, 19, 2, 6, 5, 28, 2, 21, 5,
19, 6, 3, 6, 29, 7, 22, 20, 6, 7, 3, 20, 29, 22, 7,
20, 6, 22, 3, 29, 20, 22, 7, 29, 6, 3, 22, 29, 20, 3,
7, 6, 29, 3, 22, 6, 20, 7, 4, 7, 30, 8, 23, 21, 7, 8,
4, 21, 30, 23, 8, 21, 7, 23, 4, 30, 21, 23, 8, 30, 7,
4, 23, 30, 21, 4, 8, 7, 30, 4, 23, 7, 21, 8, 25, 26,
30, 27, 29, 28, 26, 27, 25, 28, 30, 29, 27, 28, 26,
29, 25, 30, 28, 29, 27, 30, 26, 25, 29, 30, 28, 25,
27, 26, 30, 25, 29, 26, 28, 27), 150, 6, byrow = T)
} else if (all(williams_D == 7, selection == 172, type == "R")) {
sequences <- matrix(c(1, 9, 2, 6, 5, 3, 8, 2, 1, 5, 9, 8, 6, 3, 5, 2, 8, 1,
3, 9, 6, 8, 5, 3, 2, 6, 1, 9, 3, 8, 6, 5, 9, 2, 1, 6,
3, 9, 8, 1, 5, 2, 9, 6, 1, 3, 2, 8, 5, 8, 3, 5, 6, 2,
9, 1, 3, 6, 8, 9, 5, 1, 2, 6, 9, 3, 1, 8, 2, 5, 9, 1,
6, 2, 3, 5, 8, 1, 2, 9, 5, 6, 8, 3, 2, 5, 1, 8, 9, 3,
6, 5, 8, 2, 3, 1, 6, 9, 2, 1, 3, 7, 6, 4, 9, 3, 2, 6,
1, 9, 7, 4, 6, 3, 9, 2, 4, 1, 7, 9, 6, 4, 3, 7, 2, 1,
4, 9, 7, 6, 1, 3, 2, 7, 4, 1, 9, 2, 6, 3, 1, 7, 2, 4,
3, 9, 6, 9, 4, 6, 7, 3, 1, 2, 4, 7, 9, 1, 6, 2, 3, 7,
1, 4, 2, 9, 3, 6, 1, 2, 7, 3, 4, 6, 9, 2, 3, 1, 6, 7,
9, 4, 3, 6, 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, 1, 5, 12, 7, 10, 8, 9, 5, 7, 1,
8, 12, 9, 10, 7, 8, 5, 9, 1, 10, 12, 8, 9, 7, 10, 5,
12, 1, 9, 10, 8, 12, 7, 1, 5, 8, 6, 9, 2, 10, 1, 11,
9, 8, 10, 6, 11, 2, 1, 10, 9, 11, 8, 1, 6, 2, 11, 10,
1, 9, 2, 8, 6, 1, 11, 2, 10, 6, 9, 8, 2, 1, 6, 11, 8,
10, 9, 6, 2, 8, 1, 9, 11, 10, 11, 1, 10, 2, 9, 6, 8,
1, 2, 11, 6, 10, 8, 9, 2, 6, 1, 8, 11, 9, 10, 6, 8, 2,
9, 1, 10, 11, 8, 9, 6, 10, 2, 11, 1, 9, 10, 8, 11, 6,
1, 2, 10, 11, 9, 1, 8, 2, 6, 9, 7, 10, 3, 11, 2, 12,
10, 9, 11, 7, 12, 3, 2, 11, 10, 12, 9, 2, 7, 3, 12,
11, 2, 10, 3, 9, 7, 2, 12, 3, 11, 7, 10, 9, 3, 2, 7,
12, 9, 11, 10, 7, 3, 9, 2, 10, 12, 11, 12, 2, 11, 3,
10, 7, 9, 2, 3, 12, 7, 11, 9, 10, 3, 7, 2, 9, 12, 10,
11, 7, 9, 3, 10, 2, 11, 12, 9, 10, 7, 11, 3, 12, 2,
10, 11, 9, 12, 7, 2, 3, 11, 12, 10, 2, 9, 3, 7, 10, 8,
11, 4, 12, 3, 1, 11, 10, 12, 8, 1, 4, 3, 12, 11, 1,
10, 3, 8, 4, 1, 12, 3, 11, 4, 10, 8, 3, 1, 4, 12, 8,
11, 10, 4, 3, 8, 1, 10, 12, 11, 8, 4, 10, 3, 11, 1,
12, 1, 3, 12, 4, 11, 8, 10, 3, 4, 1, 8, 12, 10, 11, 4,
8, 3, 10, 1, 11, 12, 8, 10, 4, 11, 3, 12, 1, 10, 11,
8, 12, 4, 1, 3, 11, 12, 10, 1, 8, 3, 4, 12, 1, 11, 3,
10, 4, 8, 11, 9, 12, 5, 1, 4, 2, 12, 11, 1, 9, 2, 5,
4, 1, 12, 2, 11, 4, 9, 5, 2, 1, 4, 12, 5, 11, 9, 4, 2,
5, 1, 9, 12, 11, 5, 4, 9, 2, 11, 1, 12, 9, 5, 11, 4,
12, 2, 1, 2, 4, 1, 5, 12, 9, 11, 4, 5, 2, 9, 1, 11,
12, 5, 9, 4, 11, 2, 12, 1, 9, 11, 5, 12, 4, 1, 2, 11,
12, 9, 1, 5, 2, 4, 12, 1, 11, 2, 9, 4, 5, 1, 2, 12, 4,
11, 5, 9, 12, 10, 1, 6, 2, 5, 3, 1, 12, 2, 10, 3, 6,
5, 2, 1, 3, 12, 5, 10, 6, 3, 2, 5, 1, 6, 12, 10, 5, 3,
6, 2, 10, 1, 12, 6, 5, 10, 3, 12, 2, 1, 10, 6, 12, 5,
1, 3, 2, 3, 5, 2, 6, 1, 10, 12, 5, 6, 3, 10, 2, 12, 1,
6, 10, 5, 12, 3, 1, 2, 10, 12, 6, 1, 5, 2, 3, 12, 1,
10, 2, 6, 3, 5, 1, 2, 12, 3, 10, 5, 6, 2, 3, 1, 5, 12,
6, 10), 168, 7, byrow = T)
} else if (all(williams_D == 7, selection == 176, type == "R")) {
sequences <- matrix(c(3, 12, 5, 11, 8, 10, 9, 5, 3, 8, 12, 9, 11, 10, 8, 5,
9, 3, 10, 12, 11, 9, 8, 10, 5, 11, 3, 12, 10, 9, 11,
8, 12, 5, 3, 11, 10, 12, 9, 3, 8, 5, 12, 11, 3, 10, 5,
9, 8, 9, 10, 8, 11, 5, 12, 3, 10, 11, 9, 12, 8, 3, 5,
11, 12, 10, 3, 9, 5, 8, 12, 3, 11, 5, 10, 8, 9, 3, 5,
12, 8, 11, 9, 10, 5, 8, 3, 9, 12, 10, 11, 8, 9, 5, 10,
3, 11, 12, 4, 1, 6, 12, 9, 11, 10, 6, 4, 9, 1, 10, 12,
11, 9, 6, 10, 4, 11, 1, 12, 10, 9, 11, 6, 12, 4, 1,
11, 10, 12, 9, 1, 6, 4, 12, 11, 1, 10, 4, 9, 6, 1, 12,
4, 11, 6, 10, 9, 10, 11, 9, 12, 6, 1, 4, 11, 12, 10,
1, 9, 4, 6, 12, 1, 11, 4, 10, 6, 9, 1, 4, 12, 6, 11,
9, 10, 4, 6, 1, 9, 12, 10, 11, 6, 9, 4, 10, 1, 11, 12,
9, 10, 6, 11, 4, 12, 1, 5, 2, 7, 1, 10, 12, 11, 7, 5,
10, 2, 11, 1, 12, 10, 7, 11, 5, 12, 2, 1, 11, 10, 12,
7, 1, 5, 2, 12, 11, 1, 10, 2, 7, 5, 1, 12, 2, 11, 5,
10, 7, 2, 1, 5, 12, 7, 11, 10, 11, 12, 10, 1, 7, 2, 5,
12, 1, 11, 2, 10, 5, 7, 1, 2, 12, 5, 11, 7, 10, 2, 5,
1, 7, 12, 10, 11, 5, 7, 2, 10, 1, 11, 12, 7, 10, 5,
11, 2, 12, 1, 10, 11, 7, 12, 5, 1, 2, 6, 3, 8, 2, 11,
1, 12, 8, 6, 11, 3, 12, 2, 1, 11, 8, 12, 6, 1, 3, 2,
12, 11, 1, 8, 2, 6, 3, 1, 12, 2, 11, 3, 8, 6, 2, 1, 3,
12, 6, 11, 8, 3, 2, 6, 1, 8, 12, 11, 12, 1, 11, 2, 8,
3, 6, 1, 2, 12, 3, 11, 6, 8, 2, 3, 1, 6, 12, 8, 11, 3,
6, 2, 8, 1, 11, 12, 6, 8, 3, 11, 2, 12, 1, 8, 11, 6,
12, 3, 1, 2, 11, 12, 8, 1, 6, 2, 3, 7, 4, 9, 3, 12, 2,
1, 9, 7, 12, 4, 1, 3, 2, 12, 9, 1, 7, 2, 4, 3, 1, 12,
2, 9, 3, 7, 4, 2, 1, 3, 12, 4, 9, 7, 3, 2, 4, 1, 7,
12, 9, 4, 3, 7, 2, 9, 1, 12, 1, 2, 12, 3, 9, 4, 7, 2,
3, 1, 4, 12, 7, 9, 3, 4, 2, 7, 1, 9, 12, 4, 7, 3, 9,
2, 12, 1, 7, 9, 4, 12, 3, 1, 2, 9, 12, 7, 1, 4, 2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2, 8, 11, 9, 10, 7, 8, 4, 9,
2, 10, 11), 168, 7, byrow = T)
} else if (all(williams_D == 7, selection == 177, type == "R")) {
sequences <- matrix(c(1, 4, 8, 2, 10, 3, 9, 8, 1, 10, 4, 9, 2, 3, 10, 8, 9,
1, 3, 4, 2, 9, 10, 3, 8, 2, 1, 4, 3, 9, 2, 10, 4, 8,
1, 2, 3, 4, 9, 1, 10, 8, 4, 2, 1, 3, 8, 9, 10, 9, 3,
10, 2, 8, 4, 1, 3, 2, 9, 4, 10, 1, 8, 2, 4, 3, 1, 9,
8, 10, 4, 1, 2, 8, 3, 10, 9, 1, 8, 4, 10, 2, 9, 3, 8,
10, 1, 9, 4, 3, 2, 10, 9, 8, 3, 1, 2, 4, 11, 10, 1, 3,
8, 9, 2, 1, 11, 8, 10, 2, 3, 9, 8, 1, 2, 11, 9, 10, 3,
2, 8, 9, 1, 3, 11, 10, 9, 2, 3, 8, 10, 1, 11, 3, 9,
10, 2, 11, 8, 1, 10, 3, 11, 9, 1, 2, 8, 2, 9, 8, 3, 1,
10, 11, 9, 3, 2, 10, 8, 11, 1, 3, 10, 9, 11, 2, 1, 8,
10, 11, 3, 1, 9, 8, 2, 11, 1, 10, 8, 3, 2, 9, 1, 8,
11, 2, 10, 9, 3, 8, 2, 1, 9, 11, 3, 10, 6, 12, 13, 5,
1, 2, 8, 13, 6, 1, 12, 8, 5, 2, 1, 13, 8, 6, 2, 12, 5,
8, 1, 2, 13, 5, 6, 12, 2, 8, 5, 1, 12, 13, 6, 5, 2,
12, 8, 6, 1, 13, 12, 5, 6, 2, 13, 8, 1, 8, 2, 1, 5,
13, 12, 6, 2, 5, 8, 12, 1, 6, 13, 5, 12, 2, 6, 8, 13,
1, 12, 6, 5, 13, 2, 1, 8, 6, 13, 12, 1, 5, 8, 2, 13,
1, 6, 8, 12, 2, 5, 1, 8, 13, 2, 6, 5, 12, 12, 5, 6,
13, 9, 8, 1, 6, 12, 9, 5, 1, 13, 8, 9, 6, 1, 12, 8, 5,
13, 1, 9, 8, 6, 13, 12, 5, 8, 1, 13, 9, 5, 6, 12, 13,
8, 5, 1, 12, 9, 6, 5, 13, 12, 8, 6, 1, 9, 1, 8, 9, 13,
6, 5, 12, 8, 13, 1, 5, 9, 12, 6, 13, 5, 8, 12, 1, 6,
9, 5, 12, 13, 6, 8, 9, 1, 12, 6, 5, 9, 13, 1, 8, 6, 9,
12, 1, 5, 8, 13, 9, 1, 6, 8, 12, 13, 5, 4, 14, 11, 8,
5, 1, 7, 11, 4, 5, 14, 7, 8, 1, 5, 11, 7, 4, 1, 14, 8,
7, 5, 1, 11, 8, 4, 14, 1, 7, 8, 5, 14, 11, 4, 8, 1,
14, 7, 4, 5, 11, 14, 8, 4, 1, 11, 7, 5, 7, 1, 5, 8,
11, 14, 4, 1, 8, 7, 14, 5, 4, 11, 8, 14, 1, 4, 7, 11,
5, 14, 4, 8, 11, 1, 5, 7, 4, 11, 14, 5, 8, 7, 1, 11,
5, 4, 7, 14, 1, 8, 5, 7, 11, 1, 4, 8, 14, 14, 8, 4, 1,
11, 7, 12, 4, 14, 11, 8, 12, 1, 7, 11, 4, 12, 14, 7,
8, 1, 12, 11, 7, 4, 1, 14, 8, 7, 12, 1, 11, 8, 4, 14,
1, 7, 8, 12, 14, 11, 4, 8, 1, 14, 7, 4, 12, 11, 12, 7,
11, 1, 4, 8, 14, 7, 1, 12, 8, 11, 14, 4, 1, 8, 7, 14,
12, 4, 11, 8, 14, 1, 4, 7, 11, 12, 14, 4, 8, 11, 1,
12, 7, 4, 11, 14, 12, 8, 7, 1, 11, 12, 4, 7, 14, 1, 8,
7, 1, 14, 10, 13, 6, 3, 14, 7, 13, 1, 3, 10, 6, 13,
14, 3, 7, 6, 1, 10, 3, 13, 6, 14, 10, 7, 1, 6, 3, 10,
13, 1, 14, 7, 10, 6, 1, 3, 7, 13, 14, 1, 10, 7, 6, 14,
3, 13, 3, 6, 13, 10, 14, 1, 7, 6, 10, 3, 1, 13, 7, 14,
10, 1, 6, 7, 3, 14, 13, 1, 7, 10, 14, 6, 13, 3, 7, 14,
1, 13, 10, 3, 6, 14, 13, 7, 3, 1, 6, 10, 13, 3, 14, 6,
7, 10, 1, 8, 3, 10, 7, 6, 14, 13, 10, 8, 6, 3, 13, 7,
14, 6, 10, 13, 8, 14, 3, 7, 13, 6, 14, 10, 7, 8, 3,
14, 13, 7, 6, 3, 10, 8, 7, 14, 3, 13, 8, 6, 10, 3, 7,
8, 14, 10, 13, 6, 13, 14, 6, 7, 10, 3, 8, 14, 7, 13,
3, 6, 8, 10, 7, 3, 14, 8, 13, 10, 6, 3, 8, 7, 10, 14,
6, 13, 8, 10, 3, 6, 7, 13, 14, 10, 6, 8, 13, 3, 14, 7,
6, 13, 10, 14, 8, 7, 3, 2, 7, 9, 14, 3, 12, 5, 9, 2,
3, 7, 5, 14, 12, 3, 9, 5, 2, 12, 7, 14, 5, 3, 12, 9,
14, 2, 7, 12, 5, 14, 3, 7, 9, 2, 14, 12, 7, 5, 2, 3,
9, 7, 14, 2, 12, 9, 5, 3, 5, 12, 3, 14, 9, 7, 2, 12,
14, 5, 7, 3, 2, 9, 14, 7, 12, 2, 5, 9, 3, 7, 2, 14, 9,
12, 3, 5, 2, 9, 7, 3, 14, 5, 12, 9, 3, 2, 5, 7, 12,
14, 3, 5, 9, 12, 2, 14, 7, 10, 2, 12, 9, 7, 5, 14, 12,
10, 7, 2, 14, 9, 5, 7, 12, 14, 10, 5, 2, 9, 14, 7, 5,
12, 9, 10, 2, 5, 14, 9, 7, 2, 12, 10, 9, 5, 2, 14, 10,
7, 12, 2, 9, 10, 5, 12, 14, 7, 14, 5, 7, 9, 12, 2, 10,
5, 9, 14, 2, 7, 10, 12, 9, 2, 5, 10, 14, 12, 7, 2, 10,
9, 12, 5, 7, 14, 10, 12, 2, 7, 9, 14, 5, 12, 7, 10,
14, 2, 5, 9, 7, 14, 12, 5, 10, 9, 2, 9, 11, 7, 4, 2,
13, 6, 7, 9, 2, 11, 6, 4, 13, 2, 7, 6, 9, 13, 11, 4,
6, 2, 13, 7, 4, 9, 11, 13, 6, 4, 2, 11, 7, 9, 4, 13,
11, 6, 9, 2, 7, 11, 4, 9, 13, 7, 6, 2, 6, 13, 2, 4, 7,
11, 9, 13, 4, 6, 11, 2, 9, 7, 4, 11, 13, 9, 6, 7, 2,
11, 9, 4, 7, 13, 2, 6, 9, 7, 11, 2, 4, 6, 13, 7, 2, 9,
6, 11, 13, 4, 2, 6, 7, 13, 9, 4, 11, 13, 9, 2, 6, 14,
4, 11, 2, 13, 14, 9, 11, 6, 4, 14, 2, 11, 13, 4, 9, 6,
11, 14, 4, 2, 6, 13, 9, 4, 11, 6, 14, 9, 2, 13, 6, 4,
9, 11, 13, 14, 2, 9, 6, 13, 4, 2, 11, 14, 11, 4, 14,
6, 2, 9, 13, 4, 6, 11, 9, 14, 13, 2, 6, 9, 4, 13, 11,
2, 14, 9, 13, 6, 2, 4, 14, 11, 13, 2, 9, 14, 6, 11, 4,
2, 14, 13, 11, 9, 4, 6, 14, 11, 2, 4, 13, 6, 9, 3, 6,
5, 11, 12, 10, 4, 5, 3, 12, 6, 4, 11, 10, 12, 5, 4, 3,
10, 6, 11, 4, 12, 10, 5, 11, 3, 6, 10, 4, 11, 12, 6,
5, 3, 11, 10, 6, 4, 3, 12, 5, 6, 11, 3, 10, 5, 4, 12,
4, 10, 12, 11, 5, 6, 3, 10, 11, 4, 6, 12, 3, 5, 11, 6,
10, 3, 4, 5, 12, 6, 3, 11, 5, 10, 12, 4, 3, 5, 6, 12,
11, 4, 10, 5, 12, 3, 4, 6, 10, 11, 12, 4, 5, 10, 3,
11, 6, 5, 13, 3, 12, 4, 11, 10, 3, 5, 4, 13, 10, 12,
11, 4, 3, 10, 5, 11, 13, 12, 10, 4, 11, 3, 12, 5, 13,
11, 10, 12, 4, 13, 3, 5, 12, 11, 13, 10, 5, 4, 3, 13,
12, 5, 11, 3, 10, 4, 10, 11, 4, 12, 3, 13, 5, 11, 12,
10, 13, 4, 5, 3, 12, 13, 11, 5, 10, 3, 4, 13, 5, 12,
3, 11, 4, 10, 5, 3, 13, 4, 12, 10, 11, 3, 4, 5, 10,
13, 11, 12, 4, 10, 3, 11, 5, 12, 13), 196, 7,
byrow = T)
} else if (all(williams_D == 7, selection == 80, type == "SR")) {
sequences <- matrix(c(1, 7, 2, 6, 3, 5, 4, 2, 1, 3, 7, 4, 6, 5, 3, 2, 4, 1,
5, 7, 6, 4, 3, 5, 2, 6, 1, 7, 5, 4, 6, 3, 7, 2, 1, 6,
5, 7, 4, 1, 3, 2, 7, 6, 1, 5, 2, 4, 3, 4, 5, 3, 6, 2,
7, 1, 5, 6, 4, 7, 3, 1, 2, 6, 7, 5, 1, 4, 2, 3, 7, 1,
6, 2, 5, 3, 4, 1, 2, 7, 3, 6, 4, 5, 2, 3, 1, 4, 7, 5,
6, 3, 4, 2, 5, 1, 6, 7, 8, 7, 9, 6, 10, 5, 11, 9, 8,
10, 7, 11, 6, 5, 10, 9, 11, 8, 5, 7, 6, 11, 10, 5, 9,
6, 8, 7, 5, 11, 6, 10, 7, 9, 8, 6, 5, 7, 11, 8, 10, 9,
7, 6, 8, 5, 9, 11, 10, 11, 5, 10, 6, 9, 7, 8, 5, 6,
11, 7, 10, 8, 9, 6, 7, 5, 8, 11, 9, 10, 7, 8, 6, 9, 5,
10, 11, 8, 9, 7, 10, 6, 11, 5, 9, 10, 8, 11, 7, 5, 6,
10, 11, 9, 5, 8, 6, 7, 1, 7, 2, 13, 10, 12, 11, 2, 1,
10, 7, 11, 13, 12, 10, 2, 11, 1, 12, 7, 13, 11, 10,
12, 2, 13, 1, 7, 12, 11, 13, 10, 7, 2, 1, 13, 12, 7,
11, 1, 10, 2, 7, 13, 1, 12, 2, 11, 10, 11, 12, 10, 13,
2, 7, 1, 12, 13, 11, 7, 10, 1, 2, 13, 7, 12, 1, 11, 2,
10, 7, 1, 13, 2, 12, 10, 11, 1, 2, 7, 10, 13, 11, 12,
2, 10, 1, 11, 7, 12, 13, 10, 11, 2, 12, 1, 13, 7, 8,
7, 9, 13, 3, 12, 4, 9, 8, 3, 7, 4, 13, 12, 3, 9, 4, 8,
12, 7, 13, 4, 3, 12, 9, 13, 8, 7, 12, 4, 13, 3, 7, 9,
8, 13, 12, 7, 4, 8, 3, 9, 7, 13, 8, 12, 9, 4, 3, 4,
12, 3, 13, 9, 7, 8, 12, 13, 4, 7, 3, 8, 9, 13, 7, 12,
8, 4, 9, 3, 7, 8, 13, 9, 12, 3, 4, 8, 9, 7, 3, 13, 4,
12, 9, 3, 8, 4, 7, 12, 13, 3, 4, 9, 12, 8, 13, 7, 1,
14, 9, 13, 3, 5, 11, 9, 1, 3, 14, 11, 13, 5, 3, 9, 11,
1, 5, 14, 13, 11, 3, 5, 9, 13, 1, 14, 5, 11, 13, 3,
14, 9, 1, 13, 5, 14, 11, 1, 3, 9, 14, 13, 1, 5, 9, 11,
3, 11, 5, 3, 13, 9, 14, 1, 5, 13, 11, 14, 3, 1, 9, 13,
14, 5, 1, 11, 9, 3, 14, 1, 13, 9, 5, 3, 11, 1, 9, 14,
3, 13, 11, 5, 9, 3, 1, 11, 14, 5, 13, 3, 11, 9, 5, 1,
13, 14, 8, 14, 2, 13, 10, 5, 4, 2, 8, 10, 14, 4, 13,
5, 10, 2, 4, 8, 5, 14, 13, 4, 10, 5, 2, 13, 8, 14, 5,
4, 13, 10, 14, 2, 8, 13, 5, 14, 4, 8, 10, 2, 14, 13,
8, 5, 2, 4, 10, 4, 5, 10, 13, 2, 14, 8, 5, 13, 4, 14,
10, 8, 2, 13, 14, 5, 8, 4, 2, 10, 14, 8, 13, 2, 5, 10,
4, 8, 2, 14, 10, 13, 4, 5, 2, 10, 8, 4, 14, 5, 13, 10,
4, 2, 5, 8, 13, 14, 1, 14, 9, 6, 10, 12, 4, 9, 1, 10,
14, 4, 6, 12, 10, 9, 4, 1, 12, 14, 6, 4, 10, 12, 9, 6,
1, 14, 12, 4, 6, 10, 14, 9, 1, 6, 12, 14, 4, 1, 10, 9,
14, 6, 1, 12, 9, 4, 10, 4, 12, 10, 6, 9, 14, 1, 12, 6,
4, 14, 10, 1, 9, 6, 14, 12, 1, 4, 9, 10, 14, 1, 6, 9,
12, 10, 4, 1, 9, 14, 10, 6, 4, 12, 9, 10, 1, 4, 14,
12, 6, 10, 4, 9, 12, 1, 6, 14, 8, 14, 2, 6, 3, 12, 11,
2, 8, 3, 14, 11, 6, 12, 3, 2, 11, 8, 12, 14, 6, 11, 3,
12, 2, 6, 8, 14, 12, 11, 6, 3, 14, 2, 8, 6, 12, 14,
11, 8, 3, 2, 14, 6, 8, 12, 2, 11, 3, 11, 12, 3, 6, 2,
14, 8, 12, 6, 11, 14, 3, 8, 2, 6, 14, 12, 8, 11, 2, 3,
14, 8, 6, 2, 12, 3, 11, 8, 2, 14, 3, 6, 11, 12, 2, 3,
8, 11, 14, 12, 6, 3, 11, 2, 12, 8, 6, 14), 112, 7,
byrow = T)
} else if (all(williams_D == 7, selection == 81, type == "SR")) {
sequences <- matrix(c(8, 7, 9, 13, 3, 12, 11, 9, 8, 3, 7, 11, 13, 12, 3, 9,
11, 8, 12, 7, 13, 11, 3, 12, 9, 13, 8, 7, 12, 11, 13,
3, 7, 9, 8, 13, 12, 7, 11, 8, 3, 9, 7, 13, 8, 12, 9,
11, 3, 11, 12, 3, 13, 9, 7, 8, 12, 13, 11, 7, 3, 8, 9,
13, 7, 12, 8, 11, 9, 3, 7, 8, 13, 9, 12, 3, 11, 8, 9,
7, 3, 13, 11, 12, 9, 3, 8, 11, 7, 12, 13, 3, 11, 9,
12, 8, 13, 7, 1, 14, 9, 13, 10, 12, 4, 9, 1, 10, 14,
4, 13, 12, 10, 9, 4, 1, 12, 14, 13, 4, 10, 12, 9, 13,
1, 14, 12, 4, 13, 10, 14, 9, 1, 13, 12, 14, 4, 1, 10,
9, 14, 13, 1, 12, 9, 4, 10, 4, 12, 10, 13, 9, 14, 1,
12, 13, 4, 14, 10, 1, 9, 13, 14, 12, 1, 4, 9, 10, 14,
1, 13, 9, 12, 10, 4, 1, 9, 14, 10, 13, 4, 12, 9, 10,
1, 4, 14, 12, 13, 10, 4, 9, 12, 1, 13, 14, 8, 14, 2,
13, 10, 5, 11, 2, 8, 10, 14, 11, 13, 5, 10, 2, 11, 8,
5, 14, 13, 11, 10, 5, 2, 13, 8, 14, 5, 11, 13, 10, 14,
2, 8, 13, 5, 14, 11, 8, 10, 2, 14, 13, 8, 5, 2, 11,
10, 11, 5, 10, 13, 2, 14, 8, 5, 13, 11, 14, 10, 8, 2,
13, 14, 5, 8, 11, 2, 10, 14, 8, 13, 2, 5, 10, 11, 8,
2, 14, 10, 13, 11, 5, 2, 10, 8, 11, 14, 5, 13, 10, 11,
2, 5, 8, 13, 14, 1, 14, 9, 6, 3, 12, 11, 9, 1, 3, 14,
11, 6, 12, 3, 9, 11, 1, 12, 14, 6, 11, 3, 12, 9, 6, 1,
14, 12, 11, 6, 3, 14, 9, 1, 6, 12, 14, 11, 1, 3, 9,
14, 6, 1, 12, 9, 11, 3, 11, 12, 3, 6, 9, 14, 1, 12, 6,
11, 14, 3, 1, 9, 6, 14, 12, 1, 11, 9, 3, 14, 1, 6, 9,
12, 3, 11, 1, 9, 14, 3, 6, 11, 12, 9, 3, 1, 11, 14,
12, 6, 3, 11, 9, 12, 1, 6, 14, 1, 7, 2, 13, 10, 12, 4,
2, 1, 10, 7, 4, 13, 12, 10, 2, 4, 1, 12, 7, 13, 4, 10,
12, 2, 13, 1, 7, 12, 4, 13, 10, 7, 2, 1, 13, 12, 7, 4,
1, 10, 2, 7, 13, 1, 12, 2, 4, 10, 4, 12, 10, 13, 2, 7,
1, 12, 13, 4, 7, 10, 1, 2, 13, 7, 12, 1, 4, 2, 10, 7,
1, 13, 2, 12, 10, 4, 1, 2, 7, 10, 13, 4, 12, 2, 10, 1,
4, 7, 12, 13, 10, 4, 2, 12, 1, 13, 7, 1, 14, 2, 13, 3,
5, 11, 2, 1, 3, 14, 11, 13, 5, 3, 2, 11, 1, 5, 14, 13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 9, 10, 14, 8,
6, 9, 5, 10, 4, 8, 9, 14, 10, 6, 4, 5, 9, 10, 8, 4,
14, 5, 6, 10, 4, 9, 5, 8, 6, 14, 1, 7, 9, 6, 10, 5,
11, 9, 1, 10, 7, 11, 6, 5, 10, 9, 11, 1, 5, 7, 6, 11,
10, 5, 9, 6, 1, 7, 5, 11, 6, 10, 7, 9, 1, 6, 5, 7, 11,
1, 10, 9, 7, 6, 1, 5, 9, 11, 10, 11, 5, 10, 6, 9, 7,
1, 5, 6, 11, 7, 10, 1, 9, 6, 7, 5, 1, 11, 9, 10, 7, 1,
6, 9, 5, 10, 11, 1, 9, 7, 10, 6, 11, 5, 9, 10, 1, 11,
7, 5, 6, 10, 11, 9, 5, 1, 6, 7, 8, 7, 2, 6, 10, 12,
11, 2, 8, 10, 7, 11, 6, 12, 10, 2, 11, 8, 12, 7, 6,
11, 10, 12, 2, 6, 8, 7, 12, 11, 6, 10, 7, 2, 8, 6, 12,
7, 11, 8, 10, 2, 7, 6, 8, 12, 2, 11, 10, 11, 12, 10,
6, 2, 7, 8, 12, 6, 11, 7, 10, 8, 2, 6, 7, 12, 8, 11,
2, 10, 7, 8, 6, 2, 12, 10, 11, 8, 2, 7, 10, 6, 11, 12,
2, 10, 8, 11, 7, 12, 6, 10, 11, 2, 12, 8, 6, 7, 1, 7,
2, 6, 3, 5, 4, 2, 1, 3, 7, 4, 6, 5, 3, 2, 4, 1, 5, 7,
6, 4, 3, 5, 2, 6, 1, 7, 5, 4, 6, 3, 7, 2, 1, 6, 5, 7,
4, 1, 3, 2, 7, 6, 1, 5, 2, 4, 3, 4, 5, 3, 6, 2, 7, 1,
5, 6, 4, 7, 3, 1, 2, 6, 7, 5, 1, 4, 2, 3, 7, 1, 6, 2,
5, 3, 4, 1, 2, 7, 3, 6, 4, 5, 2, 3, 1, 4, 7, 5, 6, 3,
4, 2, 5, 1, 6, 7), 168, 7, byrow = T)
} else if (all(williams_D == 7, selection == 82, type == "SR")) {
sequences <- matrix(c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4, 3, 4,
12, 3, 13, 9, 7, 8, 12, 13, 4, 7, 3, 8, 9, 13, 7, 12,
8, 4, 9, 3, 7, 8, 13, 9, 12, 3, 4, 8, 9, 7, 3, 13, 4,
12, 9, 3, 8, 4, 7, 12, 13, 3, 4, 9, 12, 8, 13, 7, 1,
14, 9, 13, 3, 5, 11, 9, 1, 3, 14, 11, 13, 5, 3, 9, 11,
1, 5, 14, 13, 11, 3, 5, 9, 13, 1, 14, 5, 11, 13, 3,
14, 9, 1, 13, 5, 14, 11, 1, 3, 9, 14, 13, 1, 5, 9, 11,
3, 11, 5, 3, 13, 9, 14, 1, 5, 13, 11, 14, 3, 1, 9, 13,
14, 5, 1, 11, 9, 3, 14, 1, 13, 9, 5, 3, 11, 1, 9, 14,
3, 13, 11, 5, 9, 3, 1, 11, 14, 5, 13, 3, 11, 9, 5, 1,
13, 14, 8, 14, 2, 13, 10, 5, 4, 2, 8, 10, 14, 4, 13,
5, 10, 2, 4, 8, 5, 14, 13, 4, 10, 5, 2, 13, 8, 14, 5,
4, 13, 10, 14, 2, 8, 13, 5, 14, 4, 8, 10, 2, 14, 13,
8, 5, 2, 4, 10, 4, 5, 10, 13, 2, 14, 8, 5, 13, 4, 14,
10, 8, 2, 13, 14, 5, 8, 4, 2, 10, 14, 8, 13, 2, 5, 10,
4, 8, 2, 14, 10, 13, 4, 5, 2, 10, 8, 4, 14, 5, 13, 10,
4, 2, 5, 8, 13, 14, 1, 14, 9, 6, 10, 12, 4, 9, 1, 10,
14, 4, 6, 12, 10, 9, 4, 1, 12, 14, 6, 4, 10, 12, 9, 6,
1, 14, 12, 4, 6, 10, 14, 9, 1, 6, 12, 14, 4, 1, 10, 9,
14, 6, 1, 12, 9, 4, 10, 4, 12, 10, 6, 9, 14, 1, 12, 6,
4, 14, 10, 1, 9, 6, 14, 12, 1, 4, 9, 10, 14, 1, 6, 9,
12, 10, 4, 1, 9, 14, 10, 6, 4, 12, 9, 10, 1, 4, 14,
12, 6, 10, 4, 9, 12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 1, 12, 2, 11, 10, 11, 12, 10, 13, 2, 7, 1, 12, 13,
11, 7, 10, 1, 2, 13, 7, 12, 1, 11, 2, 10, 7, 1, 13, 2,
12, 10, 11, 1, 2, 7, 10, 13, 11, 12, 2, 10, 1, 11, 7,
12, 13, 10, 11, 2, 12, 1, 13, 7, 8, 7, 9, 13, 3, 12,
4, 9, 8, 3, 7, 4, 13, 12, 3, 9, 4, 8, 12, 7, 13, 4, 3,
12, 9, 13, 8, 7, 12, 4, 13, 3, 7, 9, 8, 13, 12, 7, 4,
8, 3, 9, 7, 13, 8, 12, 9, 4, 3, 4, 12, 3, 13, 9, 7, 8,
12, 13, 4, 7, 3, 8, 9, 13, 7, 12, 8, 4, 9, 3, 7, 8,
13, 9, 12, 3, 4, 8, 9, 7, 3, 13, 4, 12, 9, 3, 8, 4, 7,
12, 13, 3, 4, 9, 12, 8, 13, 7, 1, 14, 9, 13, 3, 5, 11,
9, 1, 3, 14, 11, 13, 5, 3, 9, 11, 1, 5, 14, 13, 11, 3,
5, 9, 13, 1, 14, 5, 11, 13, 3, 14, 9, 1, 13, 5, 14,
11, 1, 3, 9, 14, 13, 1, 5, 9, 11, 3, 11, 5, 3, 13, 9,
14, 1, 5, 13, 11, 14, 3, 1, 9, 13, 14, 5, 1, 11, 9, 3,
14, 1, 13, 9, 5, 3, 11, 1, 9, 14, 3, 13, 11, 5, 9, 3,
1, 11, 14, 5, 13, 3, 11, 9, 5, 1, 13, 14, 8, 14, 2,
13, 10, 5, 4, 2, 8, 10, 14, 4, 13, 5, 10, 2, 4, 8, 5,
14, 13, 4, 10, 5, 2, 13, 8, 14, 5, 4, 13, 10, 14, 2,
8, 13, 5, 14, 4, 8, 10, 2, 14, 13, 8, 5, 2, 4, 10, 4,
5, 10, 13, 2, 14, 8, 5, 13, 4, 14, 10, 8, 2, 13, 14,
5, 8, 4, 2, 10, 14, 8, 13, 2, 5, 10, 4, 8, 2, 14, 10,
13, 4, 5, 2, 10, 8, 4, 14, 5, 13, 10, 4, 2, 5, 8, 13,
14, 1, 14, 9, 6, 10, 12, 4, 9, 1, 10, 14, 4, 6, 12,
10, 9, 4, 1, 12, 14, 6, 4, 10, 12, 9, 6, 1, 14, 12, 4,
6, 10, 14, 9, 1, 6, 12, 14, 4, 1, 10, 9, 14, 6, 1, 12,
9, 4, 10, 4, 12, 10, 6, 9, 14, 1, 12, 6, 4, 14, 10, 1,
9, 6, 14, 12, 1, 4, 9, 10, 14, 1, 6, 9, 12, 10, 4, 1,
9, 14, 10, 6, 4, 12, 9, 10, 1, 4, 14, 12, 6, 10, 4, 9,
12, 1, 6, 14, 8, 14, 2, 6, 3, 12, 11, 2, 8, 3, 14, 11,
6, 12, 3, 2, 11, 8, 12, 14, 6, 11, 3, 12, 2, 6, 8, 14,
12, 11, 6, 3, 14, 2, 8, 6, 12, 14, 11, 8, 3, 2, 14, 6,
8, 12, 2, 11, 3, 11, 12, 3, 6, 2, 14, 8, 12, 6, 11,
14, 3, 8, 2, 6, 14, 12, 8, 11, 2, 3, 14, 8, 6, 2, 12,
3, 11, 8, 2, 14, 3, 6, 11, 12, 2, 3, 8, 11, 14, 12, 6,
3, 11, 2, 12, 8, 6, 14), 224, 7, byrow = T)
} else if (all(williams_D == 8, selection == 186, type == "R")) {
sequences <- matrix(c(3, 4, 12, 6, 11, 8, 10, 9, 4, 6, 3, 8, 12, 9, 11, 10,
6, 8, 4, 9, 3, 10, 12, 11, 8, 9, 6, 10, 4, 11, 3, 12,
9, 10, 8, 11, 6, 12, 4, 3, 10, 11, 9, 12, 8, 3, 6, 4,
11, 12, 10, 3, 9, 4, 8, 6, 12, 3, 11, 4, 10, 6, 9, 8,
4, 5, 1, 7, 12, 9, 11, 10, 5, 7, 4, 9, 1, 10, 12, 11,
7, 9, 5, 10, 4, 11, 1, 12, 9, 10, 7, 11, 5, 12, 4, 1,
10, 11, 9, 12, 7, 1, 5, 4, 11, 12, 10, 1, 9, 4, 7, 5,
12, 1, 11, 4, 10, 5, 9, 7, 1, 4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 5, 1, 3, 11, 4, 10, 5, 7, 6, 3, 4, 1, 5,
11, 6, 10, 7, 4, 5, 3, 6, 1, 7, 11, 10, 5, 6, 4, 7, 3,
10, 1, 11, 6, 7, 5, 10, 4, 11, 3, 1, 7, 10, 6, 11, 5,
1, 4, 3, 11, 12, 8, 2, 7, 4, 6, 5, 12, 2, 11, 4, 8, 5,
7, 6, 2, 4, 12, 5, 11, 6, 8, 7, 4, 5, 2, 6, 12, 7, 11,
8, 5, 6, 4, 7, 2, 8, 12, 11, 6, 7, 5, 8, 4, 11, 2, 12,
7, 8, 6, 11, 5, 12, 4, 2, 8, 11, 7, 12, 6, 2, 5, 4,
12, 1, 9, 3, 8, 5, 7, 6, 1, 3, 12, 5, 9, 6, 8, 7, 3,
5, 1, 6, 12, 7, 9, 8, 5, 6, 3, 7, 1, 8, 12, 9, 6, 7,
5, 8, 3, 9, 1, 12, 7, 8, 6, 9, 5, 12, 3, 1, 8, 9, 7,
12, 6, 1, 5, 3, 9, 12, 8, 1, 7, 3, 6, 5, 1, 2, 10, 4,
9, 6, 8, 7, 2, 4, 1, 6, 10, 7, 9, 8, 4, 6, 2, 7, 1, 8,
10, 9, 6, 7, 4, 8, 2, 9, 1, 10, 7, 8, 6, 9, 4, 10, 2,
1, 8, 9, 7, 10, 6, 1, 4, 2, 9, 10, 8, 1, 7, 2, 6, 4,
10, 1, 9, 2, 8, 4, 7, 6, 2, 3, 11, 5, 10, 7, 9, 8, 3,
5, 2, 7, 11, 8, 10, 9, 5, 7, 3, 8, 2, 9, 11, 10, 7, 8,
5, 9, 3, 10, 2, 11, 8, 9, 7, 10, 5, 11, 3, 2, 9, 10,
8, 11, 7, 2, 5, 3, 10, 11, 9, 2, 8, 3, 7, 5, 11, 2,
10, 3, 9, 5, 8, 7), 96, 8, byrow = T)
} else if (all(williams_D == 8, selection == 51, type == "S")) {
sequences <- matrix(c(1, 6, 9, 2, 4, 7, 8, 3, 6, 2, 1, 7, 9, 3, 4, 8, 2, 7,
6, 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11,
5, 1, 2, 4, 10, 7, 11, 1, 8, 4, 5, 7, 2, 10, 2, 5, 12,
8, 9, 11, 6, 3, 5, 8, 2, 11, 12, 3, 9, 6, 8, 11, 5, 3,
2, 6, 12, 9, 11, 3, 8, 6, 5, 9, 2, 12, 3, 6, 11, 9, 8,
12, 5, 2, 6, 9, 3, 12, 11, 2, 8, 5, 9, 12, 6, 2, 3, 5,
11, 8, 12, 2, 9, 5, 6, 8, 3, 11, 3, 6, 10, 9, 7, 12,
4, 1, 6, 9, 3, 12, 10, 1, 7, 4, 9, 12, 6, 1, 3, 4, 10,
7, 12, 1, 9, 4, 6, 7, 3, 10, 1, 4, 12, 7, 9, 10, 6, 3,
4, 7, 1, 10, 12, 3, 9, 6, 7, 10, 4, 3, 1, 6, 12, 9,
10, 3, 7, 6, 4, 9, 1, 12), 24, 8, byrow = T)
} else if (all(williams_D == 8, selection == 58, type == "S")) {
sequences <- matrix(c(3, 9, 12, 4, 6, 10, 11, 5, 9, 4, 3, 10, 12, 5, 6, 11,
4, 10, 9, 5, 3, 11, 12, 6, 10, 5, 4, 11, 9, 6, 3, 12,
5, 11, 10, 6, 4, 12, 9, 3, 11, 6, 5, 12, 10, 3, 4, 9,
6, 12, 11, 3, 5, 9, 10, 4, 12, 3, 6, 9, 11, 4, 5, 10,
2, 8, 12, 4, 6, 10, 11, 5, 8, 4, 2, 10, 12, 5, 6, 11,
4, 10, 8, 5, 2, 11, 12, 6, 10, 5, 4, 11, 8, 6, 2, 12,
5, 11, 10, 6, 4, 12, 8, 2, 11, 6, 5, 12, 10, 2, 4, 8,
6, 12, 11, 2, 5, 8, 10, 4, 12, 2, 6, 8, 11, 4, 5, 10,
2, 8, 12, 3, 6, 9, 11, 5, 8, 3, 2, 9, 12, 5, 6, 11, 3,
9, 8, 5, 2, 11, 12, 6, 9, 5, 3, 11, 8, 6, 2, 12, 5,
11, 9, 6, 3, 12, 8, 2, 11, 6, 5, 12, 9, 2, 3, 8, 6,
12, 11, 2, 5, 8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3, 9, 8, 5, 2, 11, 7, 1, 9, 5, 3,
11, 8, 1, 2, 7, 5, 11, 9, 1, 3, 7, 8, 2, 11, 1, 5, 7,
9, 2, 3, 8, 1, 7, 10, 2, 4, 8, 9, 3, 7, 2, 1, 8, 10,
3, 4, 9, 2, 8, 7, 3, 1, 9, 10, 4, 8, 3, 2, 9, 7, 4, 1,
10, 3, 9, 8, 4, 2, 10, 7, 1, 9, 4, 3, 10, 8, 1, 2, 7,
4, 10, 9, 1, 3, 7, 8, 2, 10, 1, 4, 7, 9, 2, 3, 8),
120, 8, byrow = T)
} else if (all(williams_D == 8, selection == 59, type == "S")) {
sequences <- matrix(c(7, 14, 10, 6, 3, 13, 12, 5, 14, 6, 7, 13, 10, 5, 3,
12, 6, 13, 14, 5, 7, 12, 10, 3, 13, 5, 6, 12, 14, 3,
7, 10, 5, 12, 13, 3, 6, 10, 14, 7, 12, 3, 5, 10, 13,
7, 6, 14, 3, 10, 12, 7, 5, 14, 13, 6, 10, 7, 3, 14,
12, 6, 5, 13, 1, 8, 11, 7, 4, 14, 13, 6, 8, 7, 1, 14,
11, 6, 4, 13, 7, 14, 8, 6, 1, 13, 11, 4, 14, 6, 7, 13,
8, 4, 1, 11, 6, 13, 14, 4, 7, 11, 8, 1, 13, 4, 6, 11,
14, 1, 7, 8, 4, 11, 13, 1, 6, 8, 14, 7, 11, 1, 4, 8,
13, 7, 6, 14, 2, 9, 12, 1, 5, 8, 14, 7, 9, 1, 2, 8,
12, 7, 5, 14, 1, 8, 9, 7, 2, 14, 12, 5, 8, 7, 1, 14,
9, 5, 2, 12, 7, 14, 8, 5, 1, 12, 9, 2, 14, 5, 7, 12,
8, 2, 1, 9, 5, 12, 14, 2, 7, 9, 8, 1, 12, 2, 5, 9, 14,
1, 7, 8, 3, 10, 13, 2, 6, 9, 8, 1, 10, 2, 3, 9, 13, 1,
6, 8, 2, 9, 10, 1, 3, 8, 13, 6, 9, 1, 2, 8, 10, 6, 3,
13, 1, 8, 9, 6, 2, 13, 10, 3, 8, 6, 1, 13, 9, 3, 2,
10, 6, 13, 8, 3, 1, 10, 9, 2, 13, 3, 6, 10, 8, 2, 1,
9, 4, 11, 14, 3, 7, 10, 9, 2, 11, 3, 4, 10, 14, 2, 7,
9, 3, 10, 11, 2, 4, 9, 14, 7, 10, 2, 3, 9, 11, 7, 4,
14, 2, 9, 10, 7, 3, 14, 11, 4, 9, 7, 2, 14, 10, 4, 3,
11, 7, 14, 9, 4, 2, 11, 10, 3, 14, 4, 7, 11, 9, 3, 2,
10, 5, 12, 8, 4, 1, 11, 10, 3, 12, 4, 5, 11, 8, 3, 1,
10, 4, 11, 12, 3, 5, 10, 8, 1, 11, 3, 4, 10, 12, 1, 5,
8, 3, 10, 11, 1, 4, 8, 12, 5, 10, 1, 3, 8, 11, 5, 4,
12, 1, 8, 10, 5, 3, 12, 11, 4, 8, 5, 1, 12, 10, 4, 3,
11, 6, 13, 9, 5, 2, 12, 11, 4, 13, 5, 6, 12, 9, 4, 2,
11, 5, 12, 13, 4, 6, 11, 9, 2, 12, 4, 5, 11, 13, 2, 6,
9, 4, 11, 12, 2, 5, 9, 13, 6, 11, 2, 4, 9, 12, 6, 5,
13, 2, 9, 11, 6, 4, 13, 12, 5, 9, 6, 2, 13, 11, 5, 4,
12), 56, 8, byrow = T)
} else if (all(williams_D == 8, selection == 61, type == "S")) {
sequences <- matrix(c(1, 5, 14, 9, 10, 13, 6, 2, 5, 9, 1, 13, 14, 2, 10, 6,
9, 13, 5, 2, 1, 6, 14, 10, 13, 2, 9, 6, 5, 10, 1, 14,
2, 6, 13, 10, 9, 14, 5, 1, 6, 10, 2, 14, 13, 1, 9, 5,
10, 14, 6, 1, 2, 5, 13, 9, 14, 1, 10, 5, 6, 9, 2, 13,
3, 7, 16, 11, 12, 15, 8, 4, 7, 11, 3, 15, 16, 4, 12,
8, 11, 15, 7, 4, 3, 8, 16, 12, 15, 4, 11, 8, 7, 12, 3,
16, 4, 8, 15, 12, 11, 16, 7, 3, 8, 12, 4, 16, 15, 3,
11, 7, 12, 16, 8, 3, 4, 7, 15, 11, 16, 3, 12, 7, 8,
11, 4, 15, 1, 5, 15, 9, 11, 13, 7, 3, 5, 9, 1, 13, 15,
3, 11, 7, 9, 13, 5, 3, 1, 7, 15, 11, 13, 3, 9, 7, 5,
11, 1, 15, 3, 7, 13, 11, 9, 15, 5, 1, 7, 11, 3, 15,
13, 1, 9, 5, 11, 15, 7, 1, 3, 5, 13, 9, 15, 1, 11, 5,
7, 9, 3, 13, 2, 6, 16, 10, 12, 14, 8, 4, 6, 10, 2, 14,
16, 4, 12, 8, 10, 14, 6, 4, 2, 8, 16, 12, 14, 4, 10,
8, 6, 12, 2, 16, 4, 8, 14, 12, 10, 16, 6, 2, 8, 12, 4,
16, 14, 2, 10, 6, 12, 16, 8, 2, 4, 6, 14, 10, 16, 2,
12, 6, 8, 10, 4, 14, 1, 5, 16, 9, 12, 13, 8, 4, 5, 9,
1, 13, 16, 4, 12, 8, 9, 13, 5, 4, 1, 8, 16, 12, 13, 4,
9, 8, 5, 12, 1, 16, 4, 8, 13, 12, 9, 16, 5, 1, 8, 12,
4, 16, 13, 1, 9, 5, 12, 16, 8, 1, 4, 5, 13, 9, 16, 1,
12, 5, 8, 9, 4, 13, 2, 6, 15, 10, 11, 14, 7, 3, 6, 10,
2, 14, 15, 3, 11, 7, 10, 14, 6, 3, 2, 7, 15, 11, 14,
3, 10, 7, 6, 11, 2, 15, 3, 7, 14, 11, 10, 15, 6, 2, 7,
11, 3, 15, 14, 2, 10, 6, 11, 15, 7, 2, 3, 6, 14, 10,
15, 2, 11, 6, 7, 10, 3, 14), 48, 8, byrow = T)
} else if (all(williams_D == 8, selection == 63, type == "S")) {
sequences <- matrix(c(1, 9, 15, 2, 7, 10, 12, 4, 9, 2, 1, 10, 15, 4, 7, 12,
2, 10, 9, 4, 1, 12, 15, 7, 10, 4, 2, 12, 9, 7, 1, 15,
4, 12, 10, 7, 2, 15, 9, 1, 12, 7, 4, 15, 10, 1, 2, 9,
7, 15, 12, 1, 4, 9, 10, 2, 15, 1, 7, 9, 12, 2, 4, 10,
8, 16, 13, 3, 5, 11, 14, 6, 16, 3, 8, 11, 13, 6, 5,
14, 3, 11, 16, 6, 8, 14, 13, 5, 11, 6, 3, 14, 16, 5,
8, 13, 6, 14, 11, 5, 3, 13, 16, 8, 14, 5, 6, 13, 11,
8, 3, 16, 5, 13, 14, 8, 6, 16, 11, 3, 13, 8, 5, 16,
14, 3, 6, 11, 2, 10, 9, 3, 1, 11, 13, 5, 10, 3, 2, 11,
9, 5, 1, 13, 3, 11, 10, 5, 2, 13, 9, 1, 11, 5, 3, 13,
10, 1, 2, 9, 5, 13, 11, 1, 3, 9, 10, 2, 13, 1, 5, 9,
11, 2, 3, 10, 1, 9, 13, 2, 5, 10, 11, 3, 9, 2, 1, 10,
13, 3, 5, 11, 8, 16, 14, 4, 6, 12, 15, 7, 16, 4, 8,
12, 14, 7, 6, 15, 4, 12, 16, 7, 8, 15, 14, 6, 12, 7,
4, 15, 16, 6, 8, 14, 7, 15, 12, 6, 4, 14, 16, 8, 15,
6, 7, 14, 12, 8, 4, 16, 6, 14, 15, 8, 7, 16, 12, 4,
14, 8, 6, 16, 15, 4, 7, 12, 3, 11, 10, 4, 2, 12, 14,
6, 11, 4, 3, 12, 10, 6, 2, 14, 4, 12, 11, 6, 3, 14,
10, 2, 12, 6, 4, 14, 11, 2, 3, 10, 6, 14, 12, 2, 4,
10, 11, 3, 14, 2, 6, 10, 12, 3, 4, 11, 2, 10, 14, 3,
6, 11, 12, 4, 10, 3, 2, 11, 14, 4, 6, 12, 8, 16, 15,
5, 7, 13, 9, 1, 16, 5, 8, 13, 15, 1, 7, 9, 5, 13, 16,
1, 8, 9, 15, 7, 13, 1, 5, 9, 16, 7, 8, 15, 1, 9, 13,
7, 5, 15, 16, 8, 9, 7, 1, 15, 13, 8, 5, 16, 7, 15, 9,
8, 1, 16, 13, 5, 15, 8, 7, 16, 9, 5, 1, 13, 4, 12, 11,
5, 3, 13, 15, 7, 12, 5, 4, 13, 11, 7, 3, 15, 5, 13,
12, 7, 4, 15, 11, 3, 13, 7, 5, 15, 12, 3, 4, 11, 7,
15, 13, 3, 5, 11, 12, 4, 15, 3, 7, 11, 13, 4, 5, 12,
3, 11, 15, 4, 7, 12, 13, 5, 11, 4, 3, 12, 15, 5, 7,
13, 8, 16, 9, 6, 1, 14, 10, 2, 16, 6, 8, 14, 9, 2, 1,
10, 6, 14, 16, 2, 8, 10, 9, 1, 14, 2, 6, 10, 16, 1, 8,
9, 2, 10, 14, 1, 6, 9, 16, 8, 10, 1, 2, 9, 14, 8, 6,
16, 1, 9, 10, 8, 2, 16, 14, 6, 9, 8, 1, 16, 10, 6, 2,
14, 5, 13, 12, 6, 4, 14, 9, 1, 13, 6, 5, 14, 12, 1, 4,
9, 6, 14, 13, 1, 5, 9, 12, 4, 14, 1, 6, 9, 13, 4, 5,
12, 1, 9, 14, 4, 6, 12, 13, 5, 9, 4, 1, 12, 14, 5, 6,
13, 4, 12, 9, 5, 1, 13, 14, 6, 12, 5, 4, 13, 9, 6, 1,
14, 8, 16, 10, 7, 2, 15, 11, 3, 16, 7, 8, 15, 10, 3,
2, 11, 7, 15, 16, 3, 8, 11, 10, 2, 15, 3, 7, 11, 16,
2, 8, 10, 3, 11, 15, 2, 7, 10, 16, 8, 11, 2, 3, 10,
15, 8, 7, 16, 2, 10, 11, 8, 3, 16, 15, 7, 10, 8, 2,
16, 11, 7, 3, 15, 6, 14, 13, 7, 5, 15, 10, 2, 14, 7,
6, 15, 13, 2, 5, 10, 7, 15, 14, 2, 6, 10, 13, 5, 15,
2, 7, 10, 14, 5, 6, 13, 2, 10, 15, 5, 7, 13, 14, 6,
10, 5, 2, 13, 15, 6, 7, 14, 5, 13, 10, 6, 2, 14, 15,
7, 13, 6, 5, 14, 10, 7, 2, 15, 8, 16, 11, 1, 3, 9, 12,
4, 16, 1, 8, 9, 11, 4, 3, 12, 1, 9, 16, 4, 8, 12, 11,
3, 9, 4, 1, 12, 16, 3, 8, 11, 4, 12, 9, 3, 1, 11, 16,
8, 12, 3, 4, 11, 9, 8, 1, 16, 3, 11, 12, 8, 4, 16, 9,
1, 11, 8, 3, 16, 12, 1, 4, 9, 7, 15, 14, 1, 6, 9, 11,
3, 15, 1, 7, 9, 14, 3, 6, 11, 1, 9, 15, 3, 7, 11, 14,
6, 9, 3, 1, 11, 15, 6, 7, 14, 3, 11, 9, 6, 1, 14, 15,
7, 11, 6, 3, 14, 9, 7, 1, 15, 6, 14, 11, 7, 3, 15, 9,
1, 14, 7, 6, 15, 11, 1, 3, 9, 8, 16, 12, 2, 4, 10, 13,
5, 16, 2, 8, 10, 12, 5, 4, 13, 2, 10, 16, 5, 8, 13,
12, 4, 10, 5, 2, 13, 16, 4, 8, 12, 5, 13, 10, 4, 2,
12, 16, 8, 13, 4, 5, 12, 10, 8, 2, 16, 4, 12, 13, 8,
5, 16, 10, 2, 12, 8, 4, 16, 13, 2, 5, 10), 112, 8,
byrow = T)
} else if (all(williams_D == 8, selection == 65, type == "S")) {
sequences <- matrix(c(1, 10, 13, 2, 4, 11, 12, 3, 10, 2, 1, 11, 13, 3, 4,
12, 2, 11, 10, 3, 1, 12, 13, 4, 11, 3, 2, 12, 10, 4,
1, 13, 3, 12, 11, 4, 2, 13, 10, 1, 12, 4, 3, 13, 11,
1, 2, 10, 4, 13, 12, 1, 3, 10, 11, 2, 13, 1, 4, 10,
12, 2, 3, 11, 6, 15, 14, 1, 5, 10, 11, 2, 15, 1, 6,
10, 14, 2, 5, 11, 1, 10, 15, 2, 6, 11, 14, 5, 10, 2,
1, 11, 15, 5, 6, 14, 2, 11, 10, 5, 1, 14, 15, 6, 11,
5, 2, 14, 10, 6, 1, 15, 5, 14, 11, 6, 2, 15, 10, 1,
14, 6, 5, 15, 11, 1, 2, 10, 7, 16, 11, 8, 2, 17, 10,
1, 16, 8, 7, 17, 11, 1, 2, 10, 8, 17, 16, 1, 7, 10,
11, 2, 17, 1, 8, 10, 16, 2, 7, 11, 1, 10, 17, 2, 8,
11, 16, 7, 10, 2, 1, 11, 17, 7, 8, 16, 2, 11, 10, 7,
1, 16, 17, 8, 11, 7, 2, 16, 10, 8, 1, 17, 5, 14, 10,
3, 1, 12, 16, 7, 14, 3, 5, 12, 10, 7, 1, 16, 3, 12,
14, 7, 5, 16, 10, 1, 12, 7, 3, 16, 14, 1, 5, 10, 7,
16, 12, 1, 3, 10, 14, 5, 16, 1, 7, 10, 12, 5, 3, 14,
1, 10, 16, 5, 7, 14, 12, 3, 10, 5, 1, 14, 16, 3, 7,
12, 10, 1, 4, 6, 13, 15, 17, 8, 1, 6, 10, 15, 4, 8,
13, 17, 6, 15, 1, 8, 10, 17, 4, 13, 15, 8, 6, 17, 1,
13, 10, 4, 8, 17, 15, 13, 6, 4, 1, 10, 17, 13, 8, 4,
15, 10, 6, 1, 13, 4, 17, 10, 8, 1, 15, 6, 4, 10, 13,
1, 17, 6, 8, 15, 15, 6, 18, 10, 9, 1, 3, 12, 6, 10,
15, 1, 18, 12, 9, 3, 10, 1, 6, 12, 15, 3, 18, 9, 1,
12, 10, 3, 6, 9, 15, 18, 12, 3, 1, 9, 10, 18, 6, 15,
3, 9, 12, 18, 1, 15, 10, 6, 9, 18, 3, 15, 12, 6, 1,
10, 18, 15, 9, 6, 3, 10, 12, 1, 9, 18, 17, 4, 8, 13,
1, 10, 18, 4, 9, 13, 17, 10, 8, 1, 4, 13, 18, 10, 9,
1, 17, 8, 13, 10, 4, 1, 18, 8, 9, 17, 10, 1, 13, 8, 4,
17, 18, 9, 1, 8, 10, 17, 13, 9, 4, 18, 8, 17, 1, 9,
10, 18, 13, 4, 17, 9, 8, 18, 1, 4, 10, 13, 18, 9, 1,
5, 10, 14, 7, 16, 9, 5, 18, 14, 1, 16, 10, 7, 5, 14,
9, 16, 18, 7, 1, 10, 14, 16, 5, 7, 9, 10, 18, 1, 16,
7, 14, 10, 5, 1, 9, 18, 7, 10, 16, 1, 14, 18, 5, 9,
10, 1, 7, 18, 16, 9, 14, 5, 1, 18, 10, 9, 7, 5, 16,
14, 2, 11, 9, 12, 18, 3, 8, 17, 11, 12, 2, 3, 9, 17,
18, 8, 12, 3, 11, 17, 2, 8, 9, 18, 3, 17, 12, 8, 11,
18, 2, 9, 17, 8, 3, 18, 12, 9, 11, 2, 8, 18, 17, 9, 3,
2, 12, 11, 18, 9, 8, 2, 17, 11, 3, 12, 9, 2, 18, 11,
8, 12, 17, 3, 4, 13, 5, 11, 14, 2, 18, 9, 13, 11, 4,
2, 5, 9, 14, 18, 11, 2, 13, 9, 4, 18, 5, 14, 2, 9, 11,
18, 13, 14, 4, 5, 9, 18, 2, 14, 11, 5, 13, 4, 18, 14,
9, 5, 2, 4, 11, 13, 14, 5, 18, 4, 9, 13, 2, 11, 5, 4,
14, 13, 18, 11, 9, 2, 16, 7, 15, 9, 6, 18, 2, 11, 7,
9, 16, 18, 15, 11, 6, 2, 9, 18, 7, 11, 16, 2, 15, 6,
18, 11, 9, 2, 7, 6, 16, 15, 11, 2, 18, 6, 9, 15, 7,
16, 2, 6, 11, 15, 18, 16, 9, 7, 6, 15, 2, 16, 11, 7,
18, 9, 15, 16, 6, 7, 2, 9, 11, 18, 11, 2, 12, 7, 3,
16, 13, 4, 2, 7, 11, 16, 12, 4, 3, 13, 7, 16, 2, 4,
11, 13, 12, 3, 16, 4, 7, 13, 2, 3, 11, 12, 4, 13, 16,
3, 7, 12, 2, 11, 13, 3, 4, 12, 16, 11, 7, 2, 3, 12,
13, 11, 4, 2, 16, 7, 12, 11, 3, 2, 13, 7, 4, 16, 8,
17, 2, 15, 11, 6, 14, 5, 17, 15, 8, 6, 2, 5, 11, 14,
15, 6, 17, 5, 8, 14, 2, 11, 6, 5, 15, 14, 17, 11, 8,
2, 5, 14, 6, 11, 15, 2, 17, 8, 14, 11, 5, 2, 6, 8, 15,
17, 11, 2, 14, 8, 5, 17, 6, 15, 2, 8, 11, 17, 14, 15,
5, 6, 3, 12, 8, 14, 17, 5, 9, 18, 12, 14, 3, 5, 8, 18,
17, 9, 14, 5, 12, 18, 3, 9, 8, 17, 5, 18, 14, 9, 12,
17, 3, 8, 18, 9, 5, 17, 14, 8, 12, 3, 9, 17, 18, 8, 5,
3, 14, 12, 17, 8, 9, 3, 18, 12, 5, 14, 8, 3, 17, 12,
9, 14, 18, 5, 13, 4, 7, 18, 16, 9, 6, 15, 4, 18, 13,
9, 7, 15, 16, 6, 18, 9, 4, 15, 13, 6, 7, 16, 9, 15,
18, 6, 4, 16, 13, 7, 15, 6, 9, 16, 18, 7, 4, 13, 6,
16, 15, 7, 9, 13, 18, 4, 16, 7, 6, 13, 15, 4, 9, 18,
7, 13, 16, 4, 6, 18, 15, 9, 12, 3, 6, 13, 15, 4, 5,
14, 3, 13, 12, 4, 6, 14, 15, 5, 13, 4, 3, 14, 12, 5,
6, 15, 4, 14, 13, 5, 3, 15, 12, 6, 14, 5, 4, 15, 13,
6, 3, 12, 5, 15, 14, 6, 4, 12, 13, 3, 15, 6, 5, 12,
14, 3, 4, 13, 6, 12, 15, 3, 5, 13, 14, 4, 17, 8, 3,
16, 12, 7, 15, 6, 8, 16, 17, 7, 3, 6, 12, 15, 16, 7,
8, 6, 17, 15, 3, 12, 7, 6, 16, 15, 8, 12, 17, 3, 6,
15, 7, 12, 16, 3, 8, 17, 15, 12, 6, 3, 7, 17, 16, 8,
12, 3, 15, 17, 6, 8, 7, 16, 3, 17, 12, 8, 15, 16, 6,
7, 14, 5, 16, 17, 7, 8, 4, 13, 5, 17, 14, 8, 16, 13,
7, 4, 17, 8, 5, 13, 14, 4, 16, 7, 8, 13, 17, 4, 5, 7,
14, 16, 13, 4, 8, 7, 17, 16, 5, 14, 4, 7, 13, 16, 8,
14, 17, 5, 7, 16, 4, 14, 13, 5, 8, 17, 16, 14, 7, 5,
4, 17, 13, 8), 144, 8, byrow = T)
} else if (all(williams_D == 8, selection == 66, type == "S")) {
sequences <- matrix(c(1, 6, 17, 11, 12, 16, 7, 2, 6, 11, 1, 16, 17, 2, 12,
7, 11, 16, 6, 2, 1, 7, 17, 12, 16, 2, 11, 7, 6, 12, 1,
17, 2, 7, 16, 12, 11, 17, 6, 1, 7, 12, 2, 17, 16, 1,
11, 6, 12, 17, 7, 1, 2, 6, 16, 11, 17, 1, 12, 6, 7,
11, 2, 16, 2, 7, 18, 12, 13, 17, 8, 3, 7, 12, 2, 17,
18, 3, 13, 8, 12, 17, 7, 3, 2, 8, 18, 13, 17, 3, 12,
8, 7, 13, 2, 18, 3, 8, 17, 13, 12, 18, 7, 2, 8, 13, 3,
18, 17, 2, 12, 7, 13, 18, 8, 2, 3, 7, 17, 12, 18, 2,
13, 7, 8, 12, 3, 17, 3, 8, 19, 13, 14, 18, 9, 4, 8,
13, 3, 18, 19, 4, 14, 9, 13, 18, 8, 4, 3, 9, 19, 14,
18, 4, 13, 9, 8, 14, 3, 19, 4, 9, 18, 14, 13, 19, 8,
3, 9, 14, 4, 19, 18, 3, 13, 8, 14, 19, 9, 3, 4, 8, 18,
13, 19, 3, 14, 8, 9, 13, 4, 18, 4, 9, 20, 14, 15, 19,
10, 5, 9, 14, 4, 19, 20, 5, 15, 10, 14, 19, 9, 5, 4,
10, 20, 15, 19, 5, 14, 10, 9, 15, 4, 20, 5, 10, 19,
15, 14, 20, 9, 4, 10, 15, 5, 20, 19, 4, 14, 9, 15, 20,
10, 4, 5, 9, 19, 14, 20, 4, 15, 9, 10, 14, 5, 19, 5,
10, 16, 15, 11, 20, 6, 1, 10, 15, 5, 20, 16, 1, 11, 6,
15, 20, 10, 1, 5, 6, 16, 11, 20, 1, 15, 6, 10, 11, 5,
16, 1, 6, 20, 11, 15, 16, 10, 5, 6, 11, 1, 16, 20, 5,
15, 10, 11, 16, 6, 5, 1, 10, 20, 15, 16, 5, 11, 10, 6,
15, 1, 20, 1, 6, 18, 11, 13, 16, 8, 3, 6, 11, 1, 16,
18, 3, 13, 8, 11, 16, 6, 3, 1, 8, 18, 13, 16, 3, 11,
8, 6, 13, 1, 18, 3, 8, 16, 13, 11, 18, 6, 1, 8, 13, 3,
18, 16, 1, 11, 6, 13, 18, 8, 1, 3, 6, 16, 11, 18, 1,
13, 6, 8, 11, 3, 16, 2, 7, 19, 12, 14, 17, 9, 4, 7,
12, 2, 17, 19, 4, 14, 9, 12, 17, 7, 4, 2, 9, 19, 14,
17, 4, 12, 9, 7, 14, 2, 19, 4, 9, 17, 14, 12, 19, 7,
2, 9, 14, 4, 19, 17, 2, 12, 7, 14, 19, 9, 2, 4, 7, 17,
12, 19, 2, 14, 7, 9, 12, 4, 17, 3, 8, 20, 13, 15, 18,
10, 5, 8, 13, 3, 18, 20, 5, 15, 10, 13, 18, 8, 5, 3,
10, 20, 15, 18, 5, 13, 10, 8, 15, 3, 20, 5, 10, 18,
15, 13, 20, 8, 3, 10, 15, 5, 20, 18, 3, 13, 8, 15, 20,
10, 3, 5, 8, 18, 13, 20, 3, 15, 8, 10, 13, 5, 18, 4,
9, 16, 14, 11, 19, 6, 1, 9, 14, 4, 19, 16, 1, 11, 6,
14, 19, 9, 1, 4, 6, 16, 11, 19, 1, 14, 6, 9, 11, 4,
16, 1, 6, 19, 11, 14, 16, 9, 4, 6, 11, 1, 16, 19, 4,
14, 9, 11, 16, 6, 4, 1, 9, 19, 14, 16, 4, 11, 9, 6,
14, 1, 19, 5, 10, 17, 15, 12, 20, 7, 2, 10, 15, 5, 20,
17, 2, 12, 7, 15, 20, 10, 2, 5, 7, 17, 12, 20, 2, 15,
7, 10, 12, 5, 17, 2, 7, 20, 12, 15, 17, 10, 5, 7, 12,
2, 17, 20, 5, 15, 10, 12, 17, 7, 5, 2, 10, 20, 15, 17,
5, 12, 10, 7, 15, 2, 20), 80, 8, byrow = T)
} else if (all(williams_D == 8, selection == 67, type == "S")) {
sequences <- matrix(c(1, 11, 20, 4, 10, 14, 17, 7, 11, 4, 1, 14, 20, 7, 10,
17, 4, 14, 11, 7, 1, 17, 20, 10, 14, 7, 4, 17, 11, 10,
1, 20, 7, 17, 14, 10, 4, 20, 11, 1, 17, 10, 7, 20, 14,
1, 4, 11, 10, 20, 17, 1, 7, 11, 14, 4, 20, 1, 10, 11,
17, 4, 7, 14, 5, 15, 14, 9, 4, 19, 13, 3, 15, 9, 5,
19, 14, 3, 4, 13, 9, 19, 15, 3, 5, 13, 14, 4, 19, 3,
9, 13, 15, 4, 5, 14, 3, 13, 19, 4, 9, 14, 15, 5, 13,
4, 3, 14, 19, 5, 9, 15, 4, 14, 13, 5, 3, 15, 19, 9,
14, 5, 4, 15, 13, 9, 3, 19, 3, 13, 18, 7, 8, 17, 16,
6, 13, 7, 3, 17, 18, 6, 8, 16, 7, 17, 13, 6, 3, 16,
18, 8, 17, 6, 7, 16, 13, 8, 3, 18, 6, 16, 17, 8, 7,
18, 13, 3, 16, 8, 6, 18, 17, 3, 7, 13, 8, 18, 16, 3,
6, 13, 17, 7, 18, 3, 8, 13, 16, 7, 6, 17, 2, 12, 19,
6, 9, 16, 11, 1, 12, 6, 2, 16, 19, 1, 9, 11, 6, 16,
12, 1, 2, 11, 19, 9, 16, 1, 6, 11, 12, 9, 2, 19, 1,
11, 16, 9, 6, 19, 12, 2, 11, 9, 1, 19, 16, 2, 6, 12,
9, 19, 11, 2, 1, 12, 16, 6, 19, 2, 9, 12, 11, 6, 1,
16, 8, 18, 15, 10, 5, 20, 12, 2, 18, 10, 8, 20, 15, 2,
5, 12, 10, 20, 18, 2, 8, 12, 15, 5, 20, 2, 10, 12, 18,
5, 8, 15, 2, 12, 20, 5, 10, 15, 18, 8, 12, 5, 2, 15,
20, 8, 10, 18, 5, 15, 12, 8, 2, 18, 20, 10, 15, 8, 5,
18, 12, 10, 2, 20, 4, 14, 16, 2, 6, 12, 18, 8, 14, 2,
4, 12, 16, 8, 6, 18, 2, 12, 14, 8, 4, 18, 16, 6, 12,
8, 2, 18, 14, 6, 4, 16, 8, 18, 12, 6, 2, 16, 14, 4,
18, 6, 8, 16, 12, 4, 2, 14, 6, 16, 18, 4, 8, 14, 12,
2, 16, 4, 6, 14, 18, 2, 8, 12, 7, 17, 12, 9, 2, 19,
15, 5, 17, 9, 7, 19, 12, 5, 2, 15, 9, 19, 17, 5, 7,
15, 12, 2, 19, 5, 9, 15, 17, 2, 7, 12, 5, 15, 19, 2,
9, 12, 17, 7, 15, 2, 5, 12, 19, 7, 9, 17, 2, 12, 15,
7, 5, 17, 19, 9, 12, 7, 2, 17, 15, 9, 5, 19, 5, 15,
11, 8, 1, 18, 13, 3, 15, 8, 5, 18, 11, 3, 1, 13, 8,
18, 15, 3, 5, 13, 11, 1, 18, 3, 8, 13, 15, 1, 5, 11,
3, 13, 18, 1, 8, 11, 15, 5, 13, 1, 3, 11, 18, 5, 8,
15, 1, 11, 13, 5, 3, 15, 18, 8, 11, 5, 1, 15, 13, 8,
3, 18, 6, 16, 20, 3, 10, 13, 19, 9, 16, 3, 6, 13, 20,
9, 10, 19, 3, 13, 16, 9, 6, 19, 20, 10, 13, 9, 3, 19,
16, 10, 6, 20, 9, 19, 13, 10, 3, 20, 16, 6, 19, 10, 9,
20, 13, 6, 3, 16, 10, 20, 19, 6, 9, 16, 13, 3, 20, 6,
10, 16, 19, 3, 9, 13, 2, 12, 13, 1, 3, 11, 20, 10, 12,
1, 2, 11, 13, 10, 3, 20, 1, 11, 12, 10, 2, 20, 13, 3,
11, 10, 1, 20, 12, 3, 2, 13, 10, 20, 11, 3, 1, 13, 12,
2, 20, 3, 10, 13, 11, 2, 1, 12, 3, 13, 20, 2, 10, 12,
11, 1, 13, 2, 3, 12, 20, 1, 10, 11, 9, 19, 17, 10, 7,
20, 18, 8, 19, 10, 9, 20, 17, 8, 7, 18, 10, 20, 19, 8,
9, 18, 17, 7, 20, 8, 10, 18, 19, 7, 9, 17, 8, 18, 20,
7, 10, 17, 19, 9, 18, 7, 8, 17, 20, 9, 10, 19, 7, 17,
18, 9, 8, 19, 20, 10, 17, 9, 7, 19, 18, 10, 8, 20, 1,
11, 15, 6, 5, 16, 17, 7, 11, 6, 1, 16, 15, 7, 5, 17,
6, 16, 11, 7, 1, 17, 15, 5, 16, 7, 6, 17, 11, 5, 1,
15, 7, 17, 16, 5, 6, 15, 11, 1, 17, 5, 7, 15, 16, 1,
6, 11, 5, 15, 17, 1, 7, 11, 16, 6, 15, 1, 5, 11, 17,
6, 7, 16, 10, 20, 16, 5, 6, 15, 14, 4, 20, 5, 10, 15,
16, 4, 6, 14, 5, 15, 20, 4, 10, 14, 16, 6, 15, 4, 5,
14, 20, 6, 10, 16, 4, 14, 15, 6, 5, 16, 20, 10, 14, 6,
4, 16, 15, 10, 5, 20, 6, 16, 14, 10, 4, 20, 15, 5, 16,
10, 6, 20, 14, 5, 4, 15, 4, 14, 19, 8, 9, 18, 11, 1,
14, 8, 4, 18, 19, 1, 9, 11, 8, 18, 14, 1, 4, 11, 19,
9, 18, 1, 8, 11, 14, 9, 4, 19, 1, 11, 18, 9, 8, 19,
14, 4, 11, 9, 1, 19, 18, 4, 8, 14, 9, 19, 11, 4, 1,
14, 18, 8, 19, 4, 9, 14, 11, 8, 1, 18, 3, 13, 14, 7,
4, 17, 12, 2, 13, 7, 3, 17, 14, 2, 4, 12, 7, 17, 13,
2, 3, 12, 14, 4, 17, 2, 7, 12, 13, 4, 3, 14, 2, 12,
17, 4, 7, 14, 13, 3, 12, 4, 2, 14, 17, 3, 7, 13, 4,
14, 12, 3, 2, 13, 17, 7, 14, 3, 4, 13, 12, 7, 2, 17),
120, 8, byrow = T)
} else if (all(williams_D == 8, selection == 90, type == "SR")) {
sequences <- matrix(c(1, 3, 4, 8, 7, 6, 5, 2, 3, 8, 1, 6, 4, 2, 7, 5, 8, 6,
3, 2, 1, 5, 4, 7, 6, 2, 8, 5, 3, 7, 1, 4, 2, 5, 6, 7,
8, 4, 3, 1, 5, 7, 2, 4, 6, 1, 8, 3, 7, 4, 5, 1, 2, 3,
6, 8, 4, 1, 7, 3, 5, 8, 2, 6, 1, 7, 12, 4, 11, 10, 5,
6, 7, 4, 1, 10, 12, 6, 11, 5, 4, 10, 7, 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, 3, 2, 12, 6, 5, 4, 11, 3,
12, 9, 5, 2, 11, 6, 4, 12, 5, 3, 11, 9, 4, 2, 6, 5, 3,
8, 12, 7, 10, 9, 6, 3, 12, 5, 10, 8, 6, 7, 9, 12, 10,
3, 6, 5, 9, 8, 7, 10, 6, 12, 9, 3, 7, 5, 8, 6, 9, 10,
7, 12, 8, 3, 5, 9, 7, 6, 8, 10, 5, 12, 3, 7, 8, 9, 5,
6, 3, 10, 12, 8, 5, 7, 3, 9, 12, 6, 10, 5, 7, 4, 8,
11, 2, 9, 10, 7, 8, 5, 2, 4, 10, 11, 9, 8, 2, 7, 10,
5, 9, 4, 11, 2, 10, 8, 9, 7, 11, 5, 4, 10, 9, 2, 11,
8, 4, 7, 5, 9, 11, 10, 4, 2, 5, 8, 7, 11, 4, 9, 5, 10,
7, 2, 8, 4, 5, 11, 7, 9, 8, 10, 2), 72, 8, byrow = T)
} else if (all(williams_D == 8, selection == 91, type == "SR")) {
sequences <- matrix(c(9, 10, 8, 3, 7, 12, 14, 13, 10, 3, 9, 12, 8, 13, 7,
14, 3, 12, 10, 13, 9, 14, 8, 7, 12, 13, 3, 14, 10, 7,
9, 8, 13, 14, 12, 7, 3, 8, 10, 9, 14, 7, 13, 8, 12, 9,
3, 10, 7, 8, 14, 9, 13, 10, 12, 3, 8, 9, 7, 10, 14, 3,
13, 12, 13, 10, 8, 14, 4, 15, 11, 1, 10, 14, 13, 15,
8, 1, 4, 11, 14, 15, 10, 1, 13, 11, 8, 4, 15, 1, 14,
11, 10, 4, 13, 8, 1, 11, 15, 4, 14, 8, 10, 13, 11, 4,
1, 8, 15, 13, 14, 10, 4, 8, 11, 13, 1, 10, 15, 14, 8,
13, 4, 10, 11, 14, 1, 15, 9, 2, 16, 11, 15, 12, 14, 5,
2, 11, 9, 12, 16, 5, 15, 14, 11, 12, 2, 5, 9, 14, 16,
15, 12, 5, 11, 14, 2, 15, 9, 16, 5, 14, 12, 15, 11,
16, 2, 9, 14, 15, 5, 16, 12, 9, 11, 2, 15, 16, 14, 9,
5, 2, 12, 11, 16, 9, 15, 2, 14, 11, 5, 12, 1, 10, 16,
3, 15, 12, 6, 13, 10, 3, 1, 12, 16, 13, 15, 6, 3, 12,
10, 13, 1, 6, 16, 15, 12, 13, 3, 6, 10, 15, 1, 16, 13,
6, 12, 15, 3, 16, 10, 1, 6, 15, 13, 16, 12, 1, 3, 10,
15, 16, 6, 1, 13, 10, 12, 3, 16, 1, 15, 10, 6, 3, 13,
12, 1, 2, 16, 11, 7, 4, 14, 13, 2, 11, 1, 4, 16, 13,
7, 14, 11, 4, 2, 13, 1, 14, 16, 7, 4, 13, 11, 14, 2,
7, 1, 16, 13, 14, 4, 7, 11, 16, 2, 1, 14, 7, 13, 16,
4, 1, 11, 2, 7, 16, 14, 1, 13, 2, 4, 11, 16, 1, 7, 2,
14, 11, 13, 4, 1, 2, 8, 3, 15, 14, 12, 5, 2, 3, 1, 14,
8, 5, 15, 12, 3, 14, 2, 5, 1, 12, 8, 15, 14, 5, 3, 12,
2, 15, 1, 8, 5, 12, 14, 15, 3, 8, 2, 1, 12, 15, 5, 8,
14, 1, 3, 2, 15, 8, 12, 1, 5, 2, 14, 3, 8, 1, 15, 2,
12, 3, 5, 14, 13, 6, 4, 15, 3, 16, 2, 9, 6, 15, 13,
16, 4, 9, 3, 2, 15, 16, 6, 9, 13, 2, 4, 3, 16, 9, 15,
2, 6, 3, 13, 4, 9, 2, 16, 3, 15, 4, 6, 13, 2, 3, 9, 4,
16, 13, 15, 6, 3, 4, 2, 13, 9, 6, 16, 15, 4, 13, 3, 6,
2, 15, 9, 16, 5, 14, 7, 4, 3, 16, 10, 9, 14, 4, 5, 16,
7, 9, 3, 10, 4, 16, 14, 9, 5, 10, 7, 3, 16, 9, 4, 10,
14, 3, 5, 7, 9, 10, 16, 3, 4, 7, 14, 5, 10, 3, 9, 7,
16, 5, 4, 14, 3, 7, 10, 5, 9, 14, 16, 4, 7, 5, 3, 14,
10, 4, 9, 16, 9, 4, 6, 15, 11, 8, 10, 5, 4, 15, 9, 8,
6, 5, 11, 10, 15, 8, 4, 5, 9, 10, 6, 11, 8, 5, 15, 10,
4, 11, 9, 6, 5, 10, 8, 11, 15, 6, 4, 9, 10, 11, 5, 6,
8, 9, 15, 4, 11, 6, 10, 9, 5, 4, 8, 15, 6, 9, 11, 4,
10, 15, 5, 8, 5, 11, 12, 7, 6, 16, 10, 1, 11, 7, 5,
16, 12, 1, 6, 10, 7, 16, 11, 1, 5, 10, 12, 6, 16, 1,
7, 10, 11, 6, 5, 12, 1, 10, 16, 6, 7, 12, 11, 5, 10,
6, 1, 12, 16, 5, 7, 11, 6, 12, 10, 5, 1, 11, 16, 7,
12, 5, 6, 11, 10, 7, 1, 16, 13, 6, 12, 7, 11, 8, 2, 9,
6, 7, 13, 8, 12, 9, 11, 2, 7, 8, 6, 9, 13, 2, 12, 11,
8, 9, 7, 2, 6, 11, 13, 12, 9, 2, 8, 11, 7, 12, 6, 13,
2, 11, 9, 12, 8, 13, 7, 6, 11, 12, 2, 13, 9, 6, 8, 7,
12, 13, 11, 6, 2, 7, 9, 8, 5, 6, 4, 7, 3, 8, 2, 1, 6,
7, 5, 8, 4, 1, 3, 2, 7, 8, 6, 1, 5, 2, 4, 3, 8, 1, 7,
2, 6, 3, 5, 4, 1, 2, 8, 3, 7, 4, 6, 5, 2, 3, 1, 4, 8,
5, 7, 6, 3, 4, 2, 5, 1, 6, 8, 7, 4, 5, 3, 6, 2, 7, 1,
8), 96, 8, byrow = T)
} else if (all(williams_D == 8, selection == 92, type == "SR")) {
sequences <- matrix(c(1, 2, 8, 3, 7, 4, 6, 5, 2, 3, 1, 4, 8, 5, 7, 6, 3, 4,
2, 5, 1, 6, 8, 7, 4, 5, 3, 6, 2, 7, 1, 8, 5, 6, 4, 7,
3, 8, 2, 1, 6, 7, 5, 8, 4, 1, 3, 2, 7, 8, 6, 1, 5, 2,
4, 3, 8, 1, 7, 2, 6, 3, 5, 4, 9, 10, 16, 11, 15, 12,
14, 13, 10, 11, 9, 12, 16, 13, 15, 14, 11, 12, 10, 13,
9, 14, 16, 15, 12, 13, 11, 14, 10, 15, 9, 16, 13, 14,
12, 15, 11, 16, 10, 9, 14, 15, 13, 16, 12, 9, 11, 10,
15, 16, 14, 9, 13, 10, 12, 11, 16, 9, 15, 10, 14, 11,
13, 12, 10, 3, 1, 12, 16, 5, 7, 14, 3, 12, 10, 5, 1,
14, 16, 7, 12, 5, 3, 14, 10, 7, 1, 16, 5, 14, 12, 7,
3, 16, 10, 1, 14, 7, 5, 16, 12, 1, 3, 10, 7, 16, 14,
1, 5, 10, 12, 3, 16, 1, 7, 10, 14, 3, 5, 12, 1, 10,
16, 3, 7, 12, 14, 5, 2, 11, 9, 4, 8, 13, 15, 6, 11, 4,
2, 13, 9, 6, 8, 15, 4, 13, 11, 6, 2, 15, 9, 8, 13, 6,
4, 15, 11, 8, 2, 9, 6, 15, 13, 8, 4, 9, 11, 2, 15, 8,
6, 9, 13, 2, 4, 11, 8, 9, 15, 2, 6, 11, 13, 4, 9, 2,
8, 11, 15, 4, 6, 13, 11, 12, 2, 5, 1, 6, 16, 15, 12,
5, 11, 6, 2, 15, 1, 16, 5, 6, 12, 15, 11, 16, 2, 1, 6,
15, 5, 16, 12, 1, 11, 2, 15, 16, 6, 1, 5, 2, 12, 11,
16, 1, 15, 2, 6, 11, 5, 12, 1, 2, 16, 11, 15, 12, 6,
5, 2, 11, 1, 12, 16, 5, 15, 6, 3, 4, 10, 13, 9, 14, 8,
7, 4, 13, 3, 14, 10, 7, 9, 8, 13, 14, 4, 7, 3, 8, 10,
9, 14, 7, 13, 8, 4, 9, 3, 10, 7, 8, 14, 9, 13, 10, 4,
3, 8, 9, 7, 10, 14, 3, 13, 4, 9, 10, 8, 3, 7, 4, 14,
13, 10, 3, 9, 4, 8, 13, 7, 14, 4, 5, 11, 14, 10, 15,
1, 8, 5, 14, 4, 15, 11, 8, 10, 1, 14, 15, 5, 8, 4, 1,
11, 10, 15, 8, 14, 1, 5, 10, 4, 11, 8, 1, 15, 10, 14,
11, 5, 4, 1, 10, 8, 11, 15, 4, 14, 5, 10, 11, 1, 4, 8,
5, 15, 14, 11, 4, 10, 5, 1, 14, 8, 15, 12, 13, 3, 6,
2, 7, 9, 16, 13, 6, 12, 7, 3, 16, 2, 9, 6, 7, 13, 16,
12, 9, 3, 2, 7, 16, 6, 9, 13, 2, 12, 3, 16, 9, 7, 2,
6, 3, 13, 12, 9, 2, 16, 3, 7, 12, 6, 13, 2, 3, 9, 12,
16, 13, 7, 6, 3, 12, 2, 13, 9, 6, 16, 7, 13, 14, 4,
15, 3, 16, 2, 1, 14, 15, 13, 16, 4, 1, 3, 2, 15, 16,
14, 1, 13, 2, 4, 3, 16, 1, 15, 2, 14, 3, 13, 4, 1, 2,
16, 3, 15, 4, 14, 13, 2, 3, 1, 4, 16, 13, 15, 14, 3,
4, 2, 13, 1, 14, 16, 15, 4, 13, 3, 14, 2, 15, 1, 16,
5, 6, 12, 7, 11, 8, 10, 9, 6, 7, 5, 8, 12, 9, 11, 10,
7, 8, 6, 9, 5, 10, 12, 11, 8, 9, 7, 10, 6, 11, 5, 12,
9, 10, 8, 11, 7, 12, 6, 5, 10, 11, 9, 12, 8, 5, 7, 6,
11, 12, 10, 5, 9, 6, 8, 7, 12, 5, 11, 6, 10, 7, 9, 8,
6, 15, 13, 8, 12, 1, 3, 10, 15, 8, 6, 1, 13, 10, 12,
3, 8, 1, 15, 10, 6, 3, 13, 12, 1, 10, 8, 3, 15, 12, 6,
13, 10, 3, 1, 12, 8, 13, 15, 6, 3, 12, 10, 13, 1, 6,
8, 15, 12, 13, 3, 6, 10, 15, 1, 8, 13, 6, 12, 15, 3,
8, 10, 1, 14, 7, 5, 16, 4, 9, 11, 2, 7, 16, 14, 9, 5,
2, 4, 11, 16, 9, 7, 2, 14, 11, 5, 4, 9, 2, 16, 11, 7,
4, 14, 5, 2, 11, 9, 4, 16, 5, 7, 14, 11, 4, 2, 5, 9,
14, 16, 7, 4, 5, 11, 14, 2, 7, 9, 16, 5, 14, 4, 7, 11,
16, 2, 9, 7, 8, 14, 1, 13, 2, 12, 11, 8, 1, 7, 2, 14,
11, 13, 12, 1, 2, 8, 11, 7, 12, 14, 13, 2, 11, 1, 12,
8, 13, 7, 14, 11, 12, 2, 13, 1, 14, 8, 7, 12, 13, 11,
14, 2, 7, 1, 8, 13, 14, 12, 7, 11, 8, 2, 1, 14, 7, 13,
8, 12, 1, 11, 2, 15, 16, 6, 9, 5, 10, 4, 3, 16, 9, 15,
10, 6, 3, 5, 4, 9, 10, 16, 3, 15, 4, 6, 5, 10, 3, 9,
4, 16, 5, 15, 6, 3, 4, 10, 5, 9, 6, 16, 15, 4, 5, 3,
6, 10, 15, 9, 16, 5, 6, 4, 15, 3, 16, 10, 9, 6, 15, 5,
16, 4, 9, 3, 10, 16, 1, 7, 10, 6, 11, 13, 4, 1, 10,
16, 11, 7, 4, 6, 13, 10, 11, 1, 4, 16, 13, 7, 6, 11,
4, 10, 13, 1, 6, 16, 7, 4, 13, 11, 6, 10, 7, 1, 16,
13, 6, 4, 7, 11, 16, 10, 1, 6, 7, 13, 16, 4, 1, 11,
10, 7, 16, 6, 1, 13, 10, 4, 11, 8, 9, 15, 2, 14, 3, 5,
12, 9, 2, 8, 3, 15, 12, 14, 5, 2, 3, 9, 12, 8, 5, 15,
14, 3, 12, 2, 5, 9, 14, 8, 15, 12, 5, 3, 14, 2, 15, 9,
8, 5, 14, 12, 15, 3, 8, 2, 9, 14, 15, 5, 8, 12, 9, 3,
2, 15, 8, 14, 9, 5, 2, 12, 3), 128, 8, byrow = T)
} else if (all(williams_D == 8, selection == 93, type == "SR")) {
sequences <- matrix(c(1, 2, 8, 3, 7, 4, 6, 5, 2, 3, 1, 4, 8, 5, 7, 6, 3, 4,
2, 5, 1, 6, 8, 7, 4, 5, 3, 6, 2, 7, 1, 8, 5, 6, 4, 7,
3, 8, 2, 1, 6, 7, 5, 8, 4, 1, 3, 2, 7, 8, 6, 1, 5, 2,
4, 3, 8, 1, 7, 2, 6, 3, 5, 4, 9, 10, 16, 3, 15, 4, 14,
13, 10, 3, 9, 4, 16, 13, 15, 14, 3, 4, 10, 13, 9, 14,
16, 15, 4, 13, 3, 14, 10, 15, 9, 16, 13, 14, 4, 15, 3,
16, 10, 9, 14, 15, 13, 16, 4, 9, 3, 10, 15, 16, 14, 9,
13, 10, 4, 3, 16, 9, 15, 10, 14, 3, 13, 4, 14, 10, 16,
11, 15, 4, 1, 5, 10, 11, 14, 4, 16, 5, 15, 1, 11, 4,
10, 5, 14, 1, 16, 15, 4, 5, 11, 1, 10, 15, 14, 16, 5,
1, 4, 15, 11, 16, 10, 14, 1, 15, 5, 16, 4, 14, 11, 10,
15, 16, 1, 14, 5, 10, 4, 11, 16, 14, 15, 10, 1, 11, 5,
4, 9, 15, 16, 11, 2, 12, 6, 5, 15, 11, 9, 12, 16, 5,
2, 6, 11, 12, 15, 5, 9, 6, 16, 2, 12, 5, 11, 6, 15, 2,
9, 16, 5, 6, 12, 2, 11, 16, 15, 9, 6, 2, 5, 16, 12, 9,
11, 15, 2, 16, 6, 9, 5, 15, 12, 11, 16, 9, 2, 15, 6,
11, 5, 12, 9, 10, 16, 3, 7, 12, 6, 13, 10, 3, 9, 12,
16, 13, 7, 6, 3, 12, 10, 13, 9, 6, 16, 7, 12, 13, 3,
6, 10, 7, 9, 16, 13, 6, 12, 7, 3, 16, 10, 9, 6, 7, 13,
16, 12, 9, 3, 10, 7, 16, 6, 9, 13, 10, 12, 3, 16, 9,
7, 10, 6, 3, 13, 12, 1, 10, 8, 11, 7, 13, 14, 4, 10,
11, 1, 13, 8, 4, 7, 14, 11, 13, 10, 4, 1, 14, 8, 7,
13, 4, 11, 14, 10, 7, 1, 8, 4, 14, 13, 7, 11, 8, 10,
1, 14, 7, 4, 8, 13, 1, 11, 10, 7, 8, 14, 1, 4, 10, 13,
11, 8, 1, 7, 10, 14, 11, 4, 13, 1, 2, 8, 11, 15, 12,
14, 5, 2, 11, 1, 12, 8, 5, 15, 14, 11, 12, 2, 5, 1,
14, 8, 15, 12, 5, 11, 14, 2, 15, 1, 8, 5, 14, 12, 15,
11, 8, 2, 1, 14, 15, 5, 8, 12, 1, 11, 2, 15, 8, 14, 1,
5, 2, 12, 11, 8, 1, 15, 2, 14, 11, 5, 12, 1, 2, 3, 16,
15, 12, 6, 13, 2, 16, 1, 12, 3, 13, 15, 6, 16, 12, 2,
13, 1, 6, 3, 15, 12, 13, 16, 6, 2, 15, 1, 3, 13, 6,
12, 15, 16, 3, 2, 1, 6, 15, 13, 3, 12, 1, 16, 2, 15,
3, 6, 1, 13, 2, 12, 16, 3, 1, 15, 2, 6, 16, 13, 12, 1,
2, 16, 3, 7, 4, 14, 13, 2, 3, 1, 4, 16, 13, 7, 14, 3,
4, 2, 13, 1, 14, 16, 7, 4, 13, 3, 14, 2, 7, 1, 16, 13,
14, 4, 7, 3, 16, 2, 1, 14, 7, 13, 16, 4, 1, 3, 2, 7,
16, 14, 1, 13, 2, 4, 3, 16, 1, 7, 2, 14, 3, 13, 4, 9,
2, 8, 3, 15, 4, 14, 5, 2, 3, 9, 4, 8, 5, 15, 14, 3, 4,
2, 5, 9, 14, 8, 15, 4, 5, 3, 14, 2, 15, 9, 8, 5, 14,
4, 15, 3, 8, 2, 9, 14, 15, 5, 8, 4, 9, 3, 2, 15, 8,
14, 9, 5, 2, 4, 3, 8, 9, 15, 2, 14, 3, 5, 4, 5, 10, 4,
15, 3, 16, 6, 1, 10, 15, 5, 16, 4, 1, 3, 6, 15, 16,
10, 1, 5, 6, 4, 3, 16, 1, 15, 6, 10, 3, 5, 4, 1, 6,
16, 3, 15, 4, 10, 5, 6, 3, 1, 4, 16, 5, 15, 10, 3, 4,
6, 5, 1, 10, 16, 15, 4, 5, 3, 10, 6, 15, 1, 16, 5, 6,
4, 11, 7, 16, 2, 9, 6, 11, 5, 16, 4, 9, 7, 2, 11, 16,
6, 9, 5, 2, 4, 7, 16, 9, 11, 2, 6, 7, 5, 4, 9, 2, 16,
7, 11, 4, 6, 5, 2, 7, 9, 4, 16, 5, 11, 6, 7, 4, 2, 5,
9, 6, 16, 11, 4, 5, 7, 6, 2, 11, 9, 16, 5, 6, 12, 7,
3, 8, 10, 1, 6, 7, 5, 8, 12, 1, 3, 10, 7, 8, 6, 1, 5,
10, 12, 3, 8, 1, 7, 10, 6, 3, 5, 12, 1, 10, 8, 3, 7,
12, 6, 5, 10, 3, 1, 12, 8, 5, 7, 6, 3, 12, 10, 5, 1,
6, 8, 7, 12, 5, 3, 6, 10, 7, 1, 8, 9, 6, 4, 7, 11, 8,
2, 13, 6, 7, 9, 8, 4, 13, 11, 2, 7, 8, 6, 13, 9, 2, 4,
11, 8, 13, 7, 2, 6, 11, 9, 4, 13, 2, 8, 11, 7, 4, 6,
9, 2, 11, 13, 4, 8, 9, 7, 6, 11, 4, 2, 9, 13, 6, 8, 7,
4, 9, 11, 6, 2, 7, 13, 8, 5, 14, 8, 7, 3, 12, 10, 9,
14, 7, 5, 12, 8, 9, 3, 10, 7, 12, 14, 9, 5, 10, 8, 3,
12, 9, 7, 10, 14, 3, 5, 8, 9, 10, 12, 3, 7, 8, 14, 5,
10, 3, 9, 8, 12, 5, 7, 14, 3, 8, 10, 5, 9, 14, 12, 7,
8, 5, 3, 14, 10, 7, 9, 12, 13, 6, 4, 15, 11, 8, 10, 9,
6, 15, 13, 8, 4, 9, 11, 10, 15, 8, 6, 9, 13, 10, 4,
11, 8, 9, 15, 10, 6, 11, 13, 4, 9, 10, 8, 11, 15, 4,
6, 13, 10, 11, 9, 4, 8, 13, 15, 6, 11, 4, 10, 13, 9,
6, 8, 15, 4, 13, 11, 6, 10, 15, 9, 8, 5, 14, 12, 7,
11, 16, 10, 9, 14, 7, 5, 16, 12, 9, 11, 10, 7, 16, 14,
9, 5, 10, 12, 11, 16, 9, 7, 10, 14, 11, 5, 12, 9, 10,
16, 11, 7, 12, 14, 5, 10, 11, 9, 12, 16, 5, 7, 14, 11,
12, 10, 5, 9, 14, 16, 7, 12, 5, 11, 14, 10, 7, 9, 16,
13, 6, 12, 15, 11, 8, 10, 1, 6, 15, 13, 8, 12, 1, 11,
10, 15, 8, 6, 1, 13, 10, 12, 11, 8, 1, 15, 10, 6, 11,
13, 12, 1, 10, 8, 11, 15, 12, 6, 13, 10, 11, 1, 12, 8,
13, 15, 6, 11, 12, 10, 13, 1, 6, 8, 15, 12, 13, 11, 6,
10, 15, 1, 8, 13, 14, 12, 7, 11, 16, 2, 1, 14, 7, 13,
16, 12, 1, 11, 2, 7, 16, 14, 1, 13, 2, 12, 11, 16, 1,
7, 2, 14, 11, 13, 12, 1, 2, 16, 11, 7, 12, 14, 13, 2,
11, 1, 12, 16, 13, 7, 14, 11, 12, 2, 13, 1, 14, 16, 7,
12, 13, 11, 14, 2, 7, 1, 16, 13, 14, 12, 15, 3, 8, 2,
9, 14, 15, 13, 8, 12, 9, 3, 2, 15, 8, 14, 9, 13, 2,
12, 3, 8, 9, 15, 2, 14, 3, 13, 12, 9, 2, 8, 3, 15, 12,
14, 13, 2, 3, 9, 12, 8, 13, 15, 14, 3, 12, 2, 13, 9,
14, 8, 15, 12, 13, 3, 14, 2, 15, 9, 8), 160, 8,
byrow = T)
} else if (all(williams_D == 8, selection == 94, type == "SR")) {
sequences <- matrix(c(1, 2, 8, 3, 7, 4, 6, 5, 2, 3, 1, 4, 8, 5, 7, 6, 3, 4,
2, 5, 1, 6, 8, 7, 4, 5, 3, 6, 2, 7, 1, 8, 5, 6, 4, 7,
3, 8, 2, 1, 6, 7, 5, 8, 4, 1, 3, 2, 7, 8, 6, 1, 5, 2,
4, 3, 8, 1, 7, 2, 6, 3, 5, 4, 9, 10, 16, 11, 15, 12,
14, 13, 10, 11, 9, 12, 16, 13, 15, 14, 11, 12, 10, 13,
9, 14, 16, 15, 12, 13, 11, 14, 10, 15, 9, 16, 13, 14,
12, 15, 11, 16, 10, 9, 14, 15, 13, 16, 12, 9, 11, 10,
15, 16, 14, 9, 13, 10, 12, 11, 16, 9, 15, 10, 14, 11,
13, 12, 17, 18, 24, 19, 23, 20, 22, 21, 18, 19, 17,
20, 24, 21, 23, 22, 19, 20, 18, 21, 17, 22, 24, 23,
20, 21, 19, 22, 18, 23, 17, 24, 21, 22, 20, 23, 19,
24, 18, 17, 22, 23, 21, 24, 20, 17, 19, 18, 23, 24,
22, 17, 21, 18, 20, 19, 24, 17, 23, 18, 22, 19, 21,
20, 1, 2, 24, 3, 23, 12, 14, 13, 2, 3, 1, 12, 24, 13,
23, 14, 3, 12, 2, 13, 1, 14, 24, 23, 12, 13, 3, 14, 2,
23, 1, 24, 13, 14, 12, 23, 3, 24, 2, 1, 14, 23, 13,
24, 12, 1, 3, 2, 23, 24, 14, 1, 13, 2, 12, 3, 24, 1,
23, 2, 14, 3, 13, 12, 9, 10, 8, 11, 7, 20, 22, 21, 10,
11, 9, 20, 8, 21, 7, 22, 11, 20, 10, 21, 9, 22, 8, 7,
20, 21, 11, 22, 10, 7, 9, 8, 21, 22, 20, 7, 11, 8, 10,
9, 22, 7, 21, 8, 20, 9, 11, 10, 7, 8, 22, 9, 21, 10,
20, 11, 8, 9, 7, 10, 22, 11, 21, 20, 17, 18, 16, 19,
15, 4, 6, 5, 18, 19, 17, 4, 16, 5, 15, 6, 19, 4, 18,
5, 17, 6, 16, 15, 4, 5, 19, 6, 18, 15, 17, 16, 5, 6,
4, 15, 19, 16, 18, 17, 6, 15, 5, 16, 4, 17, 19, 18,
15, 16, 6, 17, 5, 18, 4, 19, 16, 17, 15, 18, 6, 19, 5,
4, 1, 2, 16, 3, 15, 20, 22, 21, 2, 3, 1, 20, 16, 21,
15, 22, 3, 20, 2, 21, 1, 22, 16, 15, 20, 21, 3, 22, 2,
15, 1, 16, 21, 22, 20, 15, 3, 16, 2, 1, 22, 15, 21,
16, 20, 1, 3, 2, 15, 16, 22, 1, 21, 2, 20, 3, 16, 1,
15, 2, 22, 3, 21, 20, 9, 10, 24, 11, 23, 4, 6, 5, 10,
11, 9, 4, 24, 5, 23, 6, 11, 4, 10, 5, 9, 6, 24, 23, 4,
5, 11, 6, 10, 23, 9, 24, 5, 6, 4, 23, 11, 24, 10, 9,
6, 23, 5, 24, 4, 9, 11, 10, 23, 24, 6, 9, 5, 10, 4,
11, 24, 9, 23, 10, 6, 11, 5, 4, 17, 18, 8, 19, 7, 12,
14, 13, 18, 19, 17, 12, 8, 13, 7, 14, 19, 12, 18, 13,
17, 14, 8, 7, 12, 13, 19, 14, 18, 7, 17, 8, 13, 14,
12, 7, 19, 8, 18, 17, 14, 7, 13, 8, 12, 17, 19, 18, 7,
8, 14, 17, 13, 18, 12, 19, 8, 17, 7, 18, 14, 19, 13,
12, 1, 10, 16, 19, 7, 4, 22, 13, 10, 19, 1, 4, 16, 13,
7, 22, 19, 4, 10, 13, 1, 22, 16, 7, 4, 13, 19, 22, 10,
7, 1, 16, 13, 22, 4, 7, 19, 16, 10, 1, 22, 7, 13, 16,
4, 1, 19, 10, 7, 16, 22, 1, 13, 10, 4, 19, 16, 1, 7,
10, 22, 19, 13, 4, 9, 18, 24, 3, 15, 12, 6, 21, 18, 3,
9, 12, 24, 21, 15, 6, 3, 12, 18, 21, 9, 6, 24, 15, 12,
21, 3, 6, 18, 15, 9, 24, 21, 6, 12, 15, 3, 24, 18, 9,
6, 15, 21, 24, 12, 9, 3, 18, 15, 24, 6, 9, 21, 18, 12,
3, 24, 9, 15, 18, 6, 3, 21, 12, 17, 2, 8, 11, 23, 20,
14, 5, 2, 11, 17, 20, 8, 5, 23, 14, 11, 20, 2, 5, 17,
14, 8, 23, 20, 5, 11, 14, 2, 23, 17, 8, 5, 14, 20, 23,
11, 8, 2, 17, 14, 23, 5, 8, 20, 17, 11, 2, 23, 8, 14,
17, 5, 2, 20, 11, 8, 17, 23, 2, 14, 11, 5, 20, 1, 10,
8, 19, 23, 12, 6, 21, 10, 19, 1, 12, 8, 21, 23, 6, 19,
12, 10, 21, 1, 6, 8, 23, 12, 21, 19, 6, 10, 23, 1, 8,
21, 6, 12, 23, 19, 8, 10, 1, 6, 23, 21, 8, 12, 1, 19,
10, 23, 8, 6, 1, 21, 10, 12, 19, 8, 1, 23, 10, 6, 19,
21, 12, 9, 18, 16, 3, 7, 20, 14, 5, 18, 3, 9, 20, 16,
5, 7, 14, 3, 20, 18, 5, 9, 14, 16, 7, 20, 5, 3, 14,
18, 7, 9, 16, 5, 14, 20, 7, 3, 16, 18, 9, 14, 7, 5,
16, 20, 9, 3, 18, 7, 16, 14, 9, 5, 18, 20, 3, 16, 9,
7, 18, 14, 3, 5, 20, 17, 2, 24, 11, 15, 4, 22, 13, 2,
11, 17, 4, 24, 13, 15, 22, 11, 4, 2, 13, 17, 22, 24,
15, 4, 13, 11, 22, 2, 15, 17, 24, 13, 22, 4, 15, 11,
24, 2, 17, 22, 15, 13, 24, 4, 17, 11, 2, 15, 24, 22,
17, 13, 2, 4, 11, 24, 17, 15, 2, 22, 11, 13, 4, 1, 10,
24, 19, 15, 20, 14, 5, 10, 19, 1, 20, 24, 5, 15, 14,
19, 20, 10, 5, 1, 14, 24, 15, 20, 5, 19, 14, 10, 15,
1, 24, 5, 14, 20, 15, 19, 24, 10, 1, 14, 15, 5, 24,
20, 1, 19, 10, 15, 24, 14, 1, 5, 10, 20, 19, 24, 1,
15, 10, 14, 19, 5, 20, 9, 18, 8, 3, 23, 4, 22, 13, 18,
3, 9, 4, 8, 13, 23, 22, 3, 4, 18, 13, 9, 22, 8, 23, 4,
13, 3, 22, 18, 23, 9, 8, 13, 22, 4, 23, 3, 8, 18, 9,
22, 23, 13, 8, 4, 9, 3, 18, 23, 8, 22, 9, 13, 18, 4,
3, 8, 9, 23, 18, 22, 3, 13, 4, 17, 2, 16, 11, 7, 12,
6, 21, 2, 11, 17, 12, 16, 21, 7, 6, 11, 12, 2, 21, 17,
6, 16, 7, 12, 21, 11, 6, 2, 7, 17, 16, 21, 6, 12, 7,
11, 16, 2, 17, 6, 7, 21, 16, 12, 17, 11, 2, 7, 16, 6,
17, 21, 2, 12, 11, 16, 17, 7, 2, 6, 11, 21, 12, 1, 18,
24, 11, 7, 4, 14, 21, 18, 11, 1, 4, 24, 21, 7, 14, 11,
4, 18, 21, 1, 14, 24, 7, 4, 21, 11, 14, 18, 7, 1, 24,
21, 14, 4, 7, 11, 24, 18, 1, 14, 7, 21, 24, 4, 1, 11,
18, 7, 24, 14, 1, 21, 18, 4, 11, 24, 1, 7, 18, 14, 11,
21, 4, 9, 2, 8, 19, 15, 12, 22, 5, 2, 19, 9, 12, 8, 5,
15, 22, 19, 12, 2, 5, 9, 22, 8, 15, 12, 5, 19, 22, 2,
15, 9, 8, 5, 22, 12, 15, 19, 8, 2, 9, 22, 15, 5, 8,
12, 9, 19, 2, 15, 8, 22, 9, 5, 2, 12, 19, 8, 9, 15, 2,
22, 19, 5, 12, 17, 10, 16, 3, 23, 20, 6, 13, 10, 3,
17, 20, 16, 13, 23, 6, 3, 20, 10, 13, 17, 6, 16, 23,
20, 13, 3, 6, 10, 23, 17, 16, 13, 6, 20, 23, 3, 16,
10, 17, 6, 23, 13, 16, 20, 17, 3, 10, 23, 16, 6, 17,
13, 10, 20, 3, 16, 17, 23, 10, 6, 3, 13, 20, 1, 18,
16, 11, 23, 12, 22, 5, 18, 11, 1, 12, 16, 5, 23, 22,
11, 12, 18, 5, 1, 22, 16, 23, 12, 5, 11, 22, 18, 23,
1, 16, 5, 22, 12, 23, 11, 16, 18, 1, 22, 23, 5, 16,
12, 1, 11, 18, 23, 16, 22, 1, 5, 18, 12, 11, 16, 1,
23, 18, 22, 11, 5, 12, 9, 2, 24, 19, 7, 20, 6, 13, 2,
19, 9, 20, 24, 13, 7, 6, 19, 20, 2, 13, 9, 6, 24, 7,
20, 13, 19, 6, 2, 7, 9, 24, 13, 6, 20, 7, 19, 24, 2,
9, 6, 7, 13, 24, 20, 9, 19, 2, 7, 24, 6, 9, 13, 2, 20,
19, 24, 9, 7, 2, 6, 19, 13, 20, 17, 10, 8, 3, 15, 4,
14, 21, 10, 3, 17, 4, 8, 21, 15, 14, 3, 4, 10, 21, 17,
14, 8, 15, 4, 21, 3, 14, 10, 15, 17, 8, 21, 14, 4, 15,
3, 8, 10, 17, 14, 15, 21, 8, 4, 17, 3, 10, 15, 8, 14,
17, 21, 10, 4, 3, 8, 17, 15, 10, 14, 3, 21, 4, 1, 18,
8, 11, 15, 20, 6, 13, 18, 11, 1, 20, 8, 13, 15, 6, 11,
20, 18, 13, 1, 6, 8, 15, 20, 13, 11, 6, 18, 15, 1, 8,
13, 6, 20, 15, 11, 8, 18, 1, 6, 15, 13, 8, 20, 1, 11,
18, 15, 8, 6, 1, 13, 18, 20, 11, 8, 1, 15, 18, 6, 11,
13, 20, 9, 2, 16, 19, 23, 4, 14, 21, 2, 19, 9, 4, 16,
21, 23, 14, 19, 4, 2, 21, 9, 14, 16, 23, 4, 21, 19,
14, 2, 23, 9, 16, 21, 14, 4, 23, 19, 16, 2, 9, 14, 23,
21, 16, 4, 9, 19, 2, 23, 16, 14, 9, 21, 2, 4, 19, 16,
9, 23, 2, 14, 19, 21, 4, 17, 10, 24, 3, 7, 12, 22, 5,
10, 3, 17, 12, 24, 5, 7, 22, 3, 12, 10, 5, 17, 22, 24,
7, 12, 5, 3, 22, 10, 7, 17, 24, 5, 22, 12, 7, 3, 24,
10, 17, 22, 7, 5, 24, 12, 17, 3, 10, 7, 24, 22, 17, 5,
10, 12, 3, 24, 17, 7, 10, 22, 3, 5, 12), 216, 8,
byrow = T)
} else if (all(williams_D == 9, selection == 193, type == "R")) {
sequences <- matrix(c(1, 2, 12, 5, 9, 8, 6, 11, 3, 2, 5, 1, 8, 12, 11, 9, 3,
6, 5, 8, 2, 11, 1, 3, 12, 6, 9, 8, 11, 5, 3, 2, 6, 1,
9, 12, 11, 3, 8, 6, 5, 9, 2, 12, 1, 3, 6, 11, 9, 8,
12, 5, 1, 2, 6, 9, 3, 12, 11, 1, 8, 2, 5, 9, 12, 6, 1,
3, 2, 11, 5, 8, 12, 1, 9, 2, 6, 5, 3, 8, 11, 3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 8, 5,
7, 4, 11, 1, 2, 10, 5, 9, 8, 10, 11, 9, 2, 6, 5, 3, 8,
12, 11, 2, 10, 5, 9, 8, 6, 12, 3, 2, 5, 11, 8, 10, 12,
9, 3, 6, 5, 8, 2, 12, 11, 3, 10, 6, 9, 8, 12, 5, 3, 2,
6, 11, 9, 10, 12, 3, 8, 6, 5, 9, 2, 10, 11, 3, 6, 12,
9, 8, 10, 5, 11, 2, 6, 9, 3, 10, 12, 11, 8, 2, 5, 9,
10, 6, 11, 3, 2, 12, 5, 8, 12, 8, 3, 5, 6, 2, 9, 11,
10, 3, 12, 6, 8, 9, 5, 10, 2, 11, 6, 3, 9, 12, 10, 8,
11, 5, 2, 9, 6, 10, 3, 11, 12, 2, 8, 5, 10, 9, 11, 6,
2, 3, 5, 12, 8, 11, 10, 2, 9, 5, 6, 8, 3, 12, 2, 11,
5, 10, 8, 9, 12, 6, 3, 5, 2, 8, 11, 12, 10, 3, 9, 6,
8, 5, 12, 2, 3, 11, 6, 10, 9, 11, 12, 10, 3, 7, 6, 4,
9, 1, 12, 3, 11, 6, 10, 9, 7, 1, 4, 3, 6, 12, 9, 11,
1, 10, 4, 7, 6, 9, 3, 1, 12, 4, 11, 7, 10, 9, 1, 6, 4,
3, 7, 12, 10, 11, 1, 4, 9, 7, 6, 10, 3, 11, 12, 4, 7,
1, 10, 9, 11, 6, 12, 3, 7, 10, 4, 11, 1, 12, 9, 3, 6,
10, 11, 7, 12, 4, 3, 1, 6, 9, 1, 9, 4, 6, 7, 3, 10,
12, 11, 4, 1, 7, 9, 10, 6, 11, 3, 12, 7, 4, 10, 1, 11,
9, 12, 6, 3, 10, 7, 11, 4, 12, 1, 3, 9, 6, 11, 10, 12,
7, 3, 4, 6, 1, 9, 12, 11, 3, 10, 6, 7, 9, 4, 1, 3, 12,
6, 11, 9, 10, 1, 7, 4, 6, 3, 9, 12, 1, 11, 4, 10, 7,
9, 6, 1, 3, 4, 12, 7, 11, 10, 12, 1, 11, 4, 8, 7, 5,
10, 2, 1, 4, 12, 7, 11, 10, 8, 2, 5, 4, 7, 1, 10, 12,
2, 11, 5, 8, 7, 10, 4, 2, 1, 5, 12, 8, 11, 10, 2, 7,
5, 4, 8, 1, 11, 12, 2, 5, 10, 8, 7, 11, 4, 12, 1, 5,
8, 2, 11, 10, 12, 7, 1, 4, 8, 11, 5, 12, 2, 1, 10, 4,
7, 11, 12, 8, 1, 5, 4, 2, 7, 10, 2, 10, 5, 7, 8, 4,
11, 1, 12, 5, 2, 8, 10, 11, 7, 12, 4, 1, 8, 5, 11, 2,
12, 10, 1, 7, 4, 11, 8, 12, 5, 1, 2, 4, 10, 7, 12, 11,
1, 8, 4, 5, 7, 2, 10, 1, 12, 4, 11, 7, 8, 10, 5, 2, 4,
1, 7, 12, 10, 11, 2, 8, 5, 7, 4, 10, 1, 2, 12, 5, 11,
8, 10, 7, 2, 4, 5, 1, 8, 12, 11), 216, 9, byrow = T)
} else if (all(williams_D == 9, selection == 82, type == "S")) {
sequences <- matrix(c(1, 5, 11, 9, 7, 2, 3, 6, 10, 5, 9, 1, 2, 11, 6, 7, 10,
3, 9, 2, 5, 6, 1, 10, 11, 3, 7, 2, 6, 9, 10, 5, 3, 1,
7, 11, 6, 10, 2, 3, 9, 7, 5, 11, 1, 10, 3, 6, 7, 2,
11, 9, 1, 5, 3, 7, 10, 11, 6, 1, 2, 5, 9, 7, 11, 3, 1,
10, 5, 6, 9, 2, 11, 1, 7, 5, 3, 9, 10, 2, 6, 10, 6, 3,
2, 7, 9, 11, 5, 1, 3, 10, 7, 6, 11, 2, 1, 9, 5, 7, 3,
11, 10, 1, 6, 5, 2, 9, 11, 7, 1, 3, 5, 10, 9, 6, 2, 1,
11, 5, 7, 9, 3, 2, 10, 6, 5, 1, 9, 11, 2, 7, 6, 3, 10,
9, 5, 2, 1, 6, 11, 10, 7, 3, 2, 9, 6, 5, 10, 1, 3, 11,
7, 6, 2, 10, 9, 3, 5, 7, 1, 11, 2, 6, 12, 10, 8, 3, 4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 10, 2, 6, 1, 5,
12, 9, 8, 2, 4, 6, 10, 5, 9, 1, 2, 12, 6, 8, 10, 4, 9,
2, 5, 6, 1, 10, 12, 4, 8, 2, 6, 9, 10, 5, 4, 1, 8, 12,
6, 10, 2, 4, 9, 8, 5, 12, 1, 10, 4, 6, 8, 2, 12, 9, 1,
5, 9, 5, 2, 1, 6, 12, 10, 8, 4, 2, 9, 6, 5, 10, 1, 4,
12, 8, 6, 2, 10, 9, 4, 5, 8, 1, 12, 10, 6, 4, 2, 8, 9,
12, 5, 1, 4, 10, 8, 6, 12, 2, 1, 9, 5, 8, 4, 12, 10,
1, 6, 5, 2, 9, 12, 8, 1, 4, 5, 10, 9, 6, 2, 1, 12, 5,
8, 9, 4, 2, 10, 6, 5, 1, 9, 12, 2, 8, 6, 4, 10), 72,
9, byrow = T)
} else if (all(williams_D == 9, selection == 85, type == "S")) {
sequences <- matrix(c(1, 6, 13, 11, 8, 2, 3, 7, 12, 6, 11, 1, 2, 13, 7, 8,
12, 3, 11, 2, 6, 7, 1, 12, 13, 3, 8, 2, 7, 11, 12, 6,
3, 1, 8, 13, 7, 12, 2, 3, 11, 8, 6, 13, 1, 12, 3, 7,
8, 2, 13, 11, 1, 6, 3, 8, 12, 13, 7, 1, 2, 6, 11, 8,
13, 3, 1, 12, 6, 7, 11, 2, 13, 1, 8, 6, 3, 11, 12, 2,
7, 12, 7, 3, 2, 8, 11, 13, 6, 1, 3, 12, 8, 7, 13, 2,
1, 11, 6, 8, 3, 13, 12, 1, 7, 6, 2, 11, 13, 8, 1, 3,
6, 12, 11, 7, 2, 1, 13, 6, 8, 11, 3, 2, 12, 7, 6, 1,
11, 13, 2, 8, 7, 3, 12, 11, 6, 2, 1, 7, 13, 12, 8, 3,
2, 11, 7, 6, 12, 1, 3, 13, 8, 7, 2, 12, 11, 3, 6, 8,
1, 13, 2, 7, 14, 12, 9, 3, 4, 8, 13, 7, 12, 2, 3, 14,
8, 9, 13, 4, 12, 3, 7, 8, 2, 13, 14, 4, 9, 3, 8, 12,
13, 7, 4, 2, 9, 14, 8, 13, 3, 4, 12, 9, 7, 14, 2, 13,
4, 8, 9, 3, 14, 12, 2, 7, 4, 9, 13, 14, 8, 2, 3, 7,
12, 9, 14, 4, 2, 13, 7, 8, 12, 3, 14, 2, 9, 7, 4, 12,
13, 3, 8, 13, 8, 4, 3, 9, 12, 14, 7, 2, 4, 13, 9, 8,
14, 3, 2, 12, 7, 9, 4, 14, 13, 2, 8, 7, 3, 12, 14, 9,
2, 4, 7, 13, 12, 8, 3, 2, 14, 7, 9, 12, 4, 3, 13, 8,
7, 2, 12, 14, 3, 9, 8, 4, 13, 12, 7, 3, 2, 8, 14, 13,
9, 4, 3, 12, 8, 7, 13, 2, 4, 14, 9, 8, 3, 13, 12, 4,
7, 9, 2, 14, 3, 8, 15, 13, 10, 4, 5, 9, 14, 8, 13, 3,
4, 15, 9, 10, 14, 5, 13, 4, 8, 9, 3, 14, 15, 5, 10, 4,
9, 13, 14, 8, 5, 3, 10, 15, 9, 14, 4, 5, 13, 10, 8,
15, 3, 14, 5, 9, 10, 4, 15, 13, 3, 8, 5, 10, 14, 15,
9, 3, 4, 8, 13, 10, 15, 5, 3, 14, 8, 9, 13, 4, 15, 3,
10, 8, 5, 13, 14, 4, 9, 14, 9, 5, 4, 10, 13, 15, 8, 3,
5, 14, 10, 9, 15, 4, 3, 13, 8, 10, 5, 15, 14, 3, 9, 8,
4, 13, 15, 10, 3, 5, 8, 14, 13, 9, 4, 3, 15, 8, 10,
13, 5, 4, 14, 9, 8, 3, 13, 15, 4, 10, 9, 5, 14, 13, 8,
4, 3, 9, 15, 14, 10, 5, 4, 13, 9, 8, 14, 3, 5, 15, 10,
9, 4, 14, 13, 5, 8, 10, 3, 15, 4, 9, 11, 14, 6, 5, 1,
10, 15, 9, 14, 4, 5, 11, 10, 6, 15, 1, 14, 5, 9, 10,
4, 15, 11, 1, 6, 5, 10, 14, 15, 9, 1, 4, 6, 11, 10,
15, 5, 1, 14, 6, 9, 11, 4, 15, 1, 10, 6, 5, 11, 14, 4,
9, 1, 6, 15, 11, 10, 4, 5, 9, 14, 6, 11, 1, 4, 15, 9,
10, 14, 5, 11, 4, 6, 9, 1, 14, 15, 5, 10, 15, 10, 1,
5, 6, 14, 11, 9, 4, 1, 15, 6, 10, 11, 5, 4, 14, 9, 6,
1, 11, 15, 4, 10, 9, 5, 14, 11, 6, 4, 1, 9, 15, 14,
10, 5, 4, 11, 9, 6, 14, 1, 5, 15, 10, 9, 4, 14, 11, 5,
6, 10, 1, 15, 14, 9, 5, 4, 10, 11, 15, 6, 1, 5, 14,
10, 9, 15, 4, 1, 11, 6, 10, 5, 15, 14, 1, 9, 6, 4, 11,
5, 10, 12, 15, 7, 1, 2, 6, 11, 10, 15, 5, 1, 12, 6, 7,
11, 2, 15, 1, 10, 6, 5, 11, 12, 2, 7, 1, 6, 15, 11,
10, 2, 5, 7, 12, 6, 11, 1, 2, 15, 7, 10, 12, 5, 11, 2,
6, 7, 1, 12, 15, 5, 10, 2, 7, 11, 12, 6, 5, 1, 10, 15,
7, 12, 2, 5, 11, 10, 6, 15, 1, 12, 5, 7, 10, 2, 15,
11, 1, 6, 11, 6, 2, 1, 7, 15, 12, 10, 5, 2, 11, 7, 6,
12, 1, 5, 15, 10, 7, 2, 12, 11, 5, 6, 10, 1, 15, 12,
7, 5, 2, 10, 11, 15, 6, 1, 5, 12, 10, 7, 15, 2, 1, 11,
6, 10, 5, 15, 12, 1, 7, 6, 2, 11, 15, 10, 1, 5, 6, 12,
11, 7, 2, 1, 15, 6, 10, 11, 5, 2, 12, 7, 6, 1, 11, 15,
2, 10, 7, 5, 12, 1, 6, 14, 11, 9, 3, 4, 8, 13, 6, 11,
1, 3, 14, 8, 9, 13, 4, 11, 3, 6, 8, 1, 13, 14, 4, 9,
3, 8, 11, 13, 6, 4, 1, 9, 14, 8, 13, 3, 4, 11, 9, 6,
14, 1, 13, 4, 8, 9, 3, 14, 11, 1, 6, 4, 9, 13, 14, 8,
1, 3, 6, 11, 9, 14, 4, 1, 13, 6, 8, 11, 3, 14, 1, 9,
6, 4, 11, 13, 3, 8, 13, 8, 4, 3, 9, 11, 14, 6, 1, 4,
13, 9, 8, 14, 3, 1, 11, 6, 9, 4, 14, 13, 1, 8, 6, 3,
11, 14, 9, 1, 4, 6, 13, 11, 8, 3, 1, 14, 6, 9, 11, 4,
3, 13, 8, 6, 1, 11, 14, 3, 9, 8, 4, 13, 11, 6, 3, 1,
8, 14, 13, 9, 4, 3, 11, 8, 6, 13, 1, 4, 14, 9, 8, 3,
13, 11, 4, 6, 9, 1, 14, 2, 7, 15, 12, 10, 4, 5, 9, 14,
7, 12, 2, 4, 15, 9, 10, 14, 5, 12, 4, 7, 9, 2, 14, 15,
5, 10, 4, 9, 12, 14, 7, 5, 2, 10, 15, 9, 14, 4, 5, 12,
10, 7, 15, 2, 14, 5, 9, 10, 4, 15, 12, 2, 7, 5, 10,
14, 15, 9, 2, 4, 7, 12, 10, 15, 5, 2, 14, 7, 9, 12, 4,
15, 2, 10, 7, 5, 12, 14, 4, 9, 14, 9, 5, 4, 10, 12,
15, 7, 2, 5, 14, 10, 9, 15, 4, 2, 12, 7, 10, 5, 15,
14, 2, 9, 7, 4, 12, 15, 10, 2, 5, 7, 14, 12, 9, 4, 2,
15, 7, 10, 12, 5, 4, 14, 9, 7, 2, 12, 15, 4, 10, 9, 5,
14, 12, 7, 4, 2, 9, 15, 14, 10, 5, 4, 12, 9, 7, 14, 2,
5, 15, 10, 9, 4, 14, 12, 5, 7, 10, 2, 15, 3, 8, 11,
13, 6, 5, 1, 10, 15, 8, 13, 3, 5, 11, 10, 6, 15, 1,
13, 5, 8, 10, 3, 15, 11, 1, 6, 5, 10, 13, 15, 8, 1, 3,
6, 11, 10, 15, 5, 1, 13, 6, 8, 11, 3, 15, 1, 10, 6, 5,
11, 13, 3, 8, 1, 6, 15, 11, 10, 3, 5, 8, 13, 6, 11, 1,
3, 15, 8, 10, 13, 5, 11, 3, 6, 8, 1, 13, 15, 5, 10,
15, 10, 1, 5, 6, 13, 11, 8, 3, 1, 15, 6, 10, 11, 5, 3,
13, 8, 6, 1, 11, 15, 3, 10, 8, 5, 13, 11, 6, 3, 1, 8,
15, 13, 10, 5, 3, 11, 8, 6, 13, 1, 5, 15, 10, 8, 3,
13, 11, 5, 6, 10, 1, 15, 13, 8, 5, 3, 10, 11, 15, 6,
1, 5, 13, 10, 8, 15, 3, 1, 11, 6, 10, 5, 15, 13, 1, 8,
6, 3, 11, 4, 9, 12, 14, 7, 1, 2, 6, 11, 9, 14, 4, 1,
12, 6, 7, 11, 2, 14, 1, 9, 6, 4, 11, 12, 2, 7, 1, 6,
14, 11, 9, 2, 4, 7, 12, 6, 11, 1, 2, 14, 7, 9, 12, 4,
11, 2, 6, 7, 1, 12, 14, 4, 9, 2, 7, 11, 12, 6, 4, 1,
9, 14, 7, 12, 2, 4, 11, 9, 6, 14, 1, 12, 4, 7, 9, 2,
14, 11, 1, 6, 11, 6, 2, 1, 7, 14, 12, 9, 4, 2, 11, 7,
6, 12, 1, 4, 14, 9, 7, 2, 12, 11, 4, 6, 9, 1, 14, 12,
7, 4, 2, 9, 11, 14, 6, 1, 4, 12, 9, 7, 14, 2, 1, 11,
6, 9, 4, 14, 12, 1, 7, 6, 2, 11, 14, 9, 1, 4, 6, 12,
11, 7, 2, 1, 14, 6, 9, 11, 4, 2, 12, 7, 6, 1, 11, 14,
2, 9, 7, 4, 12, 5, 10, 13, 15, 8, 2, 3, 7, 12, 10, 15,
5, 2, 13, 7, 8, 12, 3, 15, 2, 10, 7, 5, 12, 13, 3, 8,
2, 7, 15, 12, 10, 3, 5, 8, 13, 7, 12, 2, 3, 15, 8, 10,
13, 5, 12, 3, 7, 8, 2, 13, 15, 5, 10, 3, 8, 12, 13, 7,
5, 2, 10, 15, 8, 13, 3, 5, 12, 10, 7, 15, 2, 13, 5, 8,
10, 3, 15, 12, 2, 7, 12, 7, 3, 2, 8, 15, 13, 10, 5, 3,
12, 8, 7, 13, 2, 5, 15, 10, 8, 3, 13, 12, 5, 7, 10, 2,
15, 13, 8, 5, 3, 10, 12, 15, 7, 2, 5, 13, 10, 8, 15,
3, 2, 12, 7, 10, 5, 15, 13, 2, 8, 7, 3, 12, 15, 10, 2,
5, 7, 13, 12, 8, 3, 2, 15, 7, 10, 12, 5, 3, 13, 8, 7,
2, 12, 15, 3, 10, 8, 5, 13), 180, 9, byrow = T)
} else if (all(williams_D == 9, selection == 86, type == "S")) {
sequences <- matrix(c(1, 7, 15, 13, 9, 2, 3, 8, 14, 7, 13, 1, 2, 15, 8, 9,
14, 3, 13, 2, 7, 8, 1, 14, 15, 3, 9, 2, 8, 13, 14, 7,
3, 1, 9, 15, 8, 14, 2, 3, 13, 9, 7, 15, 1, 14, 3, 8,
9, 2, 15, 13, 1, 7, 3, 9, 14, 15, 8, 1, 2, 7, 13, 9,
15, 3, 1, 14, 7, 8, 13, 2, 15, 1, 9, 7, 3, 13, 14, 2,
8, 14, 8, 3, 2, 9, 13, 15, 7, 1, 3, 14, 9, 8, 15, 2,
1, 13, 7, 9, 3, 15, 14, 1, 8, 7, 2, 13, 15, 9, 1, 3,
7, 14, 13, 8, 2, 1, 15, 7, 9, 13, 3, 2, 14, 8, 7, 1,
13, 15, 2, 9, 8, 3, 14, 13, 7, 2, 1, 8, 15, 14, 9, 3,
2, 13, 8, 7, 14, 1, 3, 15, 9, 8, 2, 14, 13, 3, 7, 9,
1, 15, 1, 7, 16, 13, 10, 2, 4, 8, 14, 7, 13, 1, 2, 16,
8, 10, 14, 4, 13, 2, 7, 8, 1, 14, 16, 4, 10, 2, 8, 13,
14, 7, 4, 1, 10, 16, 8, 14, 2, 4, 13, 10, 7, 16, 1,
14, 4, 8, 10, 2, 16, 13, 1, 7, 4, 10, 14, 16, 8, 1, 2,
7, 13, 10, 16, 4, 1, 14, 7, 8, 13, 2, 16, 1, 10, 7, 4,
13, 14, 2, 8, 14, 8, 4, 2, 10, 13, 16, 7, 1, 4, 14,
10, 8, 16, 2, 1, 13, 7, 10, 4, 16, 14, 1, 8, 7, 2, 13,
16, 10, 1, 4, 7, 14, 13, 8, 2, 1, 16, 7, 10, 13, 4, 2,
14, 8, 7, 1, 13, 16, 2, 10, 8, 4, 14, 13, 7, 2, 1, 8,
16, 14, 10, 4, 2, 13, 8, 7, 14, 1, 4, 16, 10, 8, 2,
14, 13, 4, 7, 10, 1, 16, 1, 7, 18, 13, 12, 3, 6, 9,
15, 7, 13, 1, 3, 18, 9, 12, 15, 6, 13, 3, 7, 9, 1, 15,
18, 6, 12, 3, 9, 13, 15, 7, 6, 1, 12, 18, 9, 15, 3, 6,
13, 12, 7, 18, 1, 15, 6, 9, 12, 3, 18, 13, 1, 7, 6,
12, 15, 18, 9, 1, 3, 7, 13, 12, 18, 6, 1, 15, 7, 9,
13, 3, 18, 1, 12, 7, 6, 13, 15, 3, 9, 15, 9, 6, 3, 12,
13, 18, 7, 1, 6, 15, 12, 9, 18, 3, 1, 13, 7, 12, 6,
18, 15, 1, 9, 7, 3, 13, 18, 12, 1, 6, 7, 15, 13, 9, 3,
1, 18, 7, 12, 13, 6, 3, 15, 9, 7, 1, 13, 18, 3, 12, 9,
6, 15, 13, 7, 3, 1, 9, 18, 15, 12, 6, 3, 13, 9, 7, 15,
1, 6, 18, 12, 9, 3, 15, 13, 6, 7, 12, 1, 18, 1, 7, 17,
13, 11, 4, 5, 10, 16, 7, 13, 1, 4, 17, 10, 11, 16, 5,
13, 4, 7, 10, 1, 16, 17, 5, 11, 4, 10, 13, 16, 7, 5,
1, 11, 17, 10, 16, 4, 5, 13, 11, 7, 17, 1, 16, 5, 10,
11, 4, 17, 13, 1, 7, 5, 11, 16, 17, 10, 1, 4, 7, 13,
11, 17, 5, 1, 16, 7, 10, 13, 4, 17, 1, 11, 7, 5, 13,
16, 4, 10, 16, 10, 5, 4, 11, 13, 17, 7, 1, 5, 16, 11,
10, 17, 4, 1, 13, 7, 11, 5, 17, 16, 1, 10, 7, 4, 13,
17, 11, 1, 5, 7, 16, 13, 10, 4, 1, 17, 7, 11, 13, 5,
4, 16, 10, 7, 1, 13, 17, 4, 11, 10, 5, 16, 13, 7, 4,
1, 10, 17, 16, 11, 5, 4, 13, 10, 7, 16, 1, 5, 17, 11,
10, 4, 16, 13, 5, 7, 11, 1, 17, 1, 7, 18, 13, 12, 5,
6, 11, 17, 7, 13, 1, 5, 18, 11, 12, 17, 6, 13, 5, 7,
11, 1, 17, 18, 6, 12, 5, 11, 13, 17, 7, 6, 1, 12, 18,
11, 17, 5, 6, 13, 12, 7, 18, 1, 17, 6, 11, 12, 5, 18,
13, 1, 7, 6, 12, 17, 18, 11, 1, 5, 7, 13, 12, 18, 6,
1, 17, 7, 11, 13, 5, 18, 1, 12, 7, 6, 13, 17, 5, 11,
17, 11, 6, 5, 12, 13, 18, 7, 1, 6, 17, 12, 11, 18, 5,
1, 13, 7, 12, 6, 18, 17, 1, 11, 7, 5, 13, 18, 12, 1,
6, 7, 17, 13, 11, 5, 1, 18, 7, 12, 13, 6, 5, 17, 11,
7, 1, 13, 18, 5, 12, 11, 6, 17, 13, 7, 5, 1, 11, 18,
17, 12, 6, 5, 13, 11, 7, 17, 1, 6, 18, 12, 11, 5, 17,
13, 6, 7, 12, 1, 18, 2, 8, 17, 14, 11, 3, 5, 9, 15, 8,
14, 2, 3, 17, 9, 11, 15, 5, 14, 3, 8, 9, 2, 15, 17, 5,
11, 3, 9, 14, 15, 8, 5, 2, 11, 17, 9, 15, 3, 5, 14,
11, 8, 17, 2, 15, 5, 9, 11, 3, 17, 14, 2, 8, 5, 11,
15, 17, 9, 2, 3, 8, 14, 11, 17, 5, 2, 15, 8, 9, 14, 3,
17, 2, 11, 8, 5, 14, 15, 3, 9, 15, 9, 5, 3, 11, 14,
17, 8, 2, 5, 15, 11, 9, 17, 3, 2, 14, 8, 11, 5, 17,
15, 2, 9, 8, 3, 14, 17, 11, 2, 5, 8, 15, 14, 9, 3, 2,
17, 8, 11, 14, 5, 3, 15, 9, 8, 2, 14, 17, 3, 11, 9, 5,
15, 14, 8, 3, 2, 9, 17, 15, 11, 5, 3, 14, 9, 8, 15, 2,
5, 17, 11, 9, 3, 15, 14, 5, 8, 11, 2, 17, 2, 8, 18,
14, 12, 4, 6, 10, 16, 8, 14, 2, 4, 18, 10, 12, 16, 6,
14, 4, 8, 10, 2, 16, 18, 6, 12, 4, 10, 14, 16, 8, 6,
2, 12, 18, 10, 16, 4, 6, 14, 12, 8, 18, 2, 16, 6, 10,
12, 4, 18, 14, 2, 8, 6, 12, 16, 18, 10, 2, 4, 8, 14,
12, 18, 6, 2, 16, 8, 10, 14, 4, 18, 2, 12, 8, 6, 14,
16, 4, 10, 16, 10, 6, 4, 12, 14, 18, 8, 2, 6, 16, 12,
10, 18, 4, 2, 14, 8, 12, 6, 18, 16, 2, 10, 8, 4, 14,
18, 12, 2, 6, 8, 16, 14, 10, 4, 2, 18, 8, 12, 14, 6,
4, 16, 10, 8, 2, 14, 18, 4, 12, 10, 6, 16, 14, 8, 4,
2, 10, 18, 16, 12, 6, 4, 14, 10, 8, 16, 2, 6, 18, 12,
10, 4, 16, 14, 6, 8, 12, 2, 18, 2, 8, 18, 14, 12, 5,
6, 11, 17, 8, 14, 2, 5, 18, 11, 12, 17, 6, 14, 5, 8,
11, 2, 17, 18, 6, 12, 5, 11, 14, 17, 8, 6, 2, 12, 18,
11, 17, 5, 6, 14, 12, 8, 18, 2, 17, 6, 11, 12, 5, 18,
14, 2, 8, 6, 12, 17, 18, 11, 2, 5, 8, 14, 12, 18, 6,
2, 17, 8, 11, 14, 5, 18, 2, 12, 8, 6, 14, 17, 5, 11,
17, 11, 6, 5, 12, 14, 18, 8, 2, 6, 17, 12, 11, 18, 5,
2, 14, 8, 12, 6, 18, 17, 2, 11, 8, 5, 14, 18, 12, 2,
6, 8, 17, 14, 11, 5, 2, 18, 8, 12, 14, 6, 5, 17, 11,
8, 2, 14, 18, 5, 12, 11, 6, 17, 14, 8, 5, 2, 11, 18,
17, 12, 6, 5, 14, 11, 8, 17, 2, 6, 18, 12, 11, 5, 17,
14, 6, 8, 12, 2, 18, 3, 9, 17, 15, 11, 4, 5, 10, 16,
9, 15, 3, 4, 17, 10, 11, 16, 5, 15, 4, 9, 10, 3, 16,
17, 5, 11, 4, 10, 15, 16, 9, 5, 3, 11, 17, 10, 16, 4,
5, 15, 11, 9, 17, 3, 16, 5, 10, 11, 4, 17, 15, 3, 9,
5, 11, 16, 17, 10, 3, 4, 9, 15, 11, 17, 5, 3, 16, 9,
10, 15, 4, 17, 3, 11, 9, 5, 15, 16, 4, 10, 16, 10, 5,
4, 11, 15, 17, 9, 3, 5, 16, 11, 10, 17, 4, 3, 15, 9,
11, 5, 17, 16, 3, 10, 9, 4, 15, 17, 11, 3, 5, 9, 16,
15, 10, 4, 3, 17, 9, 11, 15, 5, 4, 16, 10, 9, 3, 15,
17, 4, 11, 10, 5, 16, 15, 9, 4, 3, 10, 17, 16, 11, 5,
4, 15, 10, 9, 16, 3, 5, 17, 11, 10, 4, 16, 15, 5, 9,
11, 3, 17, 3, 9, 18, 15, 12, 4, 6, 10, 16, 9, 15, 3,
4, 18, 10, 12, 16, 6, 15, 4, 9, 10, 3, 16, 18, 6, 12,
4, 10, 15, 16, 9, 6, 3, 12, 18, 10, 16, 4, 6, 15, 12,
9, 18, 3, 16, 6, 10, 12, 4, 18, 15, 3, 9, 6, 12, 16,
18, 10, 3, 4, 9, 15, 12, 18, 6, 3, 16, 9, 10, 15, 4,
18, 3, 12, 9, 6, 15, 16, 4, 10, 16, 10, 6, 4, 12, 15,
18, 9, 3, 6, 16, 12, 10, 18, 4, 3, 15, 9, 12, 6, 18,
16, 3, 10, 9, 4, 15, 18, 12, 3, 6, 9, 16, 15, 10, 4,
3, 18, 9, 12, 15, 6, 4, 16, 10, 9, 3, 15, 18, 4, 12,
10, 6, 16, 15, 9, 4, 3, 10, 18, 16, 12, 6, 4, 15, 10,
9, 16, 3, 6, 18, 12, 10, 4, 16, 15, 6, 9, 12, 3, 18),
180, 9, byrow = T)
} else if (all(williams_D == 9, selection == 88, type == "S")) {
sequences <- matrix(c(1, 8, 18, 15, 11, 2, 4, 9, 16, 8, 15, 1, 2, 18, 9, 11,
16, 4, 15, 2, 8, 9, 1, 16, 18, 4, 11, 2, 9, 15, 16, 8,
4, 1, 11, 18, 9, 16, 2, 4, 15, 11, 8, 18, 1, 16, 4, 9,
11, 2, 18, 15, 1, 8, 4, 11, 16, 18, 9, 1, 2, 8, 15,
11, 18, 4, 1, 16, 8, 9, 15, 2, 18, 1, 11, 8, 4, 15,
16, 2, 9, 16, 9, 4, 2, 11, 15, 18, 8, 1, 4, 16, 11, 9,
18, 2, 1, 15, 8, 11, 4, 18, 16, 1, 9, 8, 2, 15, 18,
11, 1, 4, 8, 16, 15, 9, 2, 1, 18, 8, 11, 15, 4, 2, 16,
9, 8, 1, 15, 18, 2, 11, 9, 4, 16, 15, 8, 2, 1, 9, 18,
16, 11, 4, 2, 15, 9, 8, 16, 1, 4, 18, 11, 9, 2, 16,
15, 4, 8, 11, 1, 18, 2, 9, 19, 16, 12, 3, 5, 10, 17,
9, 16, 2, 3, 19, 10, 12, 17, 5, 16, 3, 9, 10, 2, 17,
19, 5, 12, 3, 10, 16, 17, 9, 5, 2, 12, 19, 10, 17, 3,
5, 16, 12, 9, 19, 2, 17, 5, 10, 12, 3, 19, 16, 2, 9,
5, 12, 17, 19, 10, 2, 3, 9, 16, 12, 19, 5, 2, 17, 9,
10, 16, 3, 19, 2, 12, 9, 5, 16, 17, 3, 10, 17, 10, 5,
3, 12, 16, 19, 9, 2, 5, 17, 12, 10, 19, 3, 2, 16, 9,
12, 5, 19, 17, 2, 10, 9, 3, 16, 19, 12, 2, 5, 9, 17,
16, 10, 3, 2, 19, 9, 12, 16, 5, 3, 17, 10, 9, 2, 16,
19, 3, 12, 10, 5, 17, 16, 9, 3, 2, 10, 19, 17, 12, 5,
3, 16, 10, 9, 17, 2, 5, 19, 12, 10, 3, 17, 16, 5, 9,
12, 2, 19, 3, 10, 20, 17, 13, 4, 6, 11, 18, 10, 17, 3,
4, 20, 11, 13, 18, 6, 17, 4, 10, 11, 3, 18, 20, 6, 13,
4, 11, 17, 18, 10, 6, 3, 13, 20, 11, 18, 4, 6, 17, 13,
10, 20, 3, 18, 6, 11, 13, 4, 20, 17, 3, 10, 6, 13, 18,
20, 11, 3, 4, 10, 17, 13, 20, 6, 3, 18, 10, 11, 17, 4,
20, 3, 13, 10, 6, 17, 18, 4, 11, 18, 11, 6, 4, 13, 17,
20, 10, 3, 6, 18, 13, 11, 20, 4, 3, 17, 10, 13, 6, 20,
18, 3, 11, 10, 4, 17, 20, 13, 3, 6, 10, 18, 17, 11, 4,
3, 20, 10, 13, 17, 6, 4, 18, 11, 10, 3, 17, 20, 4, 13,
11, 6, 18, 17, 10, 4, 3, 11, 20, 18, 13, 6, 4, 17, 11,
10, 18, 3, 6, 20, 13, 11, 4, 18, 17, 6, 10, 13, 3, 20,
4, 11, 21, 18, 14, 5, 7, 12, 19, 11, 18, 4, 5, 21, 12,
14, 19, 7, 18, 5, 11, 12, 4, 19, 21, 7, 14, 5, 12, 18,
19, 11, 7, 4, 14, 21, 12, 19, 5, 7, 18, 14, 11, 21, 4,
19, 7, 12, 14, 5, 21, 18, 4, 11, 7, 14, 19, 21, 12, 4,
5, 11, 18, 14, 21, 7, 4, 19, 11, 12, 18, 5, 21, 4, 14,
11, 7, 18, 19, 5, 12, 19, 12, 7, 5, 14, 18, 21, 11, 4,
7, 19, 14, 12, 21, 5, 4, 18, 11, 14, 7, 21, 19, 4, 12,
11, 5, 18, 21, 14, 4, 7, 11, 19, 18, 12, 5, 4, 21, 11,
14, 18, 7, 5, 19, 12, 11, 4, 18, 21, 5, 14, 12, 7, 19,
18, 11, 5, 4, 12, 21, 19, 14, 7, 5, 18, 12, 11, 19, 4,
7, 21, 14, 12, 5, 19, 18, 7, 11, 14, 4, 21, 5, 12, 15,
19, 8, 6, 1, 13, 20, 12, 19, 5, 6, 15, 13, 8, 20, 1,
19, 6, 12, 13, 5, 20, 15, 1, 8, 6, 13, 19, 20, 12, 1,
5, 8, 15, 13, 20, 6, 1, 19, 8, 12, 15, 5, 20, 1, 13,
8, 6, 15, 19, 5, 12, 1, 8, 20, 15, 13, 5, 6, 12, 19,
8, 15, 1, 5, 20, 12, 13, 19, 6, 15, 5, 8, 12, 1, 19,
20, 6, 13, 20, 13, 1, 6, 8, 19, 15, 12, 5, 1, 20, 8,
13, 15, 6, 5, 19, 12, 8, 1, 15, 20, 5, 13, 12, 6, 19,
15, 8, 5, 1, 12, 20, 19, 13, 6, 5, 15, 12, 8, 19, 1,
6, 20, 13, 12, 5, 19, 15, 6, 8, 13, 1, 20, 19, 12, 6,
5, 13, 15, 20, 8, 1, 6, 19, 13, 12, 20, 5, 1, 15, 8,
13, 6, 20, 19, 1, 12, 8, 5, 15, 6, 13, 16, 20, 9, 7,
2, 14, 21, 13, 20, 6, 7, 16, 14, 9, 21, 2, 20, 7, 13,
14, 6, 21, 16, 2, 9, 7, 14, 20, 21, 13, 2, 6, 9, 16,
14, 21, 7, 2, 20, 9, 13, 16, 6, 21, 2, 14, 9, 7, 16,
20, 6, 13, 2, 9, 21, 16, 14, 6, 7, 13, 20, 9, 16, 2,
6, 21, 13, 14, 20, 7, 16, 6, 9, 13, 2, 20, 21, 7, 14,
21, 14, 2, 7, 9, 20, 16, 13, 6, 2, 21, 9, 14, 16, 7,
6, 20, 13, 9, 2, 16, 21, 6, 14, 13, 7, 20, 16, 9, 6,
2, 13, 21, 20, 14, 7, 6, 16, 13, 9, 20, 2, 7, 21, 14,
13, 6, 20, 16, 7, 9, 14, 2, 21, 20, 13, 7, 6, 14, 16,
21, 9, 2, 7, 20, 14, 13, 21, 6, 2, 16, 9, 14, 7, 21,
20, 2, 13, 9, 6, 16, 7, 14, 17, 21, 10, 1, 3, 8, 15,
14, 21, 7, 1, 17, 8, 10, 15, 3, 21, 1, 14, 8, 7, 15,
17, 3, 10, 1, 8, 21, 15, 14, 3, 7, 10, 17, 8, 15, 1,
3, 21, 10, 14, 17, 7, 15, 3, 8, 10, 1, 17, 21, 7, 14,
3, 10, 15, 17, 8, 7, 1, 14, 21, 10, 17, 3, 7, 15, 14,
8, 21, 1, 17, 7, 10, 14, 3, 21, 15, 1, 8, 15, 8, 3, 1,
10, 21, 17, 14, 7, 3, 15, 10, 8, 17, 1, 7, 21, 14, 10,
3, 17, 15, 7, 8, 14, 1, 21, 17, 10, 7, 3, 14, 15, 21,
8, 1, 7, 17, 14, 10, 21, 3, 1, 15, 8, 14, 7, 21, 17,
1, 10, 8, 3, 15, 21, 14, 1, 7, 8, 17, 15, 10, 3, 1,
21, 8, 14, 15, 7, 3, 17, 10, 8, 1, 15, 21, 3, 14, 10,
7, 17), 126, 9, byrow = T)
} else if (all(williams_D == 9, selection == 91, type == "S")) {
sequences <- matrix(c(1, 10, 25, 19, 16, 4, 7, 13, 22, 10, 19, 1, 4, 25, 13,
16, 22, 7, 19, 4, 10, 13, 1, 22, 25, 7, 16, 4, 13, 19,
22, 10, 7, 1, 16, 25, 13, 22, 4, 7, 19, 16, 10, 25, 1,
22, 7, 13, 16, 4, 25, 19, 1, 10, 7, 16, 22, 25, 13, 1,
4, 10, 19, 16, 25, 7, 1, 22, 10, 13, 19, 4, 25, 1, 16,
10, 7, 19, 22, 4, 13, 22, 13, 7, 4, 16, 19, 25, 10, 1,
7, 22, 16, 13, 25, 4, 1, 19, 10, 16, 7, 25, 22, 1, 13,
10, 4, 19, 25, 16, 1, 7, 10, 22, 19, 13, 4, 1, 25, 10,
16, 19, 7, 4, 22, 13, 10, 1, 19, 25, 4, 16, 13, 7, 22,
19, 10, 4, 1, 13, 25, 22, 16, 7, 4, 19, 13, 10, 22, 1,
7, 25, 16, 13, 4, 22, 19, 7, 10, 16, 1, 25, 2, 11, 26,
20, 17, 5, 8, 14, 23, 11, 20, 2, 5, 26, 14, 17, 23, 8,
20, 5, 11, 14, 2, 23, 26, 8, 17, 5, 14, 20, 23, 11, 8,
2, 17, 26, 14, 23, 5, 8, 20, 17, 11, 26, 2, 23, 8, 14,
17, 5, 26, 20, 2, 11, 8, 17, 23, 26, 14, 2, 5, 11, 20,
17, 26, 8, 2, 23, 11, 14, 20, 5, 26, 2, 17, 11, 8, 20,
23, 5, 14, 23, 14, 8, 5, 17, 20, 26, 11, 2, 8, 23, 17,
14, 26, 5, 2, 20, 11, 17, 8, 26, 23, 2, 14, 11, 5, 20,
26, 17, 2, 8, 11, 23, 20, 14, 5, 2, 26, 11, 17, 20, 8,
5, 23, 14, 11, 2, 20, 26, 5, 17, 14, 8, 23, 20, 11, 5,
2, 14, 26, 23, 17, 8, 5, 20, 14, 11, 23, 2, 8, 26, 17,
14, 5, 23, 20, 8, 11, 17, 2, 26, 3, 12, 27, 21, 18, 6,
9, 15, 24, 12, 21, 3, 6, 27, 15, 18, 24, 9, 21, 6, 12,
15, 3, 24, 27, 9, 18, 6, 15, 21, 24, 12, 9, 3, 18, 27,
15, 24, 6, 9, 21, 18, 12, 27, 3, 24, 9, 15, 18, 6, 27,
21, 3, 12, 9, 18, 24, 27, 15, 3, 6, 12, 21, 18, 27, 9,
3, 24, 12, 15, 21, 6, 27, 3, 18, 12, 9, 21, 24, 6, 15,
24, 15, 9, 6, 18, 21, 27, 12, 3, 9, 24, 18, 15, 27, 6,
3, 21, 12, 18, 9, 27, 24, 3, 15, 12, 6, 21, 27, 18, 3,
9, 12, 24, 21, 15, 6, 3, 27, 12, 18, 21, 9, 6, 24, 15,
12, 3, 21, 27, 6, 18, 15, 9, 24, 21, 12, 6, 3, 15, 27,
24, 18, 9, 6, 21, 15, 12, 24, 3, 9, 27, 18, 15, 6, 24,
21, 9, 12, 18, 3, 27, 2, 11, 22, 20, 13, 3, 4, 12, 21,
11, 20, 2, 3, 22, 12, 13, 21, 4, 20, 3, 11, 12, 2, 21,
22, 4, 13, 3, 12, 20, 21, 11, 4, 2, 13, 22, 12, 21, 3,
4, 20, 13, 11, 22, 2, 21, 4, 12, 13, 3, 22, 20, 2, 11,
4, 13, 21, 22, 12, 2, 3, 11, 20, 13, 22, 4, 2, 21, 11,
12, 20, 3, 22, 2, 13, 11, 4, 20, 21, 3, 12, 21, 12, 4,
3, 13, 20, 22, 11, 2, 4, 21, 13, 12, 22, 3, 2, 20, 11,
13, 4, 22, 21, 2, 12, 11, 3, 20, 22, 13, 2, 4, 11, 21,
20, 12, 3, 2, 22, 11, 13, 20, 4, 3, 21, 12, 11, 2, 20,
22, 3, 13, 12, 4, 21, 20, 11, 3, 2, 12, 22, 21, 13, 4,
3, 20, 12, 11, 21, 2, 4, 22, 13, 12, 3, 21, 20, 4, 11,
13, 2, 22, 5, 14, 25, 23, 16, 6, 7, 15, 24, 14, 23, 5,
6, 25, 15, 16, 24, 7, 23, 6, 14, 15, 5, 24, 25, 7, 16,
6, 15, 23, 24, 14, 7, 5, 16, 25, 15, 24, 6, 7, 23, 16,
14, 25, 5, 24, 7, 15, 16, 6, 25, 23, 5, 14, 7, 16, 24,
25, 15, 5, 6, 14, 23, 16, 25, 7, 5, 24, 14, 15, 23, 6,
25, 5, 16, 14, 7, 23, 24, 6, 15, 24, 15, 7, 6, 16, 23,
25, 14, 5, 7, 24, 16, 15, 25, 6, 5, 23, 14, 16, 7, 25,
24, 5, 15, 14, 6, 23, 25, 16, 5, 7, 14, 24, 23, 15, 6,
5, 25, 14, 16, 23, 7, 6, 24, 15, 14, 5, 23, 25, 6, 16,
15, 7, 24, 23, 14, 6, 5, 15, 25, 24, 16, 7, 6, 23, 15,
14, 24, 5, 7, 25, 16, 15, 6, 24, 23, 7, 14, 16, 5, 25,
8, 17, 19, 26, 10, 9, 1, 18, 27, 17, 26, 8, 9, 19, 18,
10, 27, 1, 26, 9, 17, 18, 8, 27, 19, 1, 10, 9, 18, 26,
27, 17, 1, 8, 10, 19, 18, 27, 9, 1, 26, 10, 17, 19, 8,
27, 1, 18, 10, 9, 19, 26, 8, 17, 1, 10, 27, 19, 18, 8,
9, 17, 26, 10, 19, 1, 8, 27, 17, 18, 26, 9, 19, 8, 10,
17, 1, 26, 27, 9, 18, 27, 18, 1, 9, 10, 26, 19, 17, 8,
1, 27, 10, 18, 19, 9, 8, 26, 17, 10, 1, 19, 27, 8, 18,
17, 9, 26, 19, 10, 8, 1, 17, 27, 26, 18, 9, 8, 19, 17,
10, 26, 1, 9, 27, 18, 17, 8, 26, 19, 9, 10, 18, 1, 27,
26, 17, 9, 8, 18, 19, 27, 10, 1, 9, 26, 18, 17, 27, 8,
1, 19, 10, 18, 9, 27, 26, 1, 17, 10, 8, 19, 3, 12, 23,
21, 14, 1, 5, 10, 19, 12, 21, 3, 1, 23, 10, 14, 19, 5,
21, 1, 12, 10, 3, 19, 23, 5, 14, 1, 10, 21, 19, 12, 5,
3, 14, 23, 10, 19, 1, 5, 21, 14, 12, 23, 3, 19, 5, 10,
14, 1, 23, 21, 3, 12, 5, 14, 19, 23, 10, 3, 1, 12, 21,
14, 23, 5, 3, 19, 12, 10, 21, 1, 23, 3, 14, 12, 5, 21,
19, 1, 10, 19, 10, 5, 1, 14, 21, 23, 12, 3, 5, 19, 14,
10, 23, 1, 3, 21, 12, 14, 5, 23, 19, 3, 10, 12, 1, 21,
23, 14, 3, 5, 12, 19, 21, 10, 1, 3, 23, 12, 14, 21, 5,
1, 19, 10, 12, 3, 21, 23, 1, 14, 10, 5, 19, 21, 12, 1,
3, 10, 23, 19, 14, 5, 1, 21, 10, 12, 19, 3, 5, 23, 14,
10, 1, 19, 21, 5, 12, 14, 3, 23, 6, 15, 26, 24, 17, 4,
8, 13, 22, 15, 24, 6, 4, 26, 13, 17, 22, 8, 24, 4, 15,
13, 6, 22, 26, 8, 17, 4, 13, 24, 22, 15, 8, 6, 17, 26,
13, 22, 4, 8, 24, 17, 15, 26, 6, 22, 8, 13, 17, 4, 26,
24, 6, 15, 8, 17, 22, 26, 13, 6, 4, 15, 24, 17, 26, 8,
6, 22, 15, 13, 24, 4, 26, 6, 17, 15, 8, 24, 22, 4, 13,
22, 13, 8, 4, 17, 24, 26, 15, 6, 8, 22, 17, 13, 26, 4,
6, 24, 15, 17, 8, 26, 22, 6, 13, 15, 4, 24, 26, 17, 6,
8, 15, 22, 24, 13, 4, 6, 26, 15, 17, 24, 8, 4, 22, 13,
15, 6, 24, 26, 4, 17, 13, 8, 22, 24, 15, 4, 6, 13, 26,
22, 17, 8, 4, 24, 13, 15, 22, 6, 8, 26, 17, 13, 4, 22,
24, 8, 15, 17, 6, 26, 9, 18, 20, 27, 11, 7, 2, 16, 25,
18, 27, 9, 7, 20, 16, 11, 25, 2, 27, 7, 18, 16, 9, 25,
20, 2, 11, 7, 16, 27, 25, 18, 2, 9, 11, 20, 16, 25, 7,
2, 27, 11, 18, 20, 9, 25, 2, 16, 11, 7, 20, 27, 9, 18,
2, 11, 25, 20, 16, 9, 7, 18, 27, 11, 20, 2, 9, 25, 18,
16, 27, 7, 20, 9, 11, 18, 2, 27, 25, 7, 16, 25, 16, 2,
7, 11, 27, 20, 18, 9, 2, 25, 11, 16, 20, 7, 9, 27, 18,
11, 2, 20, 25, 9, 16, 18, 7, 27, 20, 11, 9, 2, 18, 25,
27, 16, 7, 9, 20, 18, 11, 27, 2, 7, 25, 16, 18, 9, 27,
20, 7, 11, 16, 2, 25, 27, 18, 7, 9, 16, 20, 25, 11, 2,
7, 27, 16, 18, 25, 9, 2, 20, 11, 16, 7, 25, 27, 2, 18,
11, 9, 20, 1, 10, 24, 19, 15, 2, 6, 11, 20, 10, 19, 1,
2, 24, 11, 15, 20, 6, 19, 2, 10, 11, 1, 20, 24, 6, 15,
2, 11, 19, 20, 10, 6, 1, 15, 24, 11, 20, 2, 6, 19, 15,
10, 24, 1, 20, 6, 11, 15, 2, 24, 19, 1, 10, 6, 15, 20,
24, 11, 1, 2, 10, 19, 15, 24, 6, 1, 20, 10, 11, 19, 2,
24, 1, 15, 10, 6, 19, 20, 2, 11, 20, 11, 6, 2, 15, 19,
24, 10, 1, 6, 20, 15, 11, 24, 2, 1, 19, 10, 15, 6, 24,
20, 1, 11, 10, 2, 19, 24, 15, 1, 6, 10, 20, 19, 11, 2,
1, 24, 10, 15, 19, 6, 2, 20, 11, 10, 1, 19, 24, 2, 15,
11, 6, 20, 19, 10, 2, 1, 11, 24, 20, 15, 6, 2, 19, 11,
10, 20, 1, 6, 24, 15, 11, 2, 20, 19, 6, 10, 15, 1, 24,
4, 13, 27, 22, 18, 5, 9, 14, 23, 13, 22, 4, 5, 27, 14,
18, 23, 9, 22, 5, 13, 14, 4, 23, 27, 9, 18, 5, 14, 22,
23, 13, 9, 4, 18, 27, 14, 23, 5, 9, 22, 18, 13, 27, 4,
23, 9, 14, 18, 5, 27, 22, 4, 13, 9, 18, 23, 27, 14, 4,
5, 13, 22, 18, 27, 9, 4, 23, 13, 14, 22, 5, 27, 4, 18,
13, 9, 22, 23, 5, 14, 23, 14, 9, 5, 18, 22, 27, 13, 4,
9, 23, 18, 14, 27, 5, 4, 22, 13, 18, 9, 27, 23, 4, 14,
13, 5, 22, 27, 18, 4, 9, 13, 23, 22, 14, 5, 4, 27, 13,
18, 22, 9, 5, 23, 14, 13, 4, 22, 27, 5, 18, 14, 9, 23,
22, 13, 5, 4, 14, 27, 23, 18, 9, 5, 22, 14, 13, 23, 4,
9, 27, 18, 14, 5, 23, 22, 9, 13, 18, 4, 27, 7, 16, 21,
25, 12, 8, 3, 17, 26, 16, 25, 7, 8, 21, 17, 12, 26, 3,
25, 8, 16, 17, 7, 26, 21, 3, 12, 8, 17, 25, 26, 16, 3,
7, 12, 21, 17, 26, 8, 3, 25, 12, 16, 21, 7, 26, 3, 17,
12, 8, 21, 25, 7, 16, 3, 12, 26, 21, 17, 7, 8, 16, 25,
12, 21, 3, 7, 26, 16, 17, 25, 8, 21, 7, 12, 16, 3, 25,
26, 8, 17, 26, 17, 3, 8, 12, 25, 21, 16, 7, 3, 26, 12,
17, 21, 8, 7, 25, 16, 12, 3, 21, 26, 7, 17, 16, 8, 25,
21, 12, 7, 3, 16, 26, 25, 17, 8, 7, 21, 16, 12, 25, 3,
8, 26, 17, 16, 7, 25, 21, 8, 12, 17, 3, 26, 25, 16, 8,
7, 17, 21, 26, 12, 3, 8, 25, 17, 16, 26, 7, 3, 21, 12,
17, 8, 26, 25, 3, 16, 12, 7, 21), 216, 9, byrow = T)
} else if (all(williams_D == 9, selection == 99, type == "SR")) {
sequences <- matrix(c(10, 11, 13, 3, 14, 9, 7, 8, 15, 11, 3, 10, 9, 13, 8,
14, 15, 7, 3, 9, 11, 8, 10, 15, 13, 7, 14, 9, 8, 3,
15, 11, 7, 10, 14, 13, 8, 15, 9, 7, 3, 14, 11, 13, 10,
15, 7, 8, 14, 9, 13, 3, 10, 11, 7, 14, 15, 13, 8, 10,
9, 11, 3, 14, 13, 7, 10, 15, 11, 8, 3, 9, 13, 10, 14,
11, 7, 3, 15, 9, 8, 15, 8, 7, 9, 14, 3, 13, 11, 10, 7,
15, 14, 8, 13, 9, 10, 3, 11, 14, 7, 13, 15, 10, 8, 11,
9, 3, 13, 14, 10, 7, 11, 15, 3, 8, 9, 10, 13, 11, 14,
3, 7, 9, 15, 8, 11, 10, 3, 13, 9, 14, 8, 7, 15, 3, 11,
9, 10, 8, 13, 15, 14, 7, 9, 3, 8, 11, 15, 10, 7, 13,
14, 8, 9, 15, 3, 7, 11, 14, 10, 13, 1, 16, 9, 12, 15,
4, 11, 14, 8, 16, 12, 1, 4, 9, 14, 15, 8, 11, 12, 4,
16, 14, 1, 8, 9, 11, 15, 4, 14, 12, 8, 16, 11, 1, 15,
9, 14, 8, 4, 11, 12, 15, 16, 9, 1, 8, 11, 14, 15, 4,
9, 12, 1, 16, 11, 15, 8, 9, 14, 1, 4, 16, 12, 15, 9,
11, 1, 8, 16, 14, 12, 4, 9, 1, 15, 16, 11, 12, 8, 4,
14, 8, 14, 11, 4, 15, 12, 9, 16, 1, 11, 8, 15, 14, 9,
4, 1, 12, 16, 15, 11, 9, 8, 1, 14, 16, 4, 12, 9, 15,
1, 11, 16, 8, 12, 14, 4, 1, 9, 16, 15, 12, 11, 4, 8,
14, 16, 1, 12, 9, 4, 15, 14, 11, 8, 12, 16, 4, 1, 14,
9, 8, 15, 11, 4, 12, 14, 16, 8, 1, 11, 9, 15, 14, 4,
8, 12, 11, 16, 15, 1, 9, 10, 2, 9, 12, 17, 13, 16, 5,
15, 2, 12, 10, 13, 9, 5, 17, 15, 16, 12, 13, 2, 5, 10,
15, 9, 16, 17, 13, 5, 12, 15, 2, 16, 10, 17, 9, 5, 15,
13, 16, 12, 17, 2, 9, 10, 15, 16, 5, 17, 13, 9, 12,
10, 2, 16, 17, 15, 9, 5, 10, 13, 2, 12, 17, 9, 16, 10,
15, 2, 5, 12, 13, 9, 10, 17, 2, 16, 12, 15, 13, 5, 15,
5, 16, 13, 17, 12, 9, 2, 10, 16, 15, 17, 5, 9, 13, 10,
12, 2, 17, 16, 9, 15, 10, 5, 2, 13, 12, 9, 17, 10, 16,
2, 15, 12, 5, 13, 10, 9, 2, 17, 12, 16, 13, 15, 5, 2,
10, 12, 9, 13, 17, 5, 16, 15, 12, 2, 13, 10, 5, 9, 15,
17, 16, 13, 12, 5, 2, 15, 10, 16, 9, 17, 5, 13, 15,
12, 16, 2, 17, 10, 9, 1, 11, 18, 6, 17, 13, 16, 14, 3,
11, 6, 1, 13, 18, 14, 17, 3, 16, 6, 13, 11, 14, 1, 3,
18, 16, 17, 13, 14, 6, 3, 11, 16, 1, 17, 18, 14, 3,
13, 16, 6, 17, 11, 18, 1, 3, 16, 14, 17, 13, 18, 6, 1,
11, 16, 17, 3, 18, 14, 1, 13, 11, 6, 17, 18, 16, 1, 3,
11, 14, 6, 13, 18, 1, 17, 11, 16, 6, 3, 13, 14, 3, 14,
16, 13, 17, 6, 18, 11, 1, 16, 3, 17, 14, 18, 13, 1, 6,
11, 17, 16, 18, 3, 1, 14, 11, 13, 6, 18, 17, 1, 16,
11, 3, 6, 14, 13, 1, 18, 11, 17, 6, 16, 13, 3, 14, 11,
1, 6, 18, 13, 17, 14, 16, 3, 6, 11, 13, 1, 14, 18, 3,
17, 16, 13, 6, 14, 11, 3, 1, 16, 18, 17, 14, 13, 3, 6,
16, 11, 17, 1, 18, 17, 14, 18, 15, 2, 7, 1, 4, 12, 14,
15, 17, 7, 18, 4, 2, 12, 1, 15, 7, 14, 4, 17, 12, 18,
1, 2, 7, 4, 15, 12, 14, 1, 17, 2, 18, 4, 12, 7, 1, 15,
2, 14, 18, 17, 12, 1, 4, 2, 7, 18, 15, 17, 14, 1, 2,
12, 18, 4, 17, 7, 14, 15, 2, 18, 1, 17, 12, 14, 4, 15,
7, 18, 17, 2, 14, 1, 15, 12, 7, 4, 12, 4, 1, 7, 2, 15,
18, 14, 17, 1, 12, 2, 4, 18, 7, 17, 15, 14, 2, 1, 18,
12, 17, 4, 14, 7, 15, 18, 2, 17, 1, 14, 12, 15, 4, 7,
17, 18, 14, 2, 15, 1, 7, 12, 4, 14, 17, 15, 18, 7, 2,
4, 1, 12, 15, 14, 7, 17, 4, 18, 12, 2, 1, 7, 15, 4,
14, 12, 17, 1, 18, 2, 4, 7, 12, 15, 1, 14, 2, 17, 18,
13, 5, 3, 15, 8, 16, 1, 2, 18, 5, 15, 13, 16, 3, 2, 8,
18, 1, 15, 16, 5, 2, 13, 18, 3, 1, 8, 16, 2, 15, 18,
5, 1, 13, 8, 3, 2, 18, 16, 1, 15, 8, 5, 3, 13, 18, 1,
2, 8, 16, 3, 15, 13, 5, 1, 8, 18, 3, 2, 13, 16, 5, 15,
8, 3, 1, 13, 18, 5, 2, 15, 16, 3, 13, 8, 5, 1, 15, 18,
16, 2, 18, 2, 1, 16, 8, 15, 3, 5, 13, 1, 18, 8, 2, 3,
16, 13, 15, 5, 8, 1, 3, 18, 13, 2, 5, 16, 15, 3, 8,
13, 1, 5, 18, 15, 2, 16, 13, 3, 5, 8, 15, 1, 16, 18,
2, 5, 13, 15, 3, 16, 8, 2, 1, 18, 15, 5, 16, 13, 2, 3,
18, 8, 1, 16, 15, 2, 5, 18, 13, 1, 3, 8, 2, 16, 18,
15, 1, 5, 8, 13, 3, 4, 14, 3, 6, 2, 16, 10, 17, 9, 14,
6, 4, 16, 3, 17, 2, 9, 10, 6, 16, 14, 17, 4, 9, 3, 10,
2, 16, 17, 6, 9, 14, 10, 4, 2, 3, 17, 9, 16, 10, 6, 2,
14, 3, 4, 9, 10, 17, 2, 16, 3, 6, 4, 14, 10, 2, 9, 3,
17, 4, 16, 14, 6, 2, 3, 10, 4, 9, 14, 17, 6, 16, 3, 4,
2, 14, 10, 6, 9, 16, 17, 9, 17, 10, 16, 2, 6, 3, 14,
4, 10, 9, 2, 17, 3, 16, 4, 6, 14, 2, 10, 3, 9, 4, 17,
14, 16, 6, 3, 2, 4, 10, 14, 9, 6, 17, 16, 4, 3, 14, 2,
6, 10, 16, 9, 17, 14, 4, 6, 3, 16, 2, 17, 10, 9, 6,
14, 16, 4, 17, 3, 9, 2, 10, 16, 6, 17, 14, 9, 4, 10,
3, 2, 17, 16, 9, 6, 10, 14, 2, 4, 3, 4, 5, 15, 3, 11,
7, 10, 17, 18, 5, 3, 4, 7, 15, 17, 11, 18, 10, 3, 7,
5, 17, 4, 18, 15, 10, 11, 7, 17, 3, 18, 5, 10, 4, 11,
15, 17, 18, 7, 10, 3, 11, 5, 15, 4, 18, 10, 17, 11, 7,
15, 3, 4, 5, 10, 11, 18, 15, 17, 4, 7, 5, 3, 11, 15,
10, 4, 18, 5, 17, 3, 7, 15, 4, 11, 5, 10, 3, 18, 7,
17, 18, 17, 10, 7, 11, 3, 15, 5, 4, 10, 18, 11, 17,
15, 7, 4, 3, 5, 11, 10, 15, 18, 4, 17, 5, 7, 3, 15,
11, 4, 10, 5, 18, 3, 17, 7, 4, 15, 5, 11, 3, 10, 7,
18, 17, 5, 4, 3, 15, 7, 11, 17, 10, 18, 3, 5, 7, 4,
17, 15, 18, 11, 10, 7, 3, 17, 5, 18, 4, 10, 15, 11,
17, 7, 18, 3, 10, 5, 11, 4, 15, 16, 8, 6, 18, 12, 10,
4, 11, 5, 8, 18, 16, 10, 6, 11, 12, 5, 4, 18, 10, 8,
11, 16, 5, 6, 4, 12, 10, 11, 18, 5, 8, 4, 16, 12, 6,
11, 5, 10, 4, 18, 12, 8, 6, 16, 5, 4, 11, 12, 10, 6,
18, 16, 8, 4, 12, 5, 6, 11, 16, 10, 8, 18, 12, 6, 4,
16, 5, 8, 11, 18, 10, 6, 16, 12, 8, 4, 18, 5, 10, 11,
5, 11, 4, 10, 12, 18, 6, 8, 16, 4, 5, 12, 11, 6, 10,
16, 18, 8, 12, 4, 6, 5, 16, 11, 8, 10, 18, 6, 12, 16,
4, 8, 5, 18, 11, 10, 16, 6, 8, 12, 18, 4, 10, 5, 11,
8, 16, 18, 6, 10, 12, 11, 4, 5, 18, 8, 10, 16, 11, 6,
5, 12, 4, 10, 18, 11, 8, 5, 16, 4, 6, 12, 11, 10, 5,
18, 4, 8, 12, 16, 6, 13, 17, 6, 9, 5, 1, 7, 11, 12,
17, 9, 13, 1, 6, 11, 5, 12, 7, 9, 1, 17, 11, 13, 12,
6, 7, 5, 1, 11, 9, 12, 17, 7, 13, 5, 6, 11, 12, 1, 7,
9, 5, 17, 6, 13, 12, 7, 11, 5, 1, 6, 9, 13, 17, 7, 5,
12, 6, 11, 13, 1, 17, 9, 5, 6, 7, 13, 12, 17, 11, 9,
1, 6, 13, 5, 17, 7, 9, 12, 1, 11, 12, 11, 7, 1, 5, 9,
6, 17, 13, 7, 12, 5, 11, 6, 1, 13, 9, 17, 5, 7, 6, 12,
13, 11, 17, 1, 9, 6, 5, 13, 7, 17, 12, 9, 11, 1, 13,
6, 17, 5, 9, 7, 1, 12, 11, 17, 13, 9, 6, 1, 5, 11, 7,
12, 9, 17, 1, 13, 11, 6, 12, 5, 7, 1, 9, 11, 17, 12,
13, 7, 6, 5, 11, 1, 12, 9, 7, 17, 5, 13, 6, 7, 8, 12,
18, 14, 10, 13, 2, 6, 8, 18, 7, 10, 12, 2, 14, 6, 13,
18, 10, 8, 2, 7, 6, 12, 13, 14, 10, 2, 18, 6, 8, 13,
7, 14, 12, 2, 6, 10, 13, 18, 14, 8, 12, 7, 6, 13, 2,
14, 10, 12, 18, 7, 8, 13, 14, 6, 12, 2, 7, 10, 8, 18,
14, 12, 13, 7, 6, 8, 2, 18, 10, 12, 7, 14, 8, 13, 18,
6, 10, 2, 6, 2, 13, 10, 14, 18, 12, 8, 7, 13, 6, 14,
2, 12, 10, 7, 18, 8, 14, 13, 12, 6, 7, 2, 8, 10, 18,
12, 14, 7, 13, 8, 6, 18, 2, 10, 7, 12, 8, 14, 18, 13,
10, 6, 2, 8, 7, 18, 12, 10, 14, 2, 13, 6, 18, 8, 10,
7, 2, 12, 6, 14, 13, 10, 18, 2, 8, 6, 7, 13, 12, 14,
2, 10, 6, 18, 13, 8, 14, 7, 12, 7, 2, 8, 9, 5, 1, 4,
6, 3, 2, 9, 7, 1, 8, 6, 5, 3, 4, 9, 1, 2, 6, 7, 3, 8,
4, 5, 1, 6, 9, 3, 2, 4, 7, 5, 8, 6, 3, 1, 4, 9, 5, 2,
8, 7, 3, 4, 6, 5, 1, 8, 9, 7, 2, 4, 5, 3, 8, 6, 7, 1,
2, 9, 5, 8, 4, 7, 3, 2, 6, 9, 1, 8, 7, 5, 2, 4, 9, 3,
1, 6, 3, 6, 4, 1, 5, 9, 8, 2, 7, 4, 3, 5, 6, 8, 1, 7,
9, 2, 5, 4, 8, 3, 7, 6, 2, 1, 9, 8, 5, 7, 4, 2, 3, 9,
6, 1, 7, 8, 2, 5, 9, 4, 1, 3, 6, 2, 7, 9, 8, 1, 5, 6,
4, 3, 9, 2, 1, 7, 6, 8, 3, 5, 4, 1, 9, 6, 2, 3, 7, 4,
8, 5, 6, 1, 3, 9, 4, 2, 5, 7, 8), 216, 9, byrow = T)
} else if (all(williams_D == 9, selection == 100, type == "SR")) {
sequences <- matrix(c(1, 2, 9, 3, 8, 4, 7, 5, 6, 2, 3, 1, 4, 9, 5, 8, 6, 7,
3, 4, 2, 5, 1, 6, 9, 7, 8, 4, 5, 3, 6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 8, 13, 18, 3, 1, 2, 16, 8, 15, 18,
5, 1, 13, 2, 3, 8, 18, 16, 1, 15, 2, 5, 3, 13, 18, 1,
8, 2, 16, 3, 15, 13, 5, 15, 5, 16, 13, 8, 3, 18, 2, 1,
16, 15, 8, 5, 18, 13, 1, 3, 2, 8, 16, 18, 15, 1, 5, 2,
13, 3, 18, 8, 1, 16, 2, 15, 3, 5, 13, 1, 18, 2, 8, 3,
16, 13, 15, 5, 2, 1, 3, 18, 13, 8, 5, 16, 15, 3, 2,
13, 1, 5, 18, 15, 8, 16, 13, 3, 5, 2, 15, 1, 16, 18,
8, 5, 13, 15, 3, 16, 2, 8, 1, 18, 1, 2, 9, 3, 17, 13,
16, 14, 6, 2, 3, 1, 13, 9, 14, 17, 6, 16, 3, 13, 2,
14, 1, 6, 9, 16, 17, 13, 14, 3, 6, 2, 16, 1, 17, 9,
14, 6, 13, 16, 3, 17, 2, 9, 1, 6, 16, 14, 17, 13, 9,
3, 1, 2, 16, 17, 6, 9, 14, 1, 13, 2, 3, 17, 9, 16, 1,
6, 2, 14, 3, 13, 9, 1, 17, 2, 16, 3, 6, 13, 14, 6, 14,
16, 13, 17, 3, 9, 2, 1, 16, 6, 17, 14, 9, 13, 1, 3, 2,
17, 16, 9, 6, 1, 14, 2, 13, 3, 9, 17, 1, 16, 2, 6, 3,
14, 13, 1, 9, 2, 17, 3, 16, 13, 6, 14, 2, 1, 3, 9, 13,
17, 14, 16, 6, 3, 2, 13, 1, 14, 9, 6, 17, 16, 13, 3,
14, 2, 6, 1, 16, 9, 17, 14, 13, 6, 3, 16, 2, 17, 1, 9,
1, 11, 18, 12, 17, 4, 7, 5, 6, 11, 12, 1, 4, 18, 5,
17, 6, 7, 12, 4, 11, 5, 1, 6, 18, 7, 17, 4, 5, 12, 6,
11, 7, 1, 17, 18, 5, 6, 4, 7, 12, 17, 11, 18, 1, 6, 7,
5, 17, 4, 18, 12, 1, 11, 7, 17, 6, 18, 5, 1, 4, 11,
12, 17, 18, 7, 1, 6, 11, 5, 12, 4, 18, 1, 17, 11, 7,
12, 6, 4, 5, 6, 5, 7, 4, 17, 12, 18, 11, 1, 7, 6, 17,
5, 18, 4, 1, 12, 11, 17, 7, 18, 6, 1, 5, 11, 4, 12,
18, 17, 1, 7, 11, 6, 12, 5, 4, 1, 18, 11, 17, 12, 7,
4, 6, 5, 11, 1, 12, 18, 4, 17, 5, 7, 6, 12, 11, 4, 1,
5, 18, 6, 17, 7, 4, 12, 5, 11, 6, 1, 7, 18, 17, 5, 4,
6, 12, 7, 11, 17, 1, 18, 1, 11, 9, 12, 8, 4, 7, 14,
15, 11, 12, 1, 4, 9, 14, 8, 15, 7, 12, 4, 11, 14, 1,
15, 9, 7, 8, 4, 14, 12, 15, 11, 7, 1, 8, 9, 14, 15, 4,
7, 12, 8, 11, 9, 1, 15, 7, 14, 8, 4, 9, 12, 1, 11, 7,
8, 15, 9, 14, 1, 4, 11, 12, 8, 9, 7, 1, 15, 11, 14,
12, 4, 9, 1, 8, 11, 7, 12, 15, 4, 14, 15, 14, 7, 4, 8,
12, 9, 11, 1, 7, 15, 8, 14, 9, 4, 1, 12, 11, 8, 7, 9,
15, 1, 14, 11, 4, 12, 9, 8, 1, 7, 11, 15, 12, 14, 4,
1, 9, 11, 8, 12, 7, 4, 15, 14, 11, 1, 12, 9, 4, 8, 14,
7, 15, 12, 11, 4, 1, 14, 9, 15, 8, 7, 4, 12, 14, 11,
15, 1, 7, 9, 8, 14, 4, 15, 12, 7, 11, 8, 1, 9, 1, 11,
9, 12, 17, 13, 16, 5, 15, 11, 12, 1, 13, 9, 5, 17, 15,
16, 12, 13, 11, 5, 1, 15, 9, 16, 17, 13, 5, 12, 15,
11, 16, 1, 17, 9, 5, 15, 13, 16, 12, 17, 11, 9, 1, 15,
16, 5, 17, 13, 9, 12, 1, 11, 16, 17, 15, 9, 5, 1, 13,
11, 12, 17, 9, 16, 1, 15, 11, 5, 12, 13, 9, 1, 17, 11,
16, 12, 15, 13, 5, 15, 5, 16, 13, 17, 12, 9, 11, 1,
16, 15, 17, 5, 9, 13, 1, 12, 11, 17, 16, 9, 15, 1, 5,
11, 13, 12, 9, 17, 1, 16, 11, 15, 12, 5, 13, 1, 9, 11,
17, 12, 16, 13, 15, 5, 11, 1, 12, 9, 13, 17, 5, 16,
15, 12, 11, 13, 1, 5, 9, 15, 17, 16, 13, 12, 5, 11,
15, 1, 16, 9, 17, 5, 13, 15, 12, 16, 11, 17, 1, 9, 1,
11, 18, 12, 8, 13, 16, 14, 6, 11, 12, 1, 13, 18, 14,
8, 6, 16, 12, 13, 11, 14, 1, 6, 18, 16, 8, 13, 14, 12,
6, 11, 16, 1, 8, 18, 14, 6, 13, 16, 12, 8, 11, 18, 1,
6, 16, 14, 8, 13, 18, 12, 1, 11, 16, 8, 6, 18, 14, 1,
13, 11, 12, 8, 18, 16, 1, 6, 11, 14, 12, 13, 18, 1, 8,
11, 16, 12, 6, 13, 14, 6, 14, 16, 13, 8, 12, 18, 11,
1, 16, 6, 8, 14, 18, 13, 1, 12, 11, 8, 16, 18, 6, 1,
14, 11, 13, 12, 18, 8, 1, 16, 11, 6, 12, 14, 13, 1,
18, 11, 8, 12, 16, 13, 6, 14, 11, 1, 12, 18, 13, 8,
14, 16, 6, 12, 11, 13, 1, 14, 18, 6, 8, 16, 13, 12,
14, 11, 6, 1, 16, 18, 8, 14, 13, 6, 12, 16, 11, 8, 1,
18, 10, 2, 18, 12, 8, 4, 16, 5, 6, 2, 12, 10, 4, 18,
5, 8, 6, 16, 12, 4, 2, 5, 10, 6, 18, 16, 8, 4, 5, 12,
6, 2, 16, 10, 8, 18, 5, 6, 4, 16, 12, 8, 2, 18, 10, 6,
16, 5, 8, 4, 18, 12, 10, 2, 16, 8, 6, 18, 5, 10, 4, 2,
12, 8, 18, 16, 10, 6, 2, 5, 12, 4, 18, 10, 8, 2, 16,
12, 6, 4, 5, 6, 5, 16, 4, 8, 12, 18, 2, 10, 16, 6, 8,
5, 18, 4, 10, 12, 2, 8, 16, 18, 6, 10, 5, 2, 4, 12,
18, 8, 10, 16, 2, 6, 12, 5, 4, 10, 18, 2, 8, 12, 16,
4, 6, 5, 2, 10, 12, 18, 4, 8, 5, 16, 6, 12, 2, 4, 10,
5, 18, 6, 8, 16, 4, 12, 5, 2, 6, 10, 16, 18, 8, 5, 4,
6, 12, 16, 2, 8, 10, 18, 10, 2, 9, 12, 17, 4, 16, 14,
15, 2, 12, 10, 4, 9, 14, 17, 15, 16, 12, 4, 2, 14, 10,
15, 9, 16, 17, 4, 14, 12, 15, 2, 16, 10, 17, 9, 14,
15, 4, 16, 12, 17, 2, 9, 10, 15, 16, 14, 17, 4, 9, 12,
10, 2, 16, 17, 15, 9, 14, 10, 4, 2, 12, 17, 9, 16, 10,
15, 2, 14, 12, 4, 9, 10, 17, 2, 16, 12, 15, 4, 14, 15,
14, 16, 4, 17, 12, 9, 2, 10, 16, 15, 17, 14, 9, 4, 10,
12, 2, 17, 16, 9, 15, 10, 14, 2, 4, 12, 9, 17, 10, 16,
2, 15, 12, 14, 4, 10, 9, 2, 17, 12, 16, 4, 15, 14, 2,
10, 12, 9, 4, 17, 14, 16, 15, 12, 2, 4, 10, 14, 9, 15,
17, 16, 4, 12, 14, 2, 15, 10, 16, 9, 17, 14, 4, 15,
12, 16, 2, 17, 10, 9, 10, 2, 9, 12, 8, 13, 7, 5, 15,
2, 12, 10, 13, 9, 5, 8, 15, 7, 12, 13, 2, 5, 10, 15,
9, 7, 8, 13, 5, 12, 15, 2, 7, 10, 8, 9, 5, 15, 13, 7,
12, 8, 2, 9, 10, 15, 7, 5, 8, 13, 9, 12, 10, 2, 7, 8,
15, 9, 5, 10, 13, 2, 12, 8, 9, 7, 10, 15, 2, 5, 12,
13, 9, 10, 8, 2, 7, 12, 15, 13, 5, 15, 5, 7, 13, 8,
12, 9, 2, 10, 7, 15, 8, 5, 9, 13, 10, 12, 2, 8, 7, 9,
15, 10, 5, 2, 13, 12, 9, 8, 10, 7, 2, 15, 12, 5, 13,
10, 9, 2, 8, 12, 7, 13, 15, 5, 2, 10, 12, 9, 13, 8, 5,
7, 15, 12, 2, 13, 10, 5, 9, 15, 8, 7, 13, 12, 5, 2,
15, 10, 7, 9, 8, 5, 13, 15, 12, 7, 2, 8, 10, 9, 10, 2,
18, 12, 17, 13, 7, 14, 6, 2, 12, 10, 13, 18, 14, 17,
6, 7, 12, 13, 2, 14, 10, 6, 18, 7, 17, 13, 14, 12, 6,
2, 7, 10, 17, 18, 14, 6, 13, 7, 12, 17, 2, 18, 10, 6,
7, 14, 17, 13, 18, 12, 10, 2, 7, 17, 6, 18, 14, 10,
13, 2, 12, 17, 18, 7, 10, 6, 2, 14, 12, 13, 18, 10,
17, 2, 7, 12, 6, 13, 14, 6, 14, 7, 13, 17, 12, 18, 2,
10, 7, 6, 17, 14, 18, 13, 10, 12, 2, 17, 7, 18, 6, 10,
14, 2, 13, 12, 18, 17, 10, 7, 2, 6, 12, 14, 13, 10,
18, 2, 17, 12, 7, 13, 6, 14, 2, 10, 12, 18, 13, 17,
14, 7, 6, 12, 2, 13, 10, 14, 18, 6, 17, 7, 13, 12, 14,
2, 6, 10, 7, 18, 17, 14, 13, 6, 12, 7, 2, 17, 10, 18,
10, 11, 9, 3, 17, 4, 16, 5, 6, 11, 3, 10, 4, 9, 5, 17,
6, 16, 3, 4, 11, 5, 10, 6, 9, 16, 17, 4, 5, 3, 6, 11,
16, 10, 17, 9, 5, 6, 4, 16, 3, 17, 11, 9, 10, 6, 16,
5, 17, 4, 9, 3, 10, 11, 16, 17, 6, 9, 5, 10, 4, 11, 3,
17, 9, 16, 10, 6, 11, 5, 3, 4, 9, 10, 17, 11, 16, 3,
6, 4, 5, 6, 5, 16, 4, 17, 3, 9, 11, 10, 16, 6, 17, 5,
9, 4, 10, 3, 11, 17, 16, 9, 6, 10, 5, 11, 4, 3, 9, 17,
10, 16, 11, 6, 3, 5, 4, 10, 9, 11, 17, 3, 16, 4, 6, 5,
11, 10, 3, 9, 4, 17, 5, 16, 6, 3, 11, 4, 10, 5, 9, 6,
17, 16, 4, 3, 5, 11, 6, 10, 16, 9, 17, 5, 4, 6, 3, 16,
11, 17, 10, 9, 10, 11, 18, 3, 8, 4, 16, 14, 15, 11, 3,
10, 4, 18, 14, 8, 15, 16, 3, 4, 11, 14, 10, 15, 18,
16, 8, 4, 14, 3, 15, 11, 16, 10, 8, 18, 14, 15, 4, 16,
3, 8, 11, 18, 10, 15, 16, 14, 8, 4, 18, 3, 10, 11, 16,
8, 15, 18, 14, 10, 4, 11, 3, 8, 18, 16, 10, 15, 11,
14, 3, 4, 18, 10, 8, 11, 16, 3, 15, 4, 14, 15, 14, 16,
4, 8, 3, 18, 11, 10, 16, 15, 8, 14, 18, 4, 10, 3, 11,
8, 16, 18, 15, 10, 14, 11, 4, 3, 18, 8, 10, 16, 11,
15, 3, 14, 4, 10, 18, 11, 8, 3, 16, 4, 15, 14, 11, 10,
3, 18, 4, 8, 14, 16, 15, 3, 11, 4, 10, 14, 18, 15, 8,
16, 4, 3, 14, 11, 15, 10, 16, 18, 8, 14, 4, 15, 3, 16,
11, 8, 10, 18, 10, 11, 18, 3, 17, 13, 7, 5, 15, 11, 3,
10, 13, 18, 5, 17, 15, 7, 3, 13, 11, 5, 10, 15, 18, 7,
17, 13, 5, 3, 15, 11, 7, 10, 17, 18, 5, 15, 13, 7, 3,
17, 11, 18, 10, 15, 7, 5, 17, 13, 18, 3, 10, 11, 7,
17, 15, 18, 5, 10, 13, 11, 3, 17, 18, 7, 10, 15, 11,
5, 3, 13, 18, 10, 17, 11, 7, 3, 15, 13, 5, 15, 5, 7,
13, 17, 3, 18, 11, 10, 7, 15, 17, 5, 18, 13, 10, 3,
11, 17, 7, 18, 15, 10, 5, 11, 13, 3, 18, 17, 10, 7,
11, 15, 3, 5, 13, 10, 18, 11, 17, 3, 7, 13, 15, 5, 11,
10, 3, 18, 13, 17, 5, 7, 15, 3, 11, 13, 10, 5, 18, 15,
17, 7, 13, 3, 5, 11, 15, 10, 7, 18, 17, 5, 13, 15, 3,
7, 11, 17, 10, 18, 10, 11, 9, 3, 8, 13, 7, 14, 6, 11,
3, 10, 13, 9, 14, 8, 6, 7, 3, 13, 11, 14, 10, 6, 9, 7,
8, 13, 14, 3, 6, 11, 7, 10, 8, 9, 14, 6, 13, 7, 3, 8,
11, 9, 10, 6, 7, 14, 8, 13, 9, 3, 10, 11, 7, 8, 6, 9,
14, 10, 13, 11, 3, 8, 9, 7, 10, 6, 11, 14, 3, 13, 9,
10, 8, 11, 7, 3, 6, 13, 14, 6, 14, 7, 13, 8, 3, 9, 11,
10, 7, 6, 8, 14, 9, 13, 10, 3, 11, 8, 7, 9, 6, 10, 14,
11, 13, 3, 9, 8, 10, 7, 11, 6, 3, 14, 13, 10, 9, 11,
8, 3, 7, 13, 6, 14, 11, 10, 3, 9, 13, 8, 14, 7, 6, 3,
11, 13, 10, 14, 9, 6, 8, 7, 13, 3, 14, 11, 6, 10, 7,
9, 8, 14, 13, 6, 3, 7, 11, 8, 10, 9), 288, 9,
byrow = T)
}
D <- length(unique(as.vector(sequences)))
if (!missing(labels)) {
check_labels(labels, D)
} else {
labels <- 0:(D - 1)
}
sequences <- convert_labels(sequences, D, labels, 1:D)
sequences <- transform_to_xover(sequences, labels, as_matrix)
##### Outputting #############################################################
return(sequences)
}
|
7bf416a6179abd388fb53100d6e99930455a448c
|
ee9287f407efab94c3a598916d4e92777eb55143
|
/R/documentation.R
|
ac0dbe0056db81d1e15b287df51eca5ee99a3d1d
|
[] |
no_license
|
jarretrt/tci
|
fc8dae33f9aa73f505cf96cb513ef2665015e889
|
23fb6a721a277709eb351ce5f7e60daed9f9fafb
|
refs/heads/master
| 2023-01-24T22:55:32.769055
| 2023-01-18T01:33:04
| 2023-01-18T01:33:04
| 217,107,508
| 3
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 809
|
r
|
documentation.R
|
#' tci package documentation
#' @title tci_documentation
#' @name tci_documentation
#' @description Functions to implement target-controlled infusion algorithms
#' @details This package contains functions to implement target-controlled
#' infusion (TCI) algorithms for compartmental PK models under intravenous administration.
#' TCI algorithms for plasma or effect-site targeting are included and can be
#' extended to pharmacodynamic responses. Custom PK-PD models and custom TCI
#' algorithms can be specified. Functions are provided to simulate responses from
#' PK/PK-PD models under open- or closed-loop control.
## usethis namespace: start
#' @useDynLib tci, .registration = TRUE
## usethis namespace: end
NULL
## usethis namespace: start
#' @importFrom Rcpp sourceCpp
## usethis namespace: end
NULL
|
20e83fc12719052179fc1e488714d8408b4cd34e
|
06196479af789edf48792949519336743ee442b8
|
/R/util_style.R
|
7ab2dabcb10905039ed43224e62d4f11cb54c532
|
[
"MIT"
] |
permissive
|
jeksterslabds/jeksterslabRutils
|
c35a33eda24ad28cd9722fcf77c5338a89a44d55
|
4410e7d512b41aa678dcfaf9611d3be3b683a33d
|
refs/heads/master
| 2021-08-10T07:01:43.903835
| 2021-01-15T06:12:54
| 2021-01-15T06:12:54
| 241,089,145
| 0
| 1
|
NOASSERTION
| 2020-02-17T11:41:04
| 2020-02-17T11:17:31
| null |
UTF-8
|
R
| false
| false
| 2,522
|
r
|
util_style.R
|
#' Style `R` and `R` Markdown Files
#'
#' Styles all `R` scripts and `R` Markdown files
#' in a given directory.
#'
#' @author Ivan Jacob Agaloos Pesigan
#' @inheritParams util_lapply
#' @param dir Character string.
#' Directory.
#' @param recursive Logical.
#' If `TRUE`,
#' recursively style all `R` scripts (`.R`, `.r`) and
#' R Markdown files (`.Rmd`, `.rmd`) in `dir`.
#' @param files Character vector.
#' Vector of files to style.
#' @examples
#' \dontrun{
#' util_style(
#' dir = getwd(),
#' par = FALSE
#' )
#' }
#' @importFrom styler style_file
#' @export
###############################################
# Identical function structure to util_render
###############################################
util_style <- function(dir = getwd(),
recursive = FALSE,
files = NULL,
par = TRUE,
ncores = NULL) {
foo_exists <- function(file) {
if (file.exists(file)) {
return(file)
} else {
return(NA)
}
}
foo_style <- function(file) {
tryCatch(
{
style_file(file)
},
error = function(err) {
warning(
paste(
"Error styling",
file
)
)
}
)
}
foo_go <- function(files) {
if (length(files) == 0 | all(is.na(files))) {
return(FALSE)
} else {
return(TRUE)
}
}
message <- "No files to style."
dir <- normalizePath(dir)
if (is.null(files)) {
# populate files
files <- util_search_r(
dir = dir,
rscript = TRUE,
rmd = TRUE,
all.files = FALSE,
full.names = TRUE,
recursive = recursive,
ignore.case = TRUE,
no.. = FALSE
)
} else {
# files > 0 check if files exist
if (foo_go(files)) {
# check if file in files exists
files <- invisible(
util_lapply(
FUN = foo_exists,
args = list(
file = files
),
par = par,
ncores = ncores
)
)
} else {
message(message)
}
# if some file/s exist retain only non NA
if (foo_go(files)) {
# retain non NA
files <- files[!is.na(files)]
} else {
message(message)
}
}
# style if files > 0
if (foo_go(files)) {
# style
invisible(
util_lapply(
FUN = foo_style,
args = list(
file = files
),
par = par,
ncores = ncores
)
)
} else {
message(message)
}
}
|
9e7c2478c6a1fe0a0d99505a05ae9509066788f4
|
77ef73c072c75fc92d313d404fa1b6df50a53e40
|
/R/cyto_map.R
|
5abfead6a34d37deaf493c0bcefd16ed5cafcaa6
|
[] |
no_license
|
DillonHammill/CytoExploreR
|
8eccabf1d761c29790c1d5c1921e1bd7089d9e09
|
0efb1cc19fc701ae03905cf1b8484c1dfeb387df
|
refs/heads/master
| 2023-08-17T06:31:48.958379
| 2023-02-28T09:31:08
| 2023-02-28T09:31:08
| 214,059,913
| 60
| 17
| null | 2020-08-12T11:41:37
| 2019-10-10T01:35:16
|
R
|
UTF-8
|
R
| false
| false
| 21,441
|
r
|
cyto_map.R
|
## CYTO_MAP --------------------------------------------------------------------
#' Create dimension-reduced maps of cytometry data
#'
#' \code{cyto_map} is a convenient wrapper to produce dimension-reduced maps of
#' cytometry data using PCA, tSNE, FIt-SNE, UMAP and EmbedSOM. These
#' dimensionality reduction functions are called using the default settings, but
#' can be altered by passing relvant arguments through \code{cyto_map}. To see a
#' full list of customisable parameters refer to the documentation for each of
#' these functions by clicking on the links below.
#'
#' If you use \code{cyto_map} to map your cytometry data, be sure to cite the
#' publication that describes the dimensionality reduction algorithm that you
#' have chosen to use. References to these publications can be found in the
#' references section of this document.
#'
#' @param x object of class \code{flowFrame} or \code{flowSet}.
#' @param parent name of the parent population to extract from
#' \code{GatingHierarchy} or \code{GatingSet} objects for mapping, set to the
#' \code{"root"} node by default.
#' @param select designates which samples should be used for mapping when a
#' \code{flowSet} or \code{GatingSet} object is supplied. Filtering steps
#' should be comma separated and wrapped in a list. Refer to
#' \code{\link{cyto_select}}.
#' @param channels vector of channels names indicating the channels that should
#' be used by the dimension reduction algorithm to compute the 2-dimensional
#' map, set to all channels with assigned markers by default. Restricting the
#' number of channels can greatly improve processing speed and resolution.
#' @param display total number of events to map, all events in the combined data
#' are mapped by default.
#' @param merge_by vector of experimental variables to split and merge samples
#' into groups prior to mapping, set to "all" by default to create a single
#' consensus map.
#' @param type dimension reduction type to use to generate the map, supported
#' options include "PCA", "tSNE", "FIt-SNE", "UMAP" and "EmbedSOM". Users can
#' also supply the name of a function to perform custom mappings.
#' @param split logical indicating whether samples merged using
#' \code{cyto_merge_by} should be split prior to writing fcs files, set to
#' FALSE by default.
#' @param names original names of the samples prior to merging using
#' \code{cyto_merge_by}, only required when split is TRUE. These names will be
#' re-assigned to each of split flowFrames and included in the file names.
#' @param save_as passed to \code{cyto_save} to indicate a folder where the
#' mapped FCS files should be saved, set to NULL by default to turn off saving
#' of FCS files.
#' @param inverse logical indicating whether the data should be inverse
#' transformed prior to writing FCS files, set to FALSE by default. Inverse
#' transformations of \code{flowFrame} or \code{flowSet} objects requires
#' passing of transformers through the \code{trans} argument.
#' @param trans object of class \code{transformerList} containing the
#' transformation definitions applied to the supplied data. Used internally
#' when \code{inverse_transform} is TRUE, to inverse the transformations prior
#' to writing FCS files.
#' @param plot logical indicating whether the constructed map should be plotted
#' using \code{cyto_plot}.
#' @param seed integer to set seed prior to mapping to ensure more consistent
#' results between runs.
#' @param ... additional arguments passed to the called dimension reduction
#' function. Links to the documentation for these functions can be found
#' below.
#'
#' @return flowFrame, flowSet, GatingHierarchy or GatingSet containing the
#' mapped projection parameters.
#'
#' @importFrom flowCore exprs keyword write.FCS flowSet fr_append_cols
#' @importFrom flowWorkspace GatingSet gs_cyto_data<- flowSet_to_cytoset
#' recompute flowFrame_to_cytoframe cytoset gs_cyto_data cf_append_cols
#' @importFrom rsvd rpca
#' @importFrom Rtsne Rtsne
#' @importFrom umap umap
#' @importFrom EmbedSOM SOM EmbedSOM
#'
#' @seealso \code{\link[rsvd:rpca]{PCA}}
#' @seealso \code{\link[Rtsne:Rtsne]{tSNE}}
#' @seealso \code{\link{fftRtsne}}
#' @seealso \code{\link[umap:umap]{UMAP}}
#' @seealso \code{\link[EmbedSOM:SOM]{SOM}}
#' @seealso \code{\link[EmbedSOM:EmbedSOM]{EmbedSOM}}
#'
#' @references N. B. Erichson, S. Voronin, S. L. Brunton and J. N. Kutz. 2019.
#' Randomized Matrix Decompositions Using {R}. Journal of Statistical
#' Software, 89(11), 1-48. \url{http://doi.org/10.18637/jss.v089.i11}.
#' @references N. Halko, P. Martinsson, and J. Tropp. "Finding structure with
#' randomness: probabilistic algorithms for constructing approximate matrix
#' decompositions" (2009). (available at arXiv
#' \url{http://arxiv.org/abs/0909.4061}).
#' @references Gabriel K. (1971). The biplot graphical display of matrices with
#' application to principal component analysis. Biometrika 58, 453–467.
#' \url{doi:10.1093/biomet/58.3.453}.
#' @references Maaten, L. van der, & Hinton, G. (2008). Visualizing Data using
#' t-SNE. Journal of Machine Learning Research 9, 2579–2605.
#' \url{http://www.jmlr.org/papers/volume9/vandermaaten08a/}.
#' @references Linderman, G., Rachh, M., Hoskins, J., Steinerberger, S.,
#' Kluger., Y. (2019). Fast interpolation-based t-SNE for improved
#' visualization of single-cell RNA-seq data. Nature Methods.
#' \url{https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6402590/}.
#' @references McInnes, L., & Healy, J. (2018). UMAP: uniform manifold
#' approximation and projection for dimension reduction. Preprint at
#' \url{https://arxiv.org/abs/1802.03426}.
#' @references Kratochvíl, M., Koladiya, A., Balounova, J., Novosadova, V.,
#' Fišer, K., Sedlacek, R., Vondrášek, J., and Drbal, K. (2018). Rapid
#' single-cell cytometry data visualization with EmbedSOM. Preprint at
#' \url{https://www.biorxiv.org/content/10.1101/496869v1}.
#'
#' @author Dillon Hammill, \email{Dillon.Hammill@anu.edu.au}
#'
#' @name cyto_map
NULL
#' @rdname cyto_map
#' @export
cyto_map <- function(x, ...) {
UseMethod("cyto_map")
}
#' @rdname cyto_map
#' @export
cyto_map.GatingSet <- function(x,
parent = "root",
select = NULL,
channels = NULL,
display = 1,
type = "UMAP",
merge_by = "all",
split = TRUE,
names = NULL,
save_as = NULL,
inverse = FALSE,
trans = NULL,
plot = TRUE,
seed = NULL,
...) {
# SELECT DATA (VIEW)
if (!is.null(select)) {
x <- cyto_select(x, select)
}
# CLONE GATINGSET VIEW
gs_copy <- cyto_copy(x)
# TRANSFORMERS
if (is.null(trans)) {
trans <- cyto_transformer_extract(gs_copy)
}
# NAMES - ALL NAMES INCLUDING EMPTY PARENT
gs_names <- cyto_names(gs_copy)
# REMOVE EMPTY PARENTS
gs_counts <- cyto_stats_compute(gs_copy,
alias = parent,
stat = "count"
)
gs_clone <- gs_copy[which(gs_counts[, ncol(gs_counts)] != 0)]
# GROUP_BY
gs_list <- cyto_group_by(gs_clone, group_by = merge_by)
# NAMES
if (is.null(names)) {
names <- lapply(gs_list, "cyto_names")
} else {
names <- split(names, rep(seq_along(gs_list), LAPPLY(gs_list, "length")))
}
# MAPPING FUNCTION
if(is.function(type)){
cyto_map_fun <- as.character(substitute(type))
cyto_map_fun <- cyto_map_fun[length(cyto_map_fun)]
}else{
cyto_map_fun <- type
}
# LOOP THROUGH GATINGSETS - RETURN LIST OF FLOWSETS
cyto_data <- lapply(seq_along(gs_list), function(z) {
# GATINGSET
gs <- gs_list[[z]]
# EXTRACT FLOWSET
fs <- cyto_extract(gs, parent = parent)
# MERGE TO FLOWFRAME
fr <- cyto_merge_by(fs, merge_by = "all")[[1]]
# MAPPING - RETURNS MERGED FLOWFRAME & SAVES FILES
cyto_data <- cyto_map(fr,
channels = channels,
display = display,
type = type,
split = split,
names = names[[z]],
save_as = save_as,
inverse = inverse,
trans = trans,
plot = FALSE,
seed = seed,
cyto_map_fun = cyto_map_fun, ...
)
# SPLIT - LIST OF FLOWFRAMES
cyto_data <- cyto_split(cyto_data, names = names[[z]])
# CONVERT FLOWFRAME LIST TO FLOWSET
return(flowSet_to_cytoset(flowSet(cyto_data)))
})
# COMBINE FLOWSETS
cyto_data <- do.call("rbind2", cyto_data)
# MAPPED CHANNELS
cyto_data_channels <- cyto_channels(cyto_data)
# MAPPED FILE NAMES
cyto_data_names <- cyto_names(cyto_data)
# COMPLETE CYTO_DATA
gs_cyto_data <- as.list(cyto_names(gs_copy))
names(gs_cyto_data) <- cyto_names(gs_copy)
lapply(seq_along(gs_cyto_data), function(z) {
if (names(gs_cyto_data)[z] %in% cyto_data_names) {
ind <- match(names(gs_cyto_data)[z], cyto_data_names)
gs_cyto_data[[z]] <<- cyto_data[[ind]]
} else {
# EMPTY FILE
gs_cyto_data[[z]] <<- cyto_empty(
names(gs_cyto_data)[z],
cyto_data_channels
)
}
})
lapply(seq_along(gs_cyto_data), function(z) {
cf <- gs_cyto_data[[z]]
if (class(cf) == "flowFrame") {
cf <- flowFrame_to_cytoframe(gs_cyto_data[[z]])
}
cyto_names(cf) <- names(gs_cyto_data)[z]
gs_cyto_data[[z]] <<- cf
})
gs_cyto_data <- cytoset(gs_cyto_data)
cyto_details(gs_cyto_data) <- cyto_details(gs_copy)
gs_cyto_data(gs_copy) <- gs_cyto_data
# RECOMPUTE STATISTICS
suppressMessages(recompute(gs_copy))
# UPDATE GROUPING
gs_list <- cyto_group_by(gs_copy,
group_by = merge_by
)
# PLOT MAPPING PER GROUP (ONE PLOT PER PAGE)
if (plot == TRUE) {
lapply(seq_along(gs_list), function(z) {
# GATINGSET
gs <- gs_list[[z]]
# OVERLAY
overlay <- tryCatch(gh_pop_get_descendants(gs[[1]],
parent,
path = "auto"
),
error = function(e) {
NA
}
)
# LEGEND
if (!.all_na(overlay)) {
legend <- TRUE
} else {
legend <- FALSE
}
# TITLE
if (names(gs_list)[z] == "all") {
title <- paste0("Combined Events", "\n", cyto_map_fun)
} else {
title <- paste0(names(gs_list)[z], "\n", cyto_map_fun)
}
# POINT_COL - FADE BASE LAYER (OVERLAY)
if (!.all_na(overlay)) {
point_col <- "grey"
} else {
point_col <- NA
}
# CYTO_PLOT DESCENDANTS
tryCatch(cyto_plot(gs,
parent = parent,
channels = cyto_channels(gs, select = cyto_map_fun),
overlay = overlay,
group_by = "all",
display = display,
title = title,
legend = legend,
point_col = point_col
),
error = function(e) {
if (e$message == "figure margins too large") {
message("Insufficient plotting space, data mapped successfully.")
}
}
)
})
}
# RETURN SPLIT MAPPED FLOWFRAMES
return(gs_copy)
}
#' @rdname cyto_map
#' @export
cyto_map.flowSet <- function(x,
select = NULL,
channels = NULL,
display = 1,
type = "UMAP",
merge_by = "all",
split = TRUE,
names = NULL,
save_as = NULL,
inverse = FALSE,
trans = NULL,
plot = TRUE,
seed = NULL,
...) {
# SELECT SAMPLES
if (!is.null(select)) {
x <- cyto_select(x, select)
}
# COPY
fs_copy <- cyto_copy(x)
# NAMES - ALL NAMES NCLUDING EMPTY
fs_names <- cyto_names(fs_copy)
# REMOVE EMPTY FLOWFRAMES
fs_counts <- cyto_stats_compute(fs_copy,
stat = "count"
)
fs_clone <- fs_copy[which(fs_counts[, ncol(fs_counts)] != 0)]
# GROUP_BY
fs_list <- cyto_group_by(x, group_by = merge_by)
# NAMES
if (is.null(names)) {
names <- lapply(fs_list, "cyto_names")
} else {
names <- split(names, rep(seq_along(fs_list), LAPPLY(fs_list, "length")))
}
# MAPPING FUNCTION
if(is.function(type)){
cyto_map_fun <- as.character(substitute(type))
cyto_map_fun <- cyto_map_fun[length(cyto_map_fun)]
}else{
cyto_map_fun <- type
}
# LOOP THROUGH FLOWSETS - RETURN LIST OF FLOWSETS
cyto_data <- lapply(seq_along(fs_list), function(z) {
# FLOWSET
fs <- fs_list[[z]]
# MERGE TO FLOWFRAME
fr <- cyto_merge_by(fs, merge_by = "all")[[1]]
# MAPPING - RETURNS MERGED FLOWFRAME & SAVES FILES
cyto_data <- cyto_map(fr,
channels = channels,
display = display,
type = type,
split = split,
names = names[[z]],
save_as = save_as,
inverse = inverse,
trans = trans,
plot = plot,
seed = seed,
cyto_map_fun = cyto_map_fun,
...
)
# SPLIT - LIST OF FLOWFRAMES
cyto_data <- cyto_split(cyto_data, names = names[[z]])
# CONVERT FLOWFRAME LIST TO FLOWSET
return(flowSet_to_cytoset(flowSet(cyto_data)))
})
# COMBINE FLOWSETS
cyto_data <- do.call("rbind2", cyto_data)
# MAPPED FILE NAMES
cyto_data_names <- cyto_names(cyto_data)
# MAPPED CHANNELS
cyto_data_channels <- cyto_channels(cyto_data)
# COMPLETE CYTO_DATA
fs_cyto_data <- as.list(cyto_names(fs_copy))
names(fs_cyto_data) <- cyto_names(fs_copy)
lapply(seq_along(fs_cyto_data), function(z) {
if (names(fs_cyto_data)[z] %in% cyto_data_names) {
ind <- match(names(fs_cyto_data)[z], cyto_data_names)
fs_cyto_data[[z]] <<- cyto_data[[ind]]
} else {
# EMPTY FILE
fs_cyto_data[[z]] <<- cyto_empty(
names(fs_cyto_data)[z],
cyto_data_channels
)
}
})
lapply(seq_along(fs_cyto_data), function(z) {
cf <- fs_cyto_data[[z]]
if (class(cf) == "flowFrame") {
cf <- flowFrame_to_cytoframe(fs_cyto_data[[z]])
}
cyto_names(cf) <- names(fs_cyto_data)[z]
fs_cyto_data[[z]] <<- cf
})
fs_cyto_data <- cytoset(fs_cyto_data)
cyto_details(fs_cyto_data) <- cyto_details(fs_copy)
cyto_names(fs_cyto_data) <- cyto_names(fs_copy)
# RETURN MAPPED DATA
return(fs_cyto_data)
}
#' @rdname cyto_map
#' @export
cyto_map.flowFrame <- function(x,
channels = NULL,
display = 1,
type = "UMAP",
split = TRUE,
names = NULL,
save_as = NULL,
inverse = FALSE,
trans = NULL,
plot = TRUE,
seed = NULL,
...) {
# CHANNELS -------------------------------------------------------------------
# PREPARE CHANNELS
if (is.null(channels)) {
channels <- cyto_channels(x,
exclude = c(
"Time",
"Original",
"Sample ID",
"Event ID",
"PCA",
"tSNE",
"FIt-SNE",
"UMAP",
"EmbedSOM"
)
)
channels <- channels[channels %in% names(cyto_markers(x))]
}
# CONVERT CHANNELS
channels <- cyto_channels_extract(x,
channels = channels,
plot = FALSE
)
# PREPARE DATA ---------------------------------------------------------------
# PREPARE DATA - SAMPLING
x <- cyto_sample(x,
display = display,
seed = 56
)
# EXTRACT RAW DATA MATRIX
fr_exprs <- cyto_extract(x, raw = TRUE)[[1]]
# RESTRICT MATRIX BY CHANNELS
fr_exprs <- fr_exprs[, channels]
# PREPARE ARGUMENTS ----------------------------------------------------------
# ARGUMENTS
args <- .args_list(...)
# MAPPING FUNCTION
if("cyto_map_fun" %in% names(args)){
cyto_map_fun <- args[["cyto_map_fun"]]
}else{
if(is.function(type)){
cyto_map_fun <- as.character(substitute(type))
cyto_map_fun <- cyto_map_fun[length(cyto_map_fun)]
}else{
cyto_map_fun <- type
}
}
# ADD CYTO_MAP_FUN TO ARGS
args[["cyto_map_fun"]] <- cyto_map_fun
# REMOVE EXCESS ARGUMENTS
cyto_map_args <- formalArgs(cyto_map.flowFrame)
cyto_map_args <- cyto_map_args[!cyto_map_args %in% c("type",
"seed",
"cyto_map_fun")]
args <- args[!names(args) %in% cyto_map_args]
# RENAME FR_EXPRS TO X
names(args)[match("fr_exprs", names(args))] <- "x"
# MAPPING --------------------------------------------------------------------
# MAPPPING COORDS
coords <- do.call(".cyto_map", args)
# ADD MAPPING COORDS TO FLOWFRAME
if(class(x) == "flowFrame") {
x <- fr_append_cols(x, coords)
} else {
x <- cf_append_cols(x, coords)
}
# VISUALISATION --------------------------------------------------------------
# CYTO_PLOT - MAP
if (plot == TRUE) {
tryCatch(cyto_plot(x,
channels = colnames(coords),
title = paste0("Combined Events", "\n", cyto_map_fun)
),
error = function(e) {
if (e$message == "figure margins too large") {
message("Insufficient plotting space, data mapped successfully.")
}
}
)
}
# SAVE MAPPED SAMPLES --------------------------------------------------------
# CYTO_SAVE - INVERSE TRANSFORMS ONLY APPLIED FOR SAVING
if (!is.null(save_as)) {
cyto_save(x,
split = FALSE,
names = names,
save_as = save_as,
inverse = inverse,
trans = trans
)
}
# RESET CYTO_PLOT_MAP
options("cyto_plot_map" = NULL)
# RETURN MAPPED FLOWFRAME ----------------------------------------------------
return(x)
}
## INTERNAL MAPPING FUNCTION ---------------------------------------------------
#' Obtain dimension-reduced co-ordinates
#' @param x matrix containing the data to be mapped.
#' @noRd
.cyto_map <- function(x,
type = "UMAP",
seed = NULL,
cyto_map_fun = NULL,
...) {
# SET SEED - RETURN SAME MAP WITH EACH RUN
if (!is.null(seed)) {
set.seed(seed)
}
# ARGUMENTS
args <- .args_list(...)
args <- args[-match(c("type", "seed", "cyto_map_fun"), names(args))]
# MAPPING FUNCTION
if(is.null(cyto_map_fun)){
if(is.function(type)){
cyto_map_fun <- as.character(substitute(type))
cyto_map_fun <- cyto_map_fun[length(cyto_map_fun)]
}else{
cyto_map_fun <- type
}
}
# CHARACTER
if (is.character(type)) {
# MESSAGE
message(paste0("Computing ", type, " co-ordinates..."))
# PCA
if (grepl(type, "PCA", ignore.case = TRUE)) {
# MAPPING
mp <- rpca(x, ...)
# MAPPING CO-ORDINATES
coords <- mp$x[, 1:2, drop = FALSE]
colnames(coords) <- c("PCA-1", "PCA-2")
# tSNE
} else if (grepl(type, "tSNE", ignore.case = TRUE)) {
# MAPPING
mp <- Rtsne(x, ...)
# MAPPING CO-ORDINATES
coords <- mp$Y
colnames(coords) <- c("tSNE-1", "tSNE-2")
# FIt-SNE
} else if (grepl(type, "FIt-SNE", ignore.case = TRUE) |
grepl(type, "FItSNE", ignore.case = TRUE)) {
mp <- fftRtsne(x, ...)
# MAPPING CO-ORDINATES
coords <- mp[, 1:2, drop = FALSE]
colnames(coords) <- c("FIt-SNE-1", "FIt-SNE-2")
# UMAP
} else if (grepl(type, "UMAP", ignore.case = TRUE)) {
# MAPPING
mp <- umap(x, ...)
# MAPPING CO-ORDINATES
coords <- mp$layout
colnames(coords) <- c("UMAP-1", "UMAP-2")
# EmbedSOM
} else if (grepl(type, "EmbedSOM", ignore.case = TRUE)) {
# DATA
names(args)[1] <- "data"
# CREATE SOM - FLOWSOM NOT SUPPLIED (fsom)
if (!"fsom" %in% names(args)) {
# SOM
mp <- do.call(
"SOM",
args[names(args) %in% formalArgs(EmbedSOM::SOM)]
)
# SOM ARGUMENTS
args[["map"]] <- mp
}
# EMBEDSOM
mp <- do.call(
"EmbedSOM",
args[names(args) %in% formalArgs(EmbedSOM::EmbedSOM)]
)
# MAPPING CO-ORDINATES
coords <- mp
colnames(coords) <- c("EmbedSOM-1", "EmbedSOM-2")
# UNSUPPORTED TYPE
} else {
stop(paste(type, "is not a supported mapping type."))
}
# CUSTOM FUNCTION
} else if(is.function(type)) {
# MESSAGE
message(paste0("Computing ",
cyto_map_fun,
" co-ordinates..."))
# RENAME FIRST ARGUMENT
names(args)[1] <- formalArgs(type)[1]
# MAPPING
mp <- do.call(type, args)
# MAPPING COORDS
if(is(mp, "matrix")){
coords <- mp[, c(1,2)]
}else{
# LOOOK FOR COORDS
coords <- NULL
lapply(seq_len(mp), function(z){
if(class(mp[z]) == "matrix"){
if(nrow(mp[z]) == nrow(x)){
coords <<- cbind(coords, mp[z])
}
}
})
coords <- coords[, c(1,2)]
}
# COLNAMES
colnames(coords) <- c(paste0(cyto_map_fun, "-1"),
paste0(cyto_map_fun, "-2"))
}
# RETURN MAPPED COORDS
return(coords)
}
|
7e789984c852b955c3391250199d04180c3f6cc0
|
8d4902d586f2a7f3f2b57d6a2ce0e0afefa8bc22
|
/R Code - Plots/plot2.R
|
b97cd4341f90cbfdde4e4dc64d1a1fcec7ca8c8b
|
[] |
no_license
|
mfaryna/ExData_Plotting1
|
63bbf5e502ea03cae527a411dfcfedec243961bd
|
4289bd4fa086258d5fc9b6cf3886b4a8b3be773f
|
refs/heads/master
| 2020-12-27T01:45:05.732913
| 2014-12-06T11:37:02
| 2014-12-06T11:37:02
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,400
|
r
|
plot2.R
|
## ========== DOWNLOADING AND UNZIPPING DATA ========== ##
url <- "https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip"
download.file(url, destfile = "data.zip")
Sys.setlocale("LC_TIME", "English") ## changing time locale (windows) to present ab. of days in English
dane <- unzip("data.zip", files = NULL, list = FALSE, overwrite = TRUE, junkpaths = FALSE, exdir = ".", unzip = "internal", setTimes = FALSE)
mr <- difftime("2007-02-03 00:00", "2007-01-31 23:59", units="mins")
sk <- difftime("2007-01-31 23:59", "2006-12-16 17:22", units="mins")
names <- as.matrix(read.table(dane, sep = ";", skip = 0, nrows = 1))
set <- read.table(
dane
,sep = ";"
,skip = sk
,nrows = mr
,col.names = names
,colClasses = c("factor", "character", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric")
)
rm(names)
rm(sk)
rm(mr)
rm(dane)
set$Date <- as.Date(set$Date, '%d/%m/%Y')
days <- unique(weekdays(set$Date, TRUE))
# ========== CREATING AND SAVING PLOT ==========
png(file = "plot2.png", width = 480, height = 480, units = "px")
par(mar = c(4, 4, 4, 4))
plot(
set$Global_active_power
,ylab = "Global Active Power (kilowatts)"
,xlab = ""
,xaxt = "n"
,col = "black"
,type = "l"
)
axis(1, at=c(1, (nrow(set)-1)/2, nrow(set)), labels=days)
dev.off()
|
b601053f6279f9c56df7457a494c95e5e27146c2
|
2d34708b03cdf802018f17d0ba150df6772b6897
|
/googleiamv1.auto/man/AuditData.Rd
|
b5f95aaffa33490368f323914a8529c0ffb70181
|
[
"MIT"
] |
permissive
|
GVersteeg/autoGoogleAPI
|
8b3dda19fae2f012e11b3a18a330a4d0da474921
|
f4850822230ef2f5552c9a5f42e397d9ae027a18
|
refs/heads/master
| 2020-09-28T20:20:58.023495
| 2017-03-05T19:50:39
| 2017-03-05T19:50:39
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 574
|
rd
|
AuditData.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/iam_objects.R
\name{AuditData}
\alias{AuditData}
\title{AuditData Object}
\usage{
AuditData(policyDelta = NULL)
}
\arguments{
\item{policyDelta}{Policy delta between the original policy and the newly set policy}
}
\value{
AuditData object
}
\description{
AuditData Object
}
\details{
Autogenerated via \code{\link[googleAuthR]{gar_create_api_objects}}
Audit log information specific to Cloud IAM. This message is serializedas an `Any` type in the `ServiceData` message of an`AuditLog` message.
}
|
4a6c8eb20bc353897916b309014d78979cb72b9a
|
dd34df468ab31496c86449db8861d49a8fe5ae39
|
/cachematrix.R
|
cbffb0feabc79b0940ceb87f3303e0b04f0808bf
|
[] |
no_license
|
HerbN/ProgrammingAssignment2
|
2c880feaa1b0221c3072e0da975738132ea7aa44
|
bf59f8adf7b1e0466275df944c9e13bd72beae95
|
refs/heads/master
| 2021-01-18T15:32:30.241501
| 2015-07-26T15:41:10
| 2015-07-26T15:41:10
| 39,729,109
| 0
| 0
| null | 2015-07-26T14:51:57
| 2015-07-26T14:51:56
| null |
UTF-8
|
R
| false
| false
| 1,966
|
r
|
cachematrix.R
|
## This is a pair of functions to create a container object for large matrices
## and allow certain values for them, initially just the inverse, to be precomputed
## allowing higher programming speed by avoiding repeated calculation
## makeCacheMatrix creates a list container with:
## 1. A matrix
## 2. Four functions:
## a. Get and Set for the matrix
## b. Get and Set for the matrix inverse
## 3. A cached version of the inverse
makeCacheMatrix <- function(x = matrix()) {
## Storage for pre-computed inverse of the matrix
## Note, evaluation is lazy...the cached version is only computered
## the first time it is requested
inverted <- NULL
## Getter and setter for the matrix itself
get <- function() x
set <- function(y) {
x <<- y
inverted <<- NULL
}
## Getter and setter for the inverse
get_inverse <- function() inverted
set_inverse <- function(inverse) inverted <<- inverse
## Create the containing list and return it
list ( set = set,
get = get,
set_inverse = set_inverse,
get_inverse = get_inverse
)
}
## This function takes a cached matrix created by makeCacheMatrix
## and returns the inverse. If the inversed has already been cached
## it returns the cached value. Otherwise it calculates it, caches it,
## and returns the cached value.
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
inverted <- x$get_inverse()
if ( ! is.null(inverted) ) {
## We have a cached value so just return it
message("getting cached inverse")
return(inverted)
}
## The inverse has not been calculated so calculate it, cache it,
## and return it.
data <- x$get()
inverted <- solve(data, ...)
x$set_inverse(inverted)
## If we are not returning the result of the last operation
## I prefer an explict return over merely referencing the value
## to be returned
return(inverted)
}
|
9a5e039ccbb4e83f4498ffaa058e5d9344d031c3
|
529a7db69b0643d9d7fe3c91cb48428789b482c8
|
/man/download.dbcan.Rd
|
55d62dace91a776bd9ea83e96cf346f41d328dca
|
[
"MIT"
] |
permissive
|
ukaraoz/microtrait
|
0b039191a178a9e674cd4c64b00a25ba88e99c42
|
ad2b5aacc775336d9f45d47e4fa4a75a2ab49073
|
refs/heads/master
| 2023-04-27T03:51:19.650028
| 2023-04-25T16:04:58
| 2023-04-25T16:04:58
| 283,821,755
| 20
| 2
| null | null | null | null |
UTF-8
|
R
| false
| true
| 349
|
rd
|
download.dbcan.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prep_hmmpackage.R
\name{download.dbcan}
\alias{download.dbcan}
\title{Prepare dbcan database (download and subselect)}
\usage{
download.dbcan(dbcan_version = 8, dbcanhmmdb_selectids_file, dbcanhmmdb_file)
}
\description{
Prepare dbcan database (download and subselect)
}
|
6971a65636ae6af92524c848d1b99bde95e749d7
|
84343f1887e8c93a7d3de4d5e791b08c1ee9d37c
|
/server/vacancy/vacancyServer.R
|
96a1d50c75db28beddd3c71abc53c7c6381e8fb2
|
[] |
no_license
|
chambox/bullhornShinyDash
|
cf162d20905dc2f2e628067514603605ab028fd7
|
dff94c50941cb9d05b96334e28f34d43b78b5777
|
refs/heads/master
| 2020-04-27T17:44:34.229939
| 2019-03-08T12:44:03
| 2019-03-08T12:44:03
| 174,535,116
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 4,235
|
r
|
vacancyServer.R
|
# filter recruiter
output$vacancy_clientCopFilter <- renderUI({
clientCop <-
vacancy_rdata$clientCorporation[!vacancy_rdata$customerDpt == "NULL"]
clientCop <- as.list(unique(clientCop))
selectInput(
"vacancy_clientCopFilter",
"Select client coperation",
choices = clientCop,
selected = "BNP Paribas Fortis"
)
})
#filter business unit
output$vacancy_businessUnitFilter <- renderUI({
vacancy_rdata$customText11 %>%
unique() %>%
c("All business units") %>%
as.list() -> chs
selectInput(
"vacancy_businessUnitFilter",
"Select business unit",
choices = chs,
selected = "All business units"
)
})
# Data filtering based on date and business unit
# all done here in this reactive setting
vacancy_filteredData <- reactive({
if (is.null(input$vacancy_businessUnitFilter)) {
bu <- "All business units"
}
else{
bu <- input$vacancy_businessUnitFilter
}
if (is.null(input$vacancy_clientCopFilter)) {
cltCop <- "BNP Paribas Fortis"
}
else{
cltCop <- input$vacancy_clientCopFilter
}
if (is.null(input$daterange)) {
startEnd = c(Sys.Date() - 30, Sys.Date())
}
else{
startEnd <- input$daterange
}
if (bu == "All business units")
subset0 <- rep(TRUE, length(vacancy_rdata$customText11))
else
subset0 <- vacancy_rdata$customText11 == bu
subset1 <-
vacancy_rdata$dateAdded %within% interval(ymd(startEnd[1]),
ymd(startEnd[2]))
subset2 <- vacancy_rdata$clientCorporation == cltCop
subset <- ifelse(is.na(subset0 & subset1 & subset2),
FALSE,
subset0 & subset1 & subset2)
r0 <- vacancy_rdata[subset, ]
list(r0 = r0, bu = bu)
})
#Data table output
output$vacancy_requestTable <- DT::renderDataTable({
if (!is.null(vacancy_filteredData()$r0))
{
if (dim(vacancy_filteredData()$r0)[1] > 0) {
table(
gsub("BNPPF_", "", vacancy_filteredData()$r0$customerDpt),
vacancy_filteredData()$r0$status.y
) %>%
data.frame() %>%
reshape(
v.names = "Freq",
idvar = "Var1",
timevar = "Var2",
direction = "wide"
) -> tbl
names(tbl)[1] <- "Tribe"
names(tbl)[-1] <- gsub("Freq.", "", names(tbl)[-1])
tbl
}
else {
tbl <- data.frame("No results")
names(tbl) <-
paste("Search results for", vacancy_filteredData()$bu)
tbl
}
}
},
options = list(pageLength = 5, scrollX = TRUE),
escape = FALSE, server = FALSE, selection = 'none')
output$vacancy_placementTable <- DT::renderDataTable({
if (!is.null(vacancy_filteredData()$r0))
{
if (dim(vacancy_filteredData()$r0)[1] > 0) {
table(
gsub("BNPPF_", "", vacancy_filteredData()$r0$customerDpt),
vacancy_filteredData()$r0$status.x
) %>%
data.frame() %>%
reshape(
v.names = "Freq",
idvar = "Var1",
timevar = "Var2",
direction = "wide"
) -> tbl
names(tbl)[1] <- "Tribe"
names(tbl)[-1] <- gsub("Freq.", "", names(tbl)[-1])
tbl
}
else {
tbl <- data.frame("No results")
names(tbl) <-
paste("Search results for", vacancy_filteredData()$bu)
tbl
}
}
},
options = list(pageLength = 5, scrollX = TRUE),
escape = FALSE, server = FALSE, selection = 'none')
##Vacancy recieved per department
output$vacancy_perDpt <- renderPlotly({
vacancy_filteredData()$r0 %>%
select(Status = status.y,
department = customerDpt) %>%
mutate(department = gsub("BNPPF_", "", department)) -> data
p <-
ggplot(data = data, aes(x = department, fill = Status)) +
geom_bar(position = "dodge")
ggplotly(p) %>%
layout(xaxis = list(title = "", tickangle = -45))
})
output$vacancy_placements <- renderPlotly({
vacancy_filteredData()$r0 %>%
select(Status = status.x,
department = customerDpt) %>%
mutate(department = gsub("BNPPF_", "", department)) -> data
p <-
ggplot(data = data, aes(x = department, fill = Status)) +
geom_bar(position = "dodge")
ggplotly(p) %>%
layout(xaxis = list(title = "", tickangle = -45))
})
|
dc8e1f4122aa420ad21a88e19f63542caffba96e
|
b0a915648ff80798c5aba7883826c9c4d7aa71eb
|
/man/cytoHeatmaps.Rd
|
20bfa40a08ef210d8a98e70c533baedd9c4f7919
|
[] |
no_license
|
KoenAStam/cytofast
|
69a13ad655dd71dd2c430f163b0a12fc73bdfede
|
98d2625aded79f4e2459cf59b2724f0ba44e8730
|
refs/heads/master
| 2022-06-10T02:29:57.346697
| 2022-05-23T13:42:51
| 2022-05-23T13:42:51
| 151,564,984
| 3
| 3
| null | 2020-03-17T10:15:03
| 2018-10-04T12:03:01
|
R
|
UTF-8
|
R
| false
| true
| 1,508
|
rd
|
cytoHeatmaps.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cytoHeatmaps.R
\name{cytoHeatmaps}
\alias{cytoHeatmaps}
\title{Draw heatmaps for cfList}
\usage{
cytoHeatmaps(cfList, group, legend = FALSE)
}
\arguments{
\item{cfList}{a cfList object.}
\item{group}{one of:
\itemize{
\item a character vector referring to a column name in the \code{samples} slot of the \code{cfList}.
\item a factor indicating the grouping (x-axis) for the boxplots.
}}
\item{legend}{logical, whether a legend should be added}
}
\value{
None
}
\description{
Function to draw two heatmaps. They visualize the median intensity of the markers for the
created clusters. The ordering of the clusters is based on the default
hierarchical cluster analysis \code{\link[stats]{hclust}}. Note that hclust takes the data after
the median intensity is calculated per cluster, thus placing the most similar clusters
next to each other.
}
\examples{
# Read Data
dirFCS <- system.file("extdata", package="cytofast")
cfData <- readCytosploreFCS(dir = dirFCS, colNames = "description")
# Add cell counts to cfList and add meta data
cfData <- cellCounts(cfData, frequency = TRUE, scale = TRUE)
meta <- spitzer[match(row.names(cfData@samples), spitzer[,"CSPLR_ST"]),]
cfData@samples <- cbind(cfData@samples, meta)
# Remove unnecessary markers
cfData@expr <- cfData@expr[,-c(3:10, 13:16, 55:59, 61:63)]
# Draw heatmaps
cytoHeatmaps(cfData, group = "group", legend = TRUE)
}
\keyword{FCS}
\keyword{heatmap,}
\keyword{markers,}
|
0f1457cfc7aba767e4a0dd92065f21d782be1e50
|
915c84dc61471ff1518fa2aec586a606119fcf1e
|
/Analysis.R
|
f084ee7f1e1b0504cd2028bebfee0e7ab576b5de
|
[] |
no_license
|
chriswardchrisward/Data
|
d8411fbf7b5a404efdd000091ecf37f8b16229d4
|
39a18fc5c0395799eb431386a81856fda4dd49c4
|
refs/heads/master
| 2020-08-10T18:06:58.086072
| 2015-05-17T23:12:35
| 2015-05-17T23:12:35
| 35,786,520
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 3,589
|
r
|
Analysis.R
|
###### Set Up ######
# 1.
setwd("~/Training/Data")
dat <- read.table("Activity.csv", header = T, sep = ",", as.is= TRUE)
# 2.
dat$interval <- as.factor(dat$interval)
dat$date <- as.Date(dat$date, format="%m/%d/%Y")
dat$day <- weekdays(dat$date) #Adds day of week
dat$weekday <- ifelse(weekdays(dat$date)=="Saturday" | weekdays(dat$date)=="Sunday", "weekend", "weekday") #Adds weekend/weekday column
dat_wday <- subset(dat, dat$weekday == "weekday") # creates a weekday subset dataframe
dat_wend <- subset(dat, dat$weekday == "weekend") # creates a weekend subset dataframe
###### Steps per day ######
# 1.
steps_per_day <- list() #creates empty list
for (i in 1:length(unique(dat$date))){ #counts total steps per day
steps_per_day <- cbind(steps_per_day, sum(dat$steps[dat$date==(unique(dat$date))[i]]))
}
steps_per_day <- sapply(steps_per_day, as.numeric) #converts to numeric
# 2.
hist(steps_per_day, breaks= length(unique(dat$date))) #creates a histogram
#3.
mean(steps_per_day, na.rm=T)
median(steps_per_day, na.rm=T)
###### Average daily activity pattern ######
# 1.
steps_per_int <- list() #creates empty list
for (i in 1:length(unique(dat$interval))){ #counts total steps per interval
steps_per_int <- cbind(steps_per_int,sum(dat$steps[dat$interval==as.character((unique(dat$interval))[i])],na.rm=T))
}
steps_per_int <- sapply(steps_per_int, as.numeric) #converts to numeric
steps_per_int <- steps_per_int/length(unique(dat$date))
plot(steps_per_int, unique(dat$intervals), type="l", xlab= "", ylab="") # creates a plot of steps per interval
mtext("Steps", side=2, line=2.75, cex=1.2, lwd=4)
mtext("Time Interval", side=1, line=3, cex=1.2)
max_steps<- max(steps_per_int, na.rm=T) #Caluculates the max steps
match(max_steps,steps_per_int)
###### Imputing Missing Values
#1
summary(dat)[7,1] #returns the number of intervals that have NA's
#2
dat_imputed <- dat # creates copy of dat to imput values on
avg_step_wday_int <- mean(dat_wday$steps, na.rm=T) # average weekday int
avg_step_wend_int <- mean(dat_wend$steps, na.rm=T) # average weekend int
# 3
#if(dat_imputed$weekday=="weekday"){
# dat_imputed$steps[is.na(dat_imputed$steps)] <-avg_step_wday_int
# } else {
# dat_imputed$steps[is.na(dat_imputed$steps)] <-avg_step_wend_int
#}
ifelse(dat_imputed$steps=="Saturday" | dat_imputed$day=="Sunday",
dat_imputed$steps[is.na(dat_imputed$steps)] <- avg_step_wday_int,
dat_imputed$steps[is.na(dat_imputed$steps)] <- avg_step_wend_int)
###### Differences between weekend and weekday panel plot ######
wday_steps_per_int <- list() #creates empty list
for (i in 1:length(unique(dat_wday$interval))){ #counts avg steps per interval
wday_steps_per_int <- cbind(wday_steps_per_int,sum(dat_wday$steps[dat_wday$interval==as.character((unique(dat_wday$interval))[i])],na.rm=T))
}
wday_steps_per_int <- sapply(wday_steps_per_int, as.numeric) #converts to numeric
wday_steps_per_int <- wday_steps_per_int/length(unique(dat_wday$date))
wday_avgs <- data.frame(unique(dat_wday$interval), wday_steps_per_int, "weekday")
wend_steps_per_int <- list() #creates empty list
for (i in 1:length(unique(dat_wend$interval))){ #counts avg steps per interval
wend_steps_per_int <- cbind(wend_steps_per_int,sum(dat_wend$steps[dat_wend$interval==as.character((unique(dat_wend$interval))[i])],na.rm=T))
}
wend_steps_per_int <- sapply(wend_steps_per_int, as.numeric) #converts to numeric
wend_steps_per_int <- wend_steps_per_int/length(unique(dat_wend$date))
wend_avgs <- data.frame(unique(dat_wend$interval), wend_steps_per_int, "weekend")
avgs <- rbind(wday_avgs, wend_avgs)
|
033404b3a31f38c27bc6e9c5c6da2ebb399821e7
|
66a8e5c4ccc3cccf48ed696fce117c3a6df4a0f8
|
/R/stepcAIC.R
|
652288c5cd4fed61e2b177a4326a9396e3771e80
|
[] |
no_license
|
davidruegamer/cAIC4dev
|
3ce3a312cdb9f2793bc558bd78f9feccc0fa89f3
|
56ccc8b2f1287d10e28ad1e5c08a1d2d773df0ee
|
refs/heads/master
| 2023-08-16T19:52:47.613189
| 2023-08-10T17:08:16
| 2023-08-10T17:08:16
| 47,450,068
| 3
| 5
| null | 2019-06-23T08:55:09
| 2015-12-05T09:27:56
|
R
|
UTF-8
|
R
| false
| false
| 24,994
|
r
|
stepcAIC.R
|
#' Function to stepwise select the (generalized) linear mixed model
#' fitted via (g)lmer() or (generalized) additive (mixed) model
#' fitted via gamm4() with the smallest cAIC.
#'
#'
#' The step function searches the space of possible models in a greedy manner,
#' where the direction of the search is specified by the argument
#' direction. If direction = "forward" / = "backward",
#' the function adds / exludes random effects until the cAIC can't be improved further.
#' In the case of forward-selection, either a new grouping structure, new
#' slopes for the random effects or new covariates modeled nonparameterically
#' must be supplied to the function call.
#' If direction = "both", the greedy search is alternating between forward
#' and backward steps, where the direction is changed after each step
#'
#'@param object object returned by \code{[lme4]{lmer}}, \code{[lme4]{glmer}} or
#'\code{[gamm4]{gamm4}}
#'@param numberOfSavedModels integer defining how many additional models to be saved
#'during the step procedure. If \code{1} (DEFAULT), only the best model is returned.
#'Any number \code{k} greater \code{1} will return the \code{k} best models.
#'If \code{0}, all models will be returned (not recommended for larger applications).
#'@param groupCandidates character vector containing names of possible grouping variables for
#'new random effects. Group nesting must be specified manually, i.e. by
#'listing up the string of the groups in the manner of lme4. For example
#'\code{groupCandidates = c("a", "b", "a/b")}.
#'@param slopeCandidates character vector containing names of possible new random effects
#'@param fixEfCandidates character vector containing names of possible (non-)linear fixed effects
#'in the GAMM; NULL for the (g)lmer-use case
#'@param direction character vector indicating the direction ("both","backward","forward")
#'@param numberOfPermissibleSlopes how much slopes are permissible for one grouping variable
#'@param trace logical; should information be printed during the execution of stepcAIC?
#'@param steps maximum number of steps to be considered
#'@param keep list($fixed,$random) of formulae; which splines / fixed (fixed) or
#'random effects (random) to be kept during selection; specified terms must be
#'included in the original model
#'@param numCores the number of cores to be used in calculations;
#'parallelization is done by using \code{parallel::mclapply}
#'@param data data.frame supplying the data used in \code{object}. \code{data} must also include
#'variables, which are considered for forward updates.
#'@param returnResult logical; whether to return the result (best model and corresponding cAIC)
#'@param calcNonOptimMod logical; if FALSE, models which failed to converge are not considered
#'for cAIC calculation
#'@param bsType type of splines to be used in forward gamm4 steps
#'@param allowUseAcross allow slopes to be used in other grouping variables
#'@param allowCorrelationSel logical; FALSE does not allow correlations of random effects
#'to be (de-)selected (default)
#'@param allowNoIntercept logical; FALSE does not allow random effects without random intercept
#'@param digits number of digits used in printing the results
#'@param printValues what values of \code{c("cll", "df", "caic", "refit")}
#'to print in the table of comparisons
#'@param ... further options for cAIC call
#'@section Details:
#'
#' Note that the method can not handle mixed models with uncorrelated random effects and does NOT
#' reduce models to such, i.e., the model with \code{(1 + s | g)} is either reduced to
#' \code{(1 | g)} or \code{(0 + s | g)} but not to \code{(1 + s || g)}.
#' @return if \code{returnResult} is \code{TRUE}, a list with the best model \code{finalModel},
#' \code{additionalModels} if \code{numberOfSavedModels} was specified and
#' the corresponding cAIC \code{bestCAIC} is returned.
#'
#' Note that if \code{trace} is set to \code{FALSE} and \code{returnResult}
#' is also \code{FALSE}, the function call may not be meaningful
#' @author David Ruegamer
#' @export
#' @import parallel
#' @importFrom stats as.formula dbinom dnorm dpois family
#' formula glm lm model.frame model.matrix
#' predict reformulate simulate terms
#' @importFrom utils combn
#' @importFrom stats4 logLik
#' @examples
#'
#' (fm3 <- lmer(strength ~ 1 + (1|sample) + (1|batch), Pastes))
#'
#' fm3_step <- stepcAIC(fm3, direction = "backward", trace = TRUE, data = Pastes)
#'
#' fm3_min <- lm(strength ~ 1, data=Pastes)
#'
#' fm3_min_step <- stepcAIC(fm3_min, groupCandidates = c("batch", "sample"),
#' direction="forward", data=Pastes, trace=TRUE)
#' fm3_min_step <- stepcAIC(fm3_min, groupCandidates = c("batch", "sample"),
#' direction="both", data=Pastes, trace=TRUE)
#' # try using a nested group effect which is actually not nested -> warning
#' fm3_min_step <- stepcAIC(fm3_min, groupCandidates = c("batch", "sample", "batch/sample"),
#' direction="both", data=Pastes, trace=TRUE)
#'
#' Pastes$time <- 1:dim(Pastes)[1]
#' fm3_slope <- lmer(data=Pastes, strength ~ 1 + (1 + time | cask))
#'
#' fm3_slope_step <- stepcAIC(fm3_slope,direction="backward", trace=TRUE, data=Pastes)
#'
#'
#'
#' fm3_min <- lm(strength ~ 1, data=Pastes)
#'
#' fm3_min_step <- stepcAIC(fm3_min,groupCandidates=c("batch","sample"),
#' direction="forward", data=Pastes,trace=TRUE)
#'
#'
#'
#' fm3_inta <- lmer(strength ~ 1 + (1|sample:batch), data=Pastes)
#'
#' fm3_inta_step <- stepcAIC(fm3_inta,groupCandidates=c("batch","sample"),
#' direction="forward", data=Pastes,trace=TRUE)
#'
#' fm3_min_step2 <- stepcAIC(fm3_min,groupCandidates=c("cask","batch","sample"),
#' direction="forward", data=Pastes,trace=TRUE)
#'
#' fm3_min_step3 <- stepcAIC(fm3_min,groupCandidates=c("cask","batch","sample"),
#' direction="both", data=Pastes,trace=TRUE)
#'
#' \dontrun{
#' fm3_inta_step2 <- stepcAIC(fm3_inta,direction="backward",
#' data=Pastes,trace=TRUE)
#' }
#'
#' ##### create own example
#'
#'
#' na <- 20
#' nb <- 25
#' n <- 400
#' a <- sample(1:na,400,replace=TRUE)
#' b <- factor(sample(1:nb,400,replace=TRUE))
#' x <- runif(n)
#' y <- 2 + 3 * x + a*.02 + rnorm(n) * .4
#' a <- factor(a)
#' c <- interaction(a,b)
#' y <- y + as.numeric(as.character(c))*5
#' df <- data.frame(y=y,x=x,a=a,b=b,c=c)
#'
#' smallMod <- lm(y ~ x)
#'
#' \dontrun{
#' # throw error
#' stepcAIC(smallMod, groupCandidates=c("a","b","c"), data=df, trace=TRUE, returnResult=FALSE)
#'
#' smallMod <- lm(y ~ x, data=df)
#'
#' # throw error
#' stepcAIC(smallMod, groupCandidates=c("a","b","c"), data=df, trace=TRUE, returnResult=FALSE)
#'
#' # get it all right
#' mod <- stepcAIC(smallMod, groupCandidates=c("a","b","c"),
#' data=df, trace=TRUE,
#' direction="forward", returnResult=TRUE)
#'
#' # make some more steps...
#' stepcAIC(smallMod, groupCandidates=c("a","b","c"), data=df, trace=TRUE,
#' direction="both", returnResult=FALSE)
#'
#' mod1 <- lmer(y ~ x + (1|a), data=df)
#'
#' stepcAIC(mod1, groupCandidates=c("b","c"), data=df, trace=TRUE, direction="forward")
#' stepcAIC(mod1, groupCandidates=c("b","c"), data=df, trace=TRUE, direction="both")
#'
#'
#'
#' mod2 <- lmer(y ~ x + (1|a) + (1|c), data=df)
#'
#' stepcAIC(mod2, data=df, trace=TRUE, direction="backward")
#'
#' mod3 <- lmer(y ~ x + (1|a) + (1|a:b), data=df)
#'
#' stepcAIC(mod3, data=df, trace=TRUE, direction="backward")
#'
#' }
#'
stepcAIC <- function(object,
numberOfSavedModels = 1,
groupCandidates = NULL,
slopeCandidates = NULL,
fixEfCandidates = NULL,
numberOfPermissibleSlopes = 2,
allowUseAcross = FALSE,
allowCorrelationSel = FALSE,
allowNoIntercept = FALSE,
direction = "backward",
trace = FALSE,
steps = 50,
keep = NULL,
numCores = 1,
data = NULL,
returnResult = TRUE,
calcNonOptimMod = TRUE,
bsType = "tp",
digits = 2,
printValues = "caic",
...)
{
#######################################################################
########################## pre-processing #############################
#######################################################################
if(!is.null(data)){
data <- get(deparse(substitute(data)), envir = parent.frame())
if(inherits(object, c("lmerMod", "glmerMod")))
attr(data, "orgname") <- as.character(object@call[["data"]]) else
attr(data, "orgname") <- as.character(object$call[["data"]])
}else if(inherits(object, c("lmerMod", "glmerMod"))){
data <- get(deparse(object@call[["data"]]), envir = parent.frame())
attr(data, "orgname") <- as.character(object@call[["data"]])
}else{
stop("argument data must be supplied!")
}
possible_predictors <- colnames(data)
### build nesting in groupCandidates
nestCands <- groupCandidates[grep("/", groupCandidates)]
nestCands <- nestCands[!nestCands %in% possible_predictors]
for(nc in nestCands){
# check if really nested
ncc <- trimws(strsplit(nc, "/")[[1]])
if(!isNested(data[,ncc[1]], data[,ncc[2]])){
warning(paste0("Dropping incorrect nesting group ", nc, " from groupCandidates."))
}else{
groupCandidates <- unique( c(groupCandidates, allNestSubs(nc)) )
}
groupCandidates <- setdiff(groupCandidates, nc)
}
# intaCands <- groupCandidates[grep(":", groupCandidates)]
# if(length(intaCands) > 0) intaCands <- intaCands[!intaCands %in% possible_predictors]
# for(ic in intaCands){
# sepIc <- trimws(strsplit(ic, ":")[[1]])
# if(cor(sapply(data[,sepIc], as.numeric))==1)
# stop(paste0("Interaction of ", sepIc, " not meaningful."))
# }
existsNonS <- FALSE
### check if gamm4-call
if(is.list(object) & length(object)==2 & all(c("mer","gam") %in% names(object))){
if(allowUseAcross | !is.null(slopeCandidates))
stop("allowUseAcross and slopeCandidates are not permissible for gamm4-objects!")
ig <- mgcv::interpret.gam(object$gam$formula)
existsNonS <- length(ig$smooth.spec)<length(ig$fake.names)
if( !is.null(fixEfCandidates) ) stopifnot( fixEfCandidates %in% possible_predictors )
### check for dot in formula
if(grepl("\\s{1}\\.{1}\\s{1}", as.character(object$mer@call)[2]))
{
stop("Abbrevation of variable names via dot in formula is not supported.")
}
}else{ # not gamm4, but potentially a lm / glm object
if( !is.null(groupCandidates) ) stopifnot( all ( groupCandidates %in% possible_predictors ) |
( unlist(strsplit(groupCandidates, ":")) %in%
possible_predictors ) )
if( !is.null(slopeCandidates) ) stopifnot( slopeCandidates %in% possible_predictors )
### check for dot in formula
if(inherits(object, "merMod")){
if(grepl("\\s{1}\\.{1}\\s{1}", as.character(object@call)[2])){
fullform <- terms(formula(object), data=object@frame)
fullform <- as.formula(Reduce(paste, deparse(fullform)))
object <- update(object, formula = fullform)
}
}else if(any(class(object)%in%c("lm","glm"))){
# formula(object) should already give the desired result
}else{
stop("Model class not supported.")
}
}
if(!returnResult & numberOfSavedModels != 1)
warning("No result will be returned if returnResult==FALSE.")
# define everything needed to save further models
if(numberOfSavedModels==1) additionalModels <- NULL else{
additionalModels <- list()
additionalCaics <- c()
}
if(numberOfSavedModels==0) numberOfSavedModels <- Inf
if(numberOfPermissibleSlopes < 1)
stop("numberOfPermissibleSlopes must be greater or equal to 1")
# redefine numberOfPermissibleSlopes as intercepts will also count as slopes
numberOfPermissibleSlopes <- numberOfPermissibleSlopes + 1
#######################################################################
########################## entry step #############################
#######################################################################
# -> get cAIC of input model
if(inherits(object, c("lmerMod", "glmerMod")) | "mer"%in%names(object)){
timeBefore <- Sys.time()
cAICofMod <- tryCatch(cAIC(object,...), error = function(e){
cat("\n\nThe cAIC of the initial model can not be calculated. Continue Anyway?")
readline("If so, type 'y': ")
})
if(!is.numeric(cAICofMod$caic) && cAICofMod=="y"){
cAICofMod <- Inf
}else if(!is.numeric(cAICofMod$caic) && cAICofMod!="y") return(NULL)
refit <- cAICofMod$new
# if(refit==1 & inherits(object, c("lmerMod", "glmerMod")))
# object <- cAICofMod$reducedModel
cAICofMod <- cAICofMod$caic
timeForCalc <- Sys.time() - timeBefore
}else if(any(class(object)%in%c("lm","glm"))){
# ll <- getGLMll(object)
# bc <- attr(logLik(object),"df")
cAICofMod <- cAIC(object)$caic #-2*ll + 2*bc
if(direction=="backward") stop("A simple (generalized) linear model can't be reduced!")
}else{
stop("Class of object is not known")
}
# check if call is inherently consistent
if(!(
direction=="backward" |
( direction %in% c("forward","both") &
( !is.null(groupCandidates) | !is.null(slopeCandidates) | !is.null(fixEfCandidates) )
) |
( direction %in% c("forward","both") &
is.null(groupCandidates) & is.null(slopeCandidates) & is.null(fixEfCandidates) &
( allowUseAcross | existsNonS ) )
))
stop("Can not make forward steps without knowledge of additional random effect covariates.")
if( direction=="backward" & !( is.null(groupCandidates) & is.null(slopeCandidates) &
is.null(fixEfCandidates) )
)
warning("Ignoring variables in group-/slopeCandidates or fixEfCandidates for backward steps.")
#######################################################################
########################## (end) #############################
#######################################################################
#######################################################################
####################### iteratively fitting ###########################
#######################################################################
# indicator to break while loop
stepsOver <- FALSE
# indicator for direction=="both"
dirWasBoth <- ifelse( direction=="both", TRUE, FALSE )
# indicator for improvement in direction=="both" - step
improvementInBoth <- TRUE
# indicator for check if step procedure didnt yield better
# results compared to the previous step
equalToLastStep <- FALSE
# change direction to either forward or backward
direction <- ifelse( direction%in%c("both","forward"),"forward","backward" )
# get the initial number of steps
stepsInit <- steps
###################################################################
####################### iterative part ############################
###################################################################
if(trace){
cat("Starting stepwise procedure...")
cat("\n_____________________________________________\n")
cat("_____________________________________________\n")
}
# try to improve the model as long as stepsOver==FALSE
while(!stepsOver){
# get all components needed for stepping procedure
comps <- getComponents(object)
newSetup <- if(direction=="forward"){
makeForward(comps=comps,
slopeCandidates=slopeCandidates,
groupCandidates=groupCandidates,
fixEfCandidates=fixEfCandidates,
nrOfCombs=numberOfPermissibleSlopes,
allowUseAcross=allowUseAcross,
allowCorrelationSel=allowCorrelationSel,
bsType=bsType,
keep=keep)
}else{
makeBackward(comps=comps,
keep=keep,
allowCorrelationSel=allowCorrelationSel,
allowNoIntercept=allowNoIntercept)
}
if(all(sapply(newSetup, is.null)) & direction=="forward")
{
if(trace){
cat("\nBest model: ", makePrint(object), "\ncAIC:",
cAICofMod, "\n_____________________________________________\n")
# cat("\nModel can not be further extended.")
if(refit==1) cat("\nBest model should be refitted due to zero variance components.\n")
}
return(list(finalModel=object,
additionalModels=NULL,
bestCAIC=cAICofMod)
)
}
########################### printing ##############################
if(trace) {
cat("\nStep ",stepsInit-steps+1," (",direction,"): cAIC=",
format(round(cAICofMod, 4)), "\n",
"Best model so far:\n", makePrint(object), "\n", sep = "")
utils::flush.console()
}
###################################################################
steps = steps - 1
if(trace) cat("New Candidates:\n\n")
newSetup <- mergeChanges(initialParts=comps, listParts=newSetup)
### ( print ) ###
if(trace & !is.null(newSetup)) cat("Calculating cAIC for",
length(newSetup),
"model(s) ...\n")
#############
### calculate all other models and cAICs
tempRes <- if(!is.null(newSetup)){
calculateAllCAICs(newSetup=newSetup,
modelInit=object,
numCores=numCores,
data=data,
calcNonOptimMod=calcNonOptimMod,
nrmods=numberOfSavedModels,
...)
}
##############
if(is.list(tempRes) & !is.null(tempRes$message)){ # gamm4 with error
warning(paste0("There are zero variance components.\n", tempRes$message))
if(returnResult){
return(list(finalModel=object,
additionalModels=additionalModels,
bestCAIC=cAICofMod)
)
}else{
return(invisible(NULL))
}
}
### get performance
aicTab <- as.data.frame(tempRes$aicTab)
### ( print ) ###
if (trace) {
cat("\n")
print(aicTab[with(aicTab,order(-caic)), c("models",printValues)],
row.names = FALSE, digits = digits)
cat("\n_____________________________________________\n")
cat("_____________________________________________\n")
utils::flush.console()
}
caicsres <- attr(tempRes$bestMod, "caic")
bestModel <- tempRes$bestMod[[which.min(caicsres)]]
if(numberOfSavedModels > 1 & length(tempRes$bestMod) > 0){
additionalModels <- c(additionalModels, tempRes$bestMod)
# check for duplicates among models
duplicates <- duplicatedMers(additionalModels)
# remove duplicates
additionalModels <- additionalModels[!duplicates]
additionalCaics <- c(additionalCaics, caicsres)[!duplicates]
bestCaics <- order(additionalCaics, decreasing = FALSE)[
1:min(numberOfSavedModels, length(additionalCaics))
]
additionalModels <- additionalModels[bestCaics]
additionalCaics <- additionalCaics[bestCaics]
}
indexMinCAIC <- which.min(aicTab$caic)
minCAIC <- ifelse(length(indexMinCAIC)==0, Inf, aicTab$caic[indexMinCAIC])
if(minCAIC < cAICofMod) refit <- tempRes$aicTab[indexMinCAIC,"refit"]
keepList <- list(random=interpret.random(keep$random),gamPart=NULL)
if(!is.null(keep$fixed)) keepList$gamPart <- mgcv::interpret.gam(keep$fixed)
###############################################################################
###############################################################################
############################# - decision part - ###############################
###############################################################################
###############################################################################
if( minCAIC==Inf ){
if(dirWasBoth){
direction <- ifelse( direction=="forward", "backward", "forward" )
improvementInBoth <- FALSE
}else{
stepsOver <- TRUE
bestModel <- object
minCAIC <- cAICofMod
}
}else if(
( minCAIC <= cAICofMod & !dirWasBoth & direction=="backward" &
any(class(bestModel)%in%c("glm","lm")) )
# if backward step procedure reached (g)lm
|
( minCAIC <= cAICofMod & !dirWasBoth & direction=="backward" &
is.logical(all.equal(newSetup[[which.min(aicTab$caic)]],keepList)) )
# if backward step procedure reached minimal model defined by keep statement
|
( minCAIC <= cAICofMod & all( is.na(newSetup) ) )
# if there is a new better model, which is a (g)lm
# stop stepping and return bestModel / bestCAIC
){
stepsOver <- TRUE
}else if( minCAIC <= cAICofMod & all(!is.na(newSetup) & !equalToLastStep ) ){
if( minCAIC == cAICofMod ) equalToLastStep <- TRUE
# if there is a new better model and the new model is not a (g)lm
# update the best model
if( steps==0 | length(newSetup)==1 ) stepsOver <- TRUE else{
cAICofMod <- minCAIC
object <- bestModel
improvementInBoth <- TRUE # set TRUE as performance improved
# (only relevant for direction=="both")
if(dirWasBoth) direction <- ifelse( direction=="forward", "backward", "forward" )
}
}else if( minCAIC <= cAICofMod & equalToLastStep & improvementInBoth ){
# there is another best model
cAICofMod <- minCAIC
object <- bestModel
improvementInBoth <- FALSE
if(dirWasBoth) direction <- ifelse( direction=="forward", "backward", "forward" )
}else if( minCAIC > cAICofMod & ( steps==0 | length(newSetup)==1 ) & !dirWasBoth ){
# if there is no better model, but all the required steps were done or
# there is no more combination of random effects to check or the
# "both"-stepping was not successful in the previous turn, stop
# stepping and return the current model or previous model
stepsOver <- TRUE
minCAIC <- cAICofMod
bestModel <- object
}else if( minCAIC >= cAICofMod & dirWasBoth & improvementInBoth ){
# if there is no new better model, but direction was "both" and
# the step before the last step was a successfully forward / backward step
direction <- ifelse( direction=="forward", "backward", "forward" )
improvementInBoth <- FALSE
# set to FALSE to prevent unnecessary steps if the current model is the best model
}else{
# in case when the procedure did all steps / no more random effects are available
# but the last step did not yield better performance or the last step had an equal cAIC
stepsOver <- TRUE
if(refit==0) bestModel <- object
minCAIC <- cAICofMod
}
} # while end
###############################################################################
############################ return result ###################################
###############################################################################
if(minCAIC==Inf){
if(trace) cat("\nNo best model found.")
}else{
if(trace) cat("\nBest model:\n", makePrint(bestModel),",\n",
"cAIC:", minCAIC, "\n_____________________________________________\n")
#if(refit==1) cat("\nBest model should be refitted due to zero variance components.\n")
}
if(returnResult){
if(!is.null(additionalModels)){
additionalModels <- additionalModels[-1]
attr(additionalModels, "cAICs") <- additionalCaics[-1]
}
return(list(finalModel=bestModel,
additionalModels=additionalModels,
bestCAIC=minCAIC)
)
}else{
return(invisible(NULL))
}
}
|
690106c4f1cafe9341312cc5087d812263b80cfe
|
e4f02038bf4a8b1e6f5a017cbc547bf33be9fd3d
|
/CRISPR/pptm_functions.R
|
6e7e35d3e79b970d0ecf354e35907e0d2807301c
|
[] |
no_license
|
rahulk87/GeneFunctionCodes
|
00e29a3e027566ec12fcbf9235dfca371bba4fff
|
777140c7c41f14908cdda794fd137f4cf7ebe3be
|
refs/heads/master
| 2021-01-12T02:47:26.826820
| 2019-10-16T02:48:23
| 2019-10-16T02:48:23
| 78,104,858
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 844
|
r
|
pptm_functions.R
|
get_pptm <- function(x){
x_total_count_sum <- sum(
x$T0
)
T0_pptm <- x$T0 / (x_total_count_sum / 10^7)
x_total_count_sum <- sum(
x$Drug_1
)
Drug_1_pptm <- x$Drug_1 / (x_total_count_sum / 10^7)
x_total_count_sum <- sum(
x$Drug_2
)
Drug_2_pptm <- x$Drug_2 / (x_total_count_sum / 10^7)
x_total_count_sum <- sum(
x$DMSO_1
)
DMSO_1_pptm <- x$DMSO_1 / (x_total_count_sum / 10^7)
x_total_count_sum <- sum(
x$DMSO_2
)
DMSO_2_pptm <- x$DMSO_2 / (x_total_count_sum / 10^7)
sgrna <- x$sgRNA
gene <- x$Gene
x_with_pptm <- cbind(
sgrna,
gene,
T0_pptm,
DMSO_1_pptm,
DMSO_2_pptm,
Drug_1_pptm,
Drug_2_pptm
)
return(x_with_pptm)
}
|
d98fcd30658bfee10ab859ddbb9a6ba1e0515766
|
b702b7798cdb9182331b81f0cdebc4f6cdd8e2c7
|
/run_analysis.R
|
8e6e1251d612e8efae7e770ce82081a6b62e6f98
|
[] |
no_license
|
jocmom/GettingCleaningData
|
003ecd197ff32ebeb2c108e027d7a3c40dbb2e4c
|
65e9aab198013edfe8d2e23132e0488f54e93b6a
|
refs/heads/master
| 2021-05-27T13:41:06.970373
| 2014-10-27T09:43:43
| 2014-10-27T09:43:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 4,309
|
r
|
run_analysis.R
|
# Getting and cleaning data course project
run_analysis <- function() {
# use "dplyr" library for fast joins
library(dplyr)
library(tidyr)
############################################################################
# get 561 features
features <-read.table("./Dataset/features.txt",
header = FALSE,
col.names = c("idx", "label"),
stringsAsFactors = FALSE)
# cleanup feature names, remove "-", "(", ")" characters
features$label <- gsub(",|-|\\(|\\)", "", features$label)
# make feature names consistent
features$label <- gsub("mean", "Mean", features$label)
features$label <- gsub("std", "Std", features$label)
features$label <- gsub("gravity", "Gravity", features$label)
#features$label <- gsub(",|-", "_", features$label)
############################################################################
# get 6 activities
activities <- read.table("./Dataset/activity_labels.txt",
header = FALSE,
col.names = c("id", "label"),
stringsAsFactors = FALSE)
############################################################################
# get test and training sensor values and step4 is easy to implement with
# the "col.names" parameter of read.table()
# step4: appropriately labels the data set with descriptive variable names.
testX <-read.table("./Dataset/test/X_test.txt",
header = FALSE,
col.names = features$label,
colClasses = "numeric")
trainX <-read.table("./Dataset/train/X_train.txt",
header = FALSE,
col.names = features$label,
colClasses = "numeric")
# step1: merge test, train rows
tableX <- rbind_list(testX, trainX)
# step2: extract only the measurements on the mean and standard deviation
isStdOrMeanMeasurement <- names(tableX) %in% grep("Mean|Std",
names(tableX),
value = TRUE)
tableX <- tableX[, isStdOrMeanMeasurement]
############################################################################
#get corresponding activities
testActivities <- read.table("./Dataset/test/y_test.txt",
header = FALSE,
col.names = c("id"))
testActivities <- inner_join(testActivities, activities, by = "id")
trainActivities <- read.table("./Dataset/train/y_train.txt",
header = FALSE,
col.names = c("id"))
trainActivities <- inner_join(trainActivities, activities, by = "id")
# merge test, train activity rows
tableActivities <- rbind(testActivities, trainActivities)
# step3: descriptive activity names to name the activities in the data set
tableX$activity <- tableActivities$label
############################################################################
# get corresponding subjects
testSubjects <- read.table("./Dataset/test/subject_test.txt",
header = FALSE,
col.names = c("subject"))
trainSubjects <- read.table("./Dataset/train/subject_train.txt",
header = FALSE,
col.names = c("subject"))
# merge test,train subject rows
tableSubjects <- rbind(testSubjects, trainSubjects)
# add column to table
tableX$subject <- tableSubjects$subject
############################################################################
# step5: From the data set in step 4, creates a second, independent tidy
# data set with the average of each variable for each activity and each
# subject.
avgTable <-
tableX %>%
group_by(activity, subject) %>%
summarise_each(funs(mean))
# save tidy data
write.table(avgTable, file="tidyData.txt", row.names = FALSE)
############################################################################
avgTable
}
|
be530e38404293a4aeabaddb6041e97bffcea1b4
|
4ab245990f25f69185636ba2180875293ba5a249
|
/grolu.R
|
7093aa268a67e93025e27cd95f2543b9524f4b5b
|
[] |
no_license
|
RomanKyrychenko/bubbles
|
dcbb8b681497b778dbc2c11d3638910772ba6498
|
bc9223fd609bd496608aa42cd0f8c112fcecd778
|
refs/heads/master
| 2021-01-20T00:28:48.698769
| 2017-08-02T20:59:59
| 2017-08-02T20:59:59
| 89,138,262
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 31,511
|
r
|
grolu.R
|
Sys.setlocale(,"UK_ua")
library(shiny)
library(ggplot2)
library(readxl)
library(readr)
library(png)
library(grid)
library(extrafont)
library(stringi)
unzip(".fonts.zip",exdir = "~/",overwrite = T)
system('fc-cache -f ~/.fonts')
tele <- rasterGrob(readPNG("1.png"), interpolate=TRUE)
net <- rasterGrob(readPNG("2.png"), interpolate=TRUE)
zag <- rasterGrob(readPNG("3.png"), interpolate=TRUE)
ui <- shinyUI(fluidPage(
titlePanel("Corestone GR-LU"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Завантажте файл з даними',
accept = c(".xlsx")),
tags$hr(),
sliderInput("shrift",label = "Відрегулюйте шрифт",min=4,max=8,value = 5.5,step = 0.5),
downloadButton('downloadPlot',"Завантажити в pdf!"),
downloadButton('download',"Завантажити в png!")
),
mainPanel("Візуалізація",plotOutput('plot', width = "1600px", height = "900px"))
)
)
)
server <- shinyServer(function(input, output){
df <- reactive({
inFile <- input$file1
if(is.null(inFile))
return(NULL)
file.rename(inFile$datapath,
paste(inFile$datapath, ".xlsx", sep=""))
data <-read_excel(paste(inFile$datapath, ".xlsx", sep=""), sheet = 1,col_names = F)
data[c(4,6,8,10,12,14,16),1] <- zoo::na.locf(data[c(4,6,8,10,12,14,16),1])
data[c(4,6,8,10,12,14,16)+1,6]<-ifelse(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))==0,NA,
unname(unlist(data[c(4,6,8,10,12,14,16)+1,6])))
data[c(4,6,8,10,12,14,16)+1,6]<-ifelse(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))==0,NA,
unname(unlist(data[c(4,6,8,10,12,14,16)+1,6])))
data[c(4,6,8,10,12,14,16),3]<-ifelse(unname(unlist(data[c(4,6,8,10,12,14,16),3]))==0,NA,
unname(unlist(data[c(4,6,8,10,12,14,16),3])))
data[c(4,6,8,10,12,14,16)+1,3]<-ifelse(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))==0,NA,
unname(unlist(data[c(4,6,8,10,12,14,16)+1,3])))
bubble <- function(data){
img <- readPNG("1.png")
i <- max(sqrt(abs(parse_number(unname(unlist(c(data[4:17,3],data[4:17,6])))))),na.rm=T)
#shrift <- 7.5+(5.7-max(c(nchar(data[4:17,2]),nchar(data[4:17,4])),na.rm = T)/26)/2-3
#otst <- 10+33-shrift*6
otst <- 25
shrift <- 6
p <- ggplot()+
geom_segment(aes(
y = -4.5,yend=-4.5,xend=max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"))+0.6,
x = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.75),
color="#babdbf"
)+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"))+0.6,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.75,
ymin=-2.3,ymax=-0.2
),fill = '#ebebed')+
geom_linerange(aes(x= as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
ymax=-0.2,ymin=-4.5),color="#babdbf")+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-0.8,yend=-0.8,xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")+0.4,
x= as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)),origin = "1970-01-01")-0.4
)
)}+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-0.8,yend=-1,x=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")-0.4,
xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")
)
)}+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-1.8,yend=-1.8,xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")+0.4,
x= as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)),origin = "1970-01-01")-0.4
)
)}+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-1.8,yend=-2,x=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")-0.4,
xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")
)
)}+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-2.8,yend=-2.8,xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")+0.4,
x= as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)),origin = "1970-01-01")-0.4
)
)}+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-2.8,yend=-3,x=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")-0.4,
xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)),origin = "1970-01-01")
)
)}+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-3.8,yend=-3.8,xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")+0.4,
x= as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),NA)),
origin = "1970-01-01")-0.4
)
)}+
{if(sum(is.na(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
NA)))!=7)geom_segment(
aes(
y=-3.8,yend=-4,x=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")-0.4,
xend=as.Date(na.omit(ifelse(!is.na(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))))),
as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"),NA)),origin = "1970-01-01")
)
)}+
geom_point(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),-1),
size=sqrt(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6])))))/i*25,color=
ifelse(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6])))>0,"#303d7d","#a31e22"))+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),-1.2,
label=format(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6])))),
big.mark=" ")),color=
ifelse(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6])))>0,"#303d7d","#a31e22"),
family="PT Sans",size=5)+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30")-0.4,
-0.75,label=unlist(unname(sapply(unlist(unname(data[c(4,6,8,10,12,14,16),5])),
function(x) paste(strwrap(gsub("((","",unname(unlist(x)),
fixed="TRUE"),otst),
collapse="\n"))))),
size=ifelse(nchar(unlist(unname(data[c(4,6,8,10,12,14,16),2])))<80,input$shrift,shrift),
lineheight=0.9,hjust=0,vjust=0,family="PT Sans",color=
ifelse(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),6])))>0,"black","#a31e22"))+
geom_point(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),-2),
size=sqrt(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6])))))/i*25,color=
ifelse(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6])))>0,"#303d7d","#a31e22"))+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),-2.2,
label=format(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6])))), big.mark=" ")),color=
ifelse(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6])))>0,"#303d7d","#a31e22"),
family="PT Sans",size=5)+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30")-0.4,
-1.75,label=unlist(unname(sapply(unlist(unname(data[c(4,6,8,10,12,14,16)+1,5])),
function(x) paste(strwrap(gsub("((","",unname(unlist(x)),
fixed="TRUE"),otst),
collapse="\n"))))),
size=ifelse(nchar(unlist(unname(data[c(4,6,8,10,12,14,16)+1,5])))<80,input$shrift,shrift),
lineheight=0.9,hjust=0,vjust=0,family="PT Sans",color=
ifelse(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6])))>0,"black","#a31e22"))+
geom_point(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
-3),size=sqrt(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))))/i*25,color="#303d7d")+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
-3.2,label=ifelse(grepl("NA",format(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3])))))),
NA,format(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3])))),
big.mark=" "))),color="#303d7d",family="PT Sans",size=5)+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30")-0.4,
-2.75,label=ifelse(unlist(unname(sapply(unlist(unname(data[c(4,6,8,10,12,14,16),2])),
function(x) paste(strwrap(gsub("((","",unname(unlist(x)),
fixed="TRUE"),20),
collapse="\n"))))=="NA",NA,
unlist(unname(sapply(unlist(unname(data[c(4,6,8,10,12,14,16),2])),
function(x) paste(strwrap(gsub("((","",unname(unlist(x)),
fixed="TRUE"),otst),
collapse="\n")))))),color="black",
size=ifelse(nchar(unlist(unname(data[c(4,6,8,10,12,14,16),1])))<80,input$shrift,shrift),
lineheight=0.9,hjust=0,vjust=0,family="PT Sans")+
geom_point(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
-4),size=sqrt((-parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3])))))/i*25,color="#a31e22")+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
-4.2,label=ifelse(grepl("NA",format(-parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3]))))),
NA,format(abs(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3])))),
big.mark=" "))),color="#a31e22",family="PT Sans",size=5)+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30")-0.4,
-3.75,label=ifelse(unlist(unname(sapply(unlist(unname(data[c(4,6,8,10,12,14,16),2])),
function(x) paste(strwrap(gsub("((","",unname(unlist(x)),
fixed="TRUE"),20),
collapse="\n"))))=="NA",NA,
unlist(unname(sapply(unlist(unname(data[c(4,6,8,10,12,14,16)+1,2])),
function(x) paste(strwrap(gsub("((","",unname(unlist(x)),
fixed="TRUE"),otst),
collapse="\n")))))),color="#a31e22",
size=ifelse(nchar(unlist(unname(data[c(4,6,8,10,12,14,16),2])))<80,input$shrift,shrift),
lineheight=0.9,hjust=0,vjust=0,family="PT Sans")+
geom_point(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
-4.5,size=colSums(rbind(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))),
parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,6]))),
parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),3]))),
parse_number(unname(unlist(data[c(4,6,8,10,12,14,16)+1,3])))),na.rm = T)),
shape=22,color="#babdbf",fill=c("#babdbf","#babdbf","#babdbf","#babdbf","#babdbf","white","white"))+
geom_text(aes(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"),
-4.6,label=substr(as.character(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")),9,10)),color="#a31e22",
family="PT Sans", fontface = "bold",size=5)+
annotation_custom(tele,
xmin=as.numeric(as.Date(parse_number(unname(unlist(data[4,1]))),
origin = "1899-12-30")[1])-0.7,
xmax=as.numeric(as.Date(parse_number(unname(unlist(data[4,1]))),
origin = "1899-12-30")[1])-0.55, ymin=-2.2, ymax=-2)+
annotation_custom(net,
xmin=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.7,
xmax=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.55, ymin=-2.6, ymax=-2.4)+
theme_void(base_family="PT Sans")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-5.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.7,
ymin=-5.2,ymax=-5
),fill="#d8d9da",color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-5.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.7,
ymin=-5.4,ymax=-5.2
),fill=NA,color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-5.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.7,
ymin=-5.6,ymax=-5.4
),fill="#808083",color="#babdbf")+
geom_segment(aes(
y=-5,yend=-5.4,xend=min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30"))-0.2,
x=min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.2
),color="#babdbf")+
#table 2
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-4.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+0.7,
ymin=-5.2,ymax=-5
),fill="#d8d9da",color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-4.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+0.7,
ymin=-5.4,ymax=-5.2
),fill=NA,color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-4.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+0.7,
ymin=-5.6,ymax=-5.4
),fill="#808083",color="#babdbf")+
#table 3
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-3.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+1.7,
ymin=-5.2,ymax=-5
),fill="#d8d9da",color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-3.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+1.7,
ymin=-5.4,ymax=-5.2
),fill=NA,color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-3.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+1.7,
ymin=-5.6,ymax=-5.4
),fill="#808083",color="#babdbf")+
#table 4
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-2.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+2.7,
ymin=-5.2,ymax=-5
),fill="#d8d9da",color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-2.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+2.7,
ymin=-5.4,ymax=-5.2
),fill=NA,color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-2.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+2.7,
ymin=-5.6,ymax=-5.4
),fill="#808083",color="#babdbf")+
#table 5
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-1.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+3.7,
ymin=-5.2,ymax=-5
),fill="#d8d9da",color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-1.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+3.7,
ymin=-5.4,ymax=-5.2
),fill=NA,color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-1.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+3.7,
ymin=-5.6,ymax=-5.4
),fill="#808083",color="#babdbf")+
#table 6
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+4.7,
ymin=-5.2,ymax=-5
),fill="#d8d9da",color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+4.7,
ymin=-5.4,ymax=-5.2
),fill=NA,color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))-0.7,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+4.7,
ymin=-5.6,ymax=-5.4
),fill="#808083",color="#babdbf")+
#table 7
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+0.3,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+5.7,
ymin=-5.2,ymax=-5
),fill="#d8d9da",color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+0.3,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+5.7,
ymin=-5.4,ymax=-5.2
),fill=NA,color="#babdbf")+
geom_rect(aes(
xmax = max(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+0.3,
xmin = min(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),origin = "1899-12-30"))+5.7,
ymin=-5.6,ymax=-5.4
),fill="#808083",color="#babdbf")+
geom_text(aes(as.Date(parse_number(unname(unlist(data[3:9,8]))),origin = "1899-12-30"),-5.1,
label=format(parse_number(unname(unlist(data[3:9,9]))),big.mark=" ")),
family="PT Sans", fontface = "bold",color="#303d7d",size=5
)+
geom_text(aes(as.Date(parse_number(unname(unlist(data[3:9,8]))),origin = "1899-12-30"),-5.3,
label=format(parse_number(unname(unlist(data[3:9,10]))),big.mark=" ")),family="PT Sans",
fontface = "bold",color="#303d7d",size=5
)+
geom_text(aes(as.Date(parse_number(unname(unlist(data[3:9,8]))),origin = "1899-12-30"),-5.5,
label=format(parse_number(unname(unlist(data[3:9,11]))),big.mark=" ")),family="PT Sans",
fontface = "bold",color="#303d7d",size=5
)+
annotation_custom(tele,
xmin=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.65,
xmax=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.55, ymin=-5.05, ymax=-5.15)+
annotation_custom(net,
xmin=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.65,
xmax=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.55, ymin=-5.25, ymax=-5.35)+
annotation_custom(zag,
xmin=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.65,
xmax=as.numeric(as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1])-0.55, ymin=-5.45, ymax=-5.55)+
geom_text(aes(y=-5.1,as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1]-0.52,label="TV"),family="PT Sans",
fontface = "bold",color="#303d7d",hjust=0,size=5)+
geom_text(aes(y=-5.3,as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1]-0.52,label="Internet"),family="PT Sans",
fontface = "bold",color="#303d7d",hjust=0,size=5)+
geom_text(aes(y=-5.5,as.Date(parse_number(unname(unlist(data[c(4,6,8,10,12,14,16),1]))),
origin = "1899-12-30")[1]-0.52,label="Разом:"),family="PT Sans",
fontface = "bold",color="white",hjust=0,size=5)+
scale_x_date(expand = c(0,0)) + scale_y_continuous(expand = c(0,0)) +
theme(
legend.position = "none",
text = element_blank(),
line = element_blank(),
title = element_blank()
)
gt <- ggplot_gtable(ggplot_build(p))
ge <- subset(gt$layout, name == "panel")
grid.draw(gt[ge$t:ge$b, ge$l:ge$r])
p
}
bubble(data)
})
output$plot <- renderPlot({
tryCatch(df())
})
output$downloadPlot <- downloadHandler(
filename = function(){paste0("grolu-",Sys.Date(),".pdf") },
content = function(file) {
cairo_pdf(file, width=16*1.4, height=9*1.4)
print(df())
dev.off()
}
)
output$download<- downloadHandler(
filename = function(){paste0("grolu-",Sys.Date(),".png") },
content = function(file) {
png(file, width=1600, height=900)
print(df())
dev.off()
}
)
})
shinyApp(ui,server)
|
3d7273369b82d5005bb61d5a8ecde2fac719fe81
|
c677505fded0544d5b12900f4f2be751251ef5af
|
/man/plotRDA.Rd
|
b4eb98ee3941ac1da68ed24163e18f6b3d32567b
|
[
"MIT"
] |
permissive
|
isglobal-brge/MEAL
|
03659b5f1b98120fd408f17cbd7553c6f414219f
|
ee9eebb76cd67b56d5be65842832274ff45e8e29
|
refs/heads/master
| 2021-05-15T00:34:10.007907
| 2021-05-05T15:50:14
| 2021-05-05T15:50:14
| 103,267,394
| 2
| 2
| null | null | null | null |
UTF-8
|
R
| false
| true
| 875
|
rd
|
plotRDA.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ResultSet_plotRDA.R
\name{plotRDA}
\alias{plotRDA}
\title{Plot RDA results}
\usage{
plotRDA(object, pheno = data.frame(), n_feat = 5, main = "RDA plot", alpha = 1)
}
\arguments{
\item{object}{\code{ResultSet}}
\item{pheno}{data.frame with the variables used to color the samples.}
\item{n_feat}{Numeric with the number of cpgs to be highlighted. Default: 5.}
\item{main}{Character with the plot title.}
\item{alpha}{Numeric with the alpha level for colour transparance. Default: 1; no
transparency.}
}
\value{
A plot is generated on the current graphics device.
}
\description{
Plot RDA results
}
\examples{
if (require(minfiData)){
set <- ratioConvert(mapToGenome(MsetEx[1:10,]))
model <- model.matrix(~set$sex)
rda <- runRDA(set, model)
plotRDA(rda, pheno = data.frame(factor(set$sex)))
}
}
|
d08387736b554e77d20afe257a2e0edc38a4cce8
|
828e41f70d8f4d2c86e232d62e515e85df099204
|
/graphs/work_sample.R
|
7861dcdb24b9a48094e09ec7068e9c83dbfd89af
|
[] |
no_license
|
jgsogo/muia_tfm
|
6f759006521ac7065b8af51303ac8333f9c8f92c
|
8a15b239ca6ef58d515fb0b4a51f7eae41230358
|
refs/heads/master
| 2021-01-23T07:10:19.398193
| 2015-08-17T08:06:31
| 2015-08-17T08:06:31
| 40,876,491
| 1
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 7,304
|
r
|
work_sample.R
|
# Work over results
library(data.table)
require(ggplot2)
library(reshape)
source("summarySE.R")
parse_sample <- function(file) {
data <- data.frame(read.csv(file=file, header=TRUE, sep="\t"))
}
plot_synset_tol <- function(data, title, save_path) {
# Credit: http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/
tol_rel_values = unique(data[, c("relation.tolerance")])
for (tol_rel in tol_rel_values) {
d_sub <- subset(data, relation.tolerance==tol_rel)
d_sub <- d_sub[, c("translator", "synset.tolerance", "similarity.value")]
colnames(d_sub) <- c("Traductor", "tol", "sim")
d_sub$Traductor <- factor(d_sub$Traductor, levels=c("google", "yandex"), labels=c("Google", "Yandex"))
tgc <- summarySE(d_sub, measurevar="sim", groupvars=c("Traductor", "tol"))
# Standard error of the mean
pd <- position_dodge(0.01) # move them .05 to the left and right
g <- ggplot(tgc, aes(x=tol, y=sim, colour=Traductor)) +
geom_errorbar(aes(ymin=sim-se, ymax=sim+se), width=.1, position=pd) +
geom_line() +
geom_point() +
# ylim(0.0, 1.0) +
ylab("Similaridad") + xlab(paste("Tolerancia entre conceptos\nTolerancia entre relaciones = ", tol_rel, sep="")) +
labs(title=title)
filename = paste("synset_tol", "relation_tol", tol_rel, sep="-")
filename = paste(filename, "png", sep=".")
filepath = file.path(save_path, filename)
print(filepath)
ggsave(filepath, g, width=7, height=4)
}
}
plot_relation_tol <- function(data, title, save_path) {
# Credit: http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/
tol_syn_values = unique(data[, c("synset.tolerance")])
for (tol_syn in tol_syn_values) {
d_sub <- subset(data, synset.tolerance==tol_syn)
d_sub <- d_sub[, c("translator", "relation.tolerance", "similarity.value")]
colnames(d_sub) <- c("Traductor", "tol", "sim")
d_sub$Traductor <- factor(d_sub$Traductor, levels=c("google", "yandex"), labels=c("Google", "Yandex"))
tgc <- summarySE(d_sub, measurevar="sim", groupvars=c("Traductor", "tol"))
# Standard error of the mean
pd <- position_dodge(0.01) # move them .05 to the left and right
g <- ggplot(tgc, aes(x=tol, y=sim, colour=Traductor)) +
geom_errorbar(aes(ymin=sim-se, ymax=sim+se), width=.1, position=pd) +
geom_line() +
geom_point() +
# ylim(0.0, 1.0) +
ylab("Similaridad") + xlab(paste("Tolerancia entre relaciones\nTolerancia entre conceptos = ", tol_syn, sep="")) +
labs(title=title)
filename = paste("relation_tol", "synset_tol", tol_syn, sep="-")
filename = paste(filename, "png", sep=".")
filepath = file.path(save_path, filename)
print(filepath)
ggsave(filepath, g, width=7, height=4)
}
}
plot_distances_synset <- function(data, title, save_path, tol_relation = 0.0) {
distance_measures <- unique(data[, c("distance.meassure")])
translators <- unique(data[, c("translator")])
data <- subset(data, relation.tolerance==tol_relation)
data <- data[, c("translator", "distance.meassure", "synset.tolerance", "similarity.value")]
colnames(data) <- c("Traductor", "Medida", "tol", "sim")
# Google
google_data <- subset(data, Traductor=="google")
google_data <- google_data[, c("Medida", "tol", "sim")]
g <- ggplot(google_data, aes(x=tol, y=sim, colour=Medida)) +
geom_line() +
geom_point() +
ylab("Similaridad") + xlab(paste("Tolerancia entre conceptos\nTolerancia entre relaciones = ", tol_relation, sep="")) +
labs(title=title)
# Yandex
yandex_data <- subset(data, Traductor=="yandex")
yandex_data <- yandex_data[, c("Medida", "tol", "sim")]
y <- ggplot(yandex_data, aes(x=tol, y=sim, colour=Medida)) +
geom_line() +
geom_point() +
ylab("Similaridad") + xlab(paste("Tolerancia entre conceptos\nTolerancia entre relaciones = ", tol_relation, sep="")) +
labs(title=title)
# Save to files
file_google = paste("measures-google-synset", "png", sep=".")
filepath = file.path(save_path, file_google)
ggsave(filepath, g, width=7, height=4)
file_yandex = paste("measures-yandex-synset", "png", sep=".")
filepath = file.path(save_path, file_yandex)
ggsave(filepath, y, width=7, height=4)
}
plot_distances_relation <- function(data, title, save_path, tol_synset = 0.0) {
distance_measures <- unique(data[, c("distance.meassure")])
translators <- unique(data[, c("translator")])
data <- subset(data, synset.tolerance==tol_synset)
data <- data[, c("translator", "distance.meassure", "relation.tolerance", "similarity.value")]
colnames(data) <- c("Traductor", "Medida", "tol", "sim")
# Google
google_data <- subset(data, Traductor=="google")
google_data <- google_data[, c("Medida", "tol", "sim")]
g <- ggplot(google_data, aes(x=tol, y=sim, colour=Medida)) +
geom_line() +
geom_point() +
ylab("Similaridad") + xlab(paste("Tolerancia entre relaciones\nTolerancia entre conceptos = ", tol_synset, sep="")) +
labs(title=title)
# Yandex
yandex_data <- subset(data, Traductor=="yandex")
yandex_data <- yandex_data[, c("Medida", "tol", "sim")]
y <- ggplot(yandex_data, aes(x=tol, y=sim, colour=Medida)) +
geom_line() +
geom_point() +
ylab("Similaridad") + xlab(paste("Tolerancia entre relaciones\nTolerancia entre conceptos = ", tol_synset, sep="")) +
labs(title=title)
# Save to files
file_google = paste("measures-google-relation", "png", sep=".")
filepath = file.path(save_path, file_google)
ggsave(filepath, g, width=7, height=4)
file_yandex = paste("measures-yandex-relation", "png", sep=".")
filepath = file.path(save_path, file_yandex)
ggsave(filepath, y, width=7, height=4)
}
work_sample <- function(file, title) {
data <- parse_sample(file)
filepath = dirname(file)
img_name = basename(file)
img_name = substr(img_name, 0, which(strsplit(img_name, '')[[1]]=='.')-1)
save_path = file.path(filepath, paste(img_name, "brief", sep="-"))
dir.create(save_path, showWarnings = FALSE)
plot_synset_tol(data, title, save_path)
plot_relation_tol(data, title, save_path)
plot_distances_synset(data, title, save_path)
plot_distances_relation(data, title, save_path)
}
work_samples <- function() {
print("Sample 01")
work_sample("sample01.csv", "Ejemplo 1")
print("Sample 02")
work_sample("sample02.csv", "Ejemplo 2")
print("Sample 03")
work_sample("sample03.csv", "Ejemplo 3")
print("Sample 04")
work_sample("sample04.csv", "Ejemplo 4")
print("Sample 05")
work_sample("sample05.csv", "Ejemplo 5")
print("Sample 06")
work_sample("sample06.csv", "Ejemplo 6")
print("Sample 07")
work_sample("sample07.csv", "Ejemplo 7")
print("Sample 08")
work_sample("sample08.csv", "Ejemplo 8")
print("Sample 09")
work_sample("sample09.csv", "Ejemplo 9")
print("Sample 10")
work_sample("sample10.csv", "Ejemplo 10")
}
|
1444b6f5df3421d6ade8aa6658e4da13e3dddd2e
|
189176e43cd9fe06ab4ab8ff698565db8427f0c7
|
/analysis/source/draw_data/draw_data.R
|
657dc48ae3e5af5adf841ac39018525f51a13cf1
|
[
"MIT"
] |
permissive
|
memonb1226/Practice-Task
|
3c9743ba60edaed5428356af521040fd5ecfcecf
|
f3ab358f0e072cffd0c9e90851b14ccba7b5dba3
|
refs/heads/master
| 2022-12-27T01:42:08.184599
| 2020-10-07T03:08:47
| 2020-10-07T03:08:47
| 298,068,106
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 343
|
r
|
draw_data.R
|
library(yaml)
library(MASS)
CONFIG <- yaml.load_file("config_global.yaml")
main <- function() {
simga <- matrix(c(1,.5,.5,1),2,2)
mean <- rep(0, 2)
draw <-mvrnorm(10000, mean, simga)
write.table(draw, sprintf("%s/data.csv", CONFIG$build$draw_data), sep=",",
row.names = FALSE, col.names = FALSE, quote = FALSE)
}
main()
|
aacec07dfafdae72294e4e392b6866b7ee2ad148
|
6467756ff4bc6f6a28b5f2c63421b2d36c163815
|
/Ass 1 Recycling Vectors.R
|
ba3547167ed01198b4a2359513c8f056627df35d
|
[] |
no_license
|
monicamajora/R-Assignment-1
|
a37305a21c326a6919e0087ad1de4a6638b615f9
|
894c79bdc85a79340add15712aa86700cb88d157
|
refs/heads/master
| 2020-04-13T04:57:13.301212
| 2018-12-24T10:00:41
| 2018-12-24T10:00:41
| 162,976,780
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 543
|
r
|
Ass 1 Recycling Vectors.R
|
getwd()
#1...Prescriptive Analytics used to predict the future outcomes? FALSE
#....Base R packages installed automatically?TRUE
#2... R operates on vectors of the same length, so if it sees two vectors of different lengths in a binary operation, it replicates (recycles) the smaller vector until it is the same length as the longest vector.
#3...An example of recycling of elements.
m=c(1:9)
n=c(2:4)
sum=m+n
###Vector n is short,so after adding the first three values of m,we start again adding with the first value of n which is 2.
|
f0138edd7aa8327f90c1ce581b1a685cc6bd6835
|
735af472776c3e90a4d337df478a3f9b6daf5c73
|
/cleanScript.R
|
99b18ae997454904c1d9a3ce5859551e95143d41
|
[] |
no_license
|
acottman1/dataFestTrainingCensus
|
cbbac9f4a6fb8735378540970d0e28d51aa2296b
|
aeb0b24e5e8ad4d616ae0f9eef468f85d502a99d
|
refs/heads/master
| 2021-01-03T09:25:42.630838
| 2020-05-28T02:28:15
| 2020-05-28T02:28:15
| 240,020,122
| 2
| 1
| null | null | null | null |
UTF-8
|
R
| false
| false
| 222
|
r
|
cleanScript.R
|
#remove special characters, commas from character data and save it to a DF
clean <- function(x){
as.numeric( gsub('[^a-zA-Z0-9.]', '', x))
}
dat$avg_Agg_HH_INC_ACS_13_17 <- clean(dat$avg_Agg_HH_INC_ACS_13_17)
str(dat)
|
92f9099e249750c521de9e4884cf377cd075311b
|
f54ee006bee856ea6d10eeb71e64f928cac526a2
|
/Modelo Revenue 2/functions/logistic/build_prod_tables_log.R
|
c6dd0e0e28a8f03a0173732aa2012cfcf765cdaa
|
[] |
no_license
|
lover2668/oil
|
a6f89b8ebf46d312c0cc853c59418abbd0c8ef19
|
a62b4e07d3aaa1fab5e0064c74ef224ad5ecf3be
|
refs/heads/master
| 2020-04-26T03:08:48.746437
| 2017-03-13T20:31:14
| 2017-03-13T20:31:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 1,783
|
r
|
build_prod_tables_log.R
|
build_prod_table_log <- function(transport) {
file_name <- paste('data/log_metrics/Escenarios_',transport,'.xlsx',sep='')
#read all data and returns
temp_table <- read.xlsx (file_name,sheet = 1)
temp_table <- temp_table[temp_table$prioridad==1,]
out_table <- data.frame(num_cuad=temp_table$numVehicles,
prod=(temp_table$completeTasks/temp_table$totalTasks)^0.25)
return(out_table)
}
generates_prod_table_log <- function() {
#executes the logistic scripts and save the files.
gp <- setGlobalParameters()
aux <- makeStackLogFromFiles("data/revenue data.xlsx",
NA,
gp)
stack_log <- aux$stack_log
print(stack_log)
sp <- aux$shortest_paths
logisData <- aux$logisData
rm(aux)
# simulates different resource scenarios
scenarios <- makeScenarios(logisData$recursos)
#redefine scenarios
for (transport_type in setdiff(names(scenarios),'Cisterna')) {
scenarios[[transport_type]] <- 1:10
}
for (transport_type in setdiff(names(scenarios),'Cisterna')) {
fileName <- paste0('data/log_metrics/Escenarios_',transport_type,'.xlsx',collapse="")
simulations <- simulateScenario_changeOneResource(
stack_log, logisData$recursos, scenarios, transport_type, gp)
createExcel_singleRunComparison(simulations, fileName,
scenarios, transport_type)
}
#### 3. generates the prod_table_log ####
transports <- setdiff(names(scenarios),'Cisterna')
prod_table_log <- list()
for (transport in transports) {
prod_table_log[[transport]] <- build_prod_table_log(transport)
}
save(prod_table_log, file = "prod_table_log.RData")
return(prod_table_log)
}
|
1044d513e8bcfba9163107a15f9831e329b33824
|
257ffc3438528729b62bc3e7abc24eea2be6193e
|
/man/shud.filein.Rd
|
90a5fb69794533986559d177ce1777f9948130f6
|
[
"MIT"
] |
permissive
|
SHUD-System/rSHUD
|
91e1ae7f077cf5efa52575a32ed4e692ed8034b9
|
1915a9cf2b241a1368b9768251b2f140454bd94e
|
refs/heads/master
| 2023-07-06T11:07:18.335307
| 2023-07-01T15:08:11
| 2023-07-01T15:08:11
| 224,737,854
| 6
| 0
| null | null | null | null |
UTF-8
|
R
| false
| true
| 746
|
rd
|
shud.filein.Rd
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Project.R
\name{shud.filein}
\alias{shud.filein}
\title{Prepare Input file of SHUD model
\code{shud.filein}}
\usage{
shud.filein(
projname = get("PRJNAME", envir = .shud),
inpath = get("inpath", envir = .shud),
outpath = get("outpath", envir = .shud)
)
}
\arguments{
\item{projname}{Character, project name, default= PRJNAME which is a global variable.}
\item{inpath}{SHUD model input directory, default = inpath which is global variable}
\item{outpath}{SHUD model output directory, default = outpath which is global variable}
}
\value{
Character of full path of input files for SHUD model
}
\description{
Prepare Input file of SHUD model
\code{shud.filein}
}
|
3720402f86ee69b5b186414019e14f6abd04a829
|
9f9011d2f7fa105a392a56bae77e89a807a97abb
|
/mse_error_rho.R
|
0b5b7f6feb26aa99452ae898145b768d4410fc1d
|
[
"MIT"
] |
permissive
|
CTsicarius/ESN_R
|
4d40fc60e04287001fc6f90e0aaa8d408ad87125
|
3cd4b7f72666e6c81f8fe0e2a6786d69198a676c
|
refs/heads/master
| 2020-03-30T23:14:01.676874
| 2018-10-24T06:53:47
| 2018-10-24T06:53:47
| 151,694,701
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 2,862
|
r
|
mse_error_rho.R
|
library(MASS)
library(Rcpp)
library(RcppArmadillo)
wd <- getwd()
source(paste(wd, 'var_utils.R', sep = '/'))
source(paste(wd, 'esn_utils.R', sep = '/'))
#SIM PARAMETERS
N_sim <- 1
print_det = FALSE
#DATA PARAMETERS
seed = 42
N <- 1
Ny <- 1
Nu <- 1
PHI_ro = 0.2
N_test <- 10000
sigma <- 0.1
#ESN PARAMETERS
Nx <- 5000
w_ro <- 0.001
w_dens <- 0.5
alpha <- 1
beta <- 5
set.seed(42)
number_of_train <- c(25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000, 25000, 50000)
#rho_array <- c(0, 0.0001, 0.001, 0.01, 0.1, 0.25, 0.5, 0.75, 0.9, 1)
rho_array <- c(0, 0.25, 0.5, 0.75, 0.9)
MSE_array_var <- matrix(0, length(number_of_train), 1)
MSE_array_esn <- matrix(0, length(number_of_train), length(rho_array))
phi <- matrix(rnorm(1:N), N, 1)
PHI1 <- generate_PHI_normal(N = N, mu = 0, sigma = 1, ro = 0.8)
PHI2 <- generate_PHI_normal(N = N, mu = 0, sigma = 1, ro = 0.95)
#global_train_data <-generate_var2(number_of_train[length(number_of_train)], phi, PHI1, PHI2, diag(sigma, N, N))#4.5 secs
#global_train_data <- generate_var1(number_of_train[length(number_of_train)], phi, PHI1, diag(sigma, N, N)) #4.5 secs
global_train_data = matrix(c(1, 1, 1, 0, 0, 1, 1, 0), 1, 50000)
#test_data <- generate_var2(N_test, phi, PHI1, PHI2, diag(sigma, N, N))
#test_data <- generate_var1(N_test, phi, PHI1, diag(sigma, N, N))
test_data = matrix(c(1, 0, 0, 1, 1, 0, 1, 1), 1, 10000)
time0 <- proc.time()
print('OK1')
Win <- generate_Win(Nx = Nx, Nu = Nu, mu = 0, sigma = 1)
for (rho_idx in 1:length(rho_array)){
W <- as.matrix(generate_W(Nx = Nx, density = w_dens, sigma = 1, ro = rho_array[rho_idx]))
train_x <- calculate_x_c(u = matrix(global_train_data[, 1:number_of_train[length(number_of_train)]], 1, number_of_train[length(number_of_train)]),
W = W, Win = Win, alpha = alpha)
test_x <- calculate_x_c(u = test_data, W = W, Win = Win, alpha = alpha)
for (i in 1:length(number_of_train)){
#CODE FOR VAR ERROR
train_data <- matrix(global_train_data[, 1:number_of_train[i]], 1, number_of_train[i])
PHI_est <- estimate_var2_parameters(train_data)
var_pred_val <- make_var2_predictions(test_data, PHI_est)
MSE_array_var[i, 1] <- MSE_error(test_data[, 3:N_test, drop = FALSE], var_pred_val)
#CODE FOR ESN ERROR
Wout <- train_Wout(y = train_data[, 2:number_of_train[i], drop = FALSE],
u = train_data[, 1:(number_of_train[i] - 1), drop = FALSE],
W = W, Win = Win, x = train_x[, 1:(number_of_train[i] - 1)],
alpha = alpha, beta = beta, print_det = print_det)
esn_pred_val <- make_esn_predictions(u = test_data, W = W, Win = Win, x = test_x, alpha = alpha, Wout = Wout)
MSE_array_esn[i, rho_idx] <- MSE_error(test_data[, 3:N_test, drop = FALSE], esn_pred_val[, 2:(N_test - 1), drop = FALSE])
}
}
print(proc.time() - time0)
|
677ebe6dc9e8e2ac02bb78b81c3bb95a3d3fec76
|
6a28ba69be875841ddc9e71ca6af5956110efcb2
|
/Statistics_For_Business_And_Economics_by_Anderson_Sweeney_And_Williams/CH10/EX10.2a/Ex10_2a.R
|
61ed0ecc03607d6fcdc88e46a74c296994cd1532
|
[] |
permissive
|
FOSSEE/R_TBC_Uploads
|
1ea929010b46babb1842b3efe0ed34be0deea3c0
|
8ab94daf80307aee399c246682cb79ccf6e9c282
|
refs/heads/master
| 2023-04-15T04:36:13.331525
| 2023-03-15T18:39:42
| 2023-03-15T18:39:42
| 212,745,783
| 0
| 3
|
MIT
| 2019-10-04T06:57:33
| 2019-10-04T05:57:19
| null |
UTF-8
|
R
| false
| false
| 832
|
r
|
Ex10_2a.R
|
# Page no. : 415 - 417
# Inference about the Difference between the two Population Means Sigma 1 and Sigma 2 Unknown
s1 <- 150
s2 <- 125
n1 <- 28
n2 <- 22
xbar1 <- 1025
xbar2 <- 910
point_estimate <- xbar1 - xbar2
numerator <- ((((s1)**2 /n1) + ((s2)**2 /n2))**2)
denomenator <- ((1 /(n1 -1)) * (((s1)**2 / n1)**2)) + ((1 /(n2 -1)) * (((s2)**2 / n2)**2))
df <- numerator / denomenator # Degree of Freedom
t_value <- qt(0.975,df) # alpha/2 = 0.05/2 = 0.025 = 1- 0.025 = 0.975
standard_error <- sqrt((((s1)^2)/(n1)) + (((s2)^2)/(n2)))
IE1 <- point_estimate + t_value*standard_error
IE2 <- point_estimate - t_value*standard_error
cat("The interval estimation for the given information at 95% confidence level is ",IE2 ,
"to", IE1)
|
c8a7c1058789d490d0ff687f343765745d8fc7b3
|
9acda93c7ff9fd5510edae289a4be49d1f8b2503
|
/R/DispConPwrAll.R
|
df402a2ba8d4f28268dfa13ff82606d101d418a4
|
[] |
no_license
|
cran/CP
|
143eff1ddd628372b7ddb22db8c77a0d2ddf436d
|
bccf2da45a9ac30b5c02045d7c9fba69eda3bd13
|
refs/heads/master
| 2023-05-26T21:51:35.320827
| 2023-05-19T13:20:05
| 2023-05-19T13:20:05
| 25,158,240
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 2,495
|
r
|
DispConPwrAll.R
|
DispConPwrAll <- function(gamma.theta.0.exp,
gamma.theta.0.nonmix.exp,
gamma.theta.0.nonmix.wei,
gamma.theta.0.nonmix.gamma,
group1.name, group2.name) {
## Prints the calculated conditional power.
##
## Args:
## gamma.theta.0.exp: Conditional power within the exponential model.
## gamma.theta.0.nonmix.exp: Conditional power within the non-mixture model
## with exponential survival.
## gamma.theta.0.nonmix.wei: Conditional power within the non-mixture model
## with Weibull type survival.
## gamma.theta.0.nonmix.gamma: Conditional power within the non-mixture model
## with Gamma type survival.
## group1.name: Name of group 1.
## group2.name: Name of group 2.
##
## Results:
## Returns the calculated conditional power.
res <- data.frame(c(formatC(x = gamma.theta.0.exp,
digits = 4,
format = "f"),
formatC(x = gamma.theta.0.nonmix.exp,
digits = 4,
format = "f"),
formatC(x = gamma.theta.0.nonmix.wei,
digits = 4,
format = "f"),
formatC(x = gamma.theta.0.nonmix.gamma,
digits = 4,
format = "f")),
row.names = c("Exponential",
"Non-Mixture-Exponential",
"Non-Mixture-Weibull",
"Non-Mixture-Gamma"))
colnames(x = res) <- "Conditional Power"
cat("Conditional Power", "\n")
cat("-----------------", "\n")
print(x = res)
cat("\n")
message(paste("Note: Conditional power is calculated in view of the hazard ratio which is defined as the ratio of the hazard of group ",
group2.name,
" to the hazard of group ",
group1.name,
".",
sep = ""))
}
|
fd5e23054fca3ab2b232a8811275c64defc142b8
|
7a95abd73d1ab9826e7f2bd7762f31c98bd0274f
|
/meteor/inst/testfiles/ET0_ThornthwaiteWilmott/libFuzzer_ET0_ThornthwaiteWilmott/ET0_ThornthwaiteWilmott_valgrind_files/1612735762-test.R
|
c3110e3762638ddd1119ac022b3de72af8878ff9
|
[] |
no_license
|
akhikolla/updatedatatype-list3
|
536d4e126d14ffb84bb655b8551ed5bc9b16d2c5
|
d1505cabc5bea8badb599bf1ed44efad5306636c
|
refs/heads/master
| 2023-03-25T09:44:15.112369
| 2021-03-20T15:57:10
| 2021-03-20T15:57:10
| 349,770,001
| 0
| 0
| null | null | null | null |
UTF-8
|
R
| false
| false
| 532
|
r
|
1612735762-test.R
|
testlist <- list(doy = c(-2.14820462865696e+139, 1.19979472795022e-309, -2.08399199030036e+139, -2.14820462865696e+139, -2.14820462865696e+139, -2.14820462865696e+139, 2.77447923393688e+180, 2.77448001762435e+180, 2.75117951516237e+180, 2.77448001762435e+180, 2.77448001762435e+180, 2.77448001762435e+180, 2.77448001762435e+180, 5.33073945694528e-304, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), latitude = numeric(0), temp = -2.14820462865696e+139)
result <- do.call(meteor:::ET0_ThornthwaiteWilmott,testlist)
str(result)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.