This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(jsonlite) | |
library(png) | |
library(glue) | |
library(ragg) | |
library(here) | |
library(showtext) | |
library(ggdark) | |
library(ggtext) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gmail.send <- function(username, password, emailto, sub, msg) | |
{ | |
frommailuser <- paste(username,"@gmail.com", sep='') | |
com1 <- paste("sendEmail -f", frommailuser, "-t", emailto, "-o message-charset=utf-8 -u") | |
com2 <- "-m " | |
com3 <- paste("-o message-format=text -s smtp.gmail.com -o tls=yes -xu", username, "-xp", password) | |
system(paste(com1, sub, com2, msg, com3)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(geofacet) | |
library(ggplot2) | |
mygrid <- data.frame( | |
row = c(1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, | |
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | |
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, | |
8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11), | |
col = c(1, 5, 18, 19, 4, 10, 1, 12, 17, 18, 3, 4, 5, 9, 10, 15, 12, 13, 8, 9, | |
10, 17, 18, 20, 1, 3, 14, 15, 16, 4, 5, 6, 7, 12, 13, 7, 8, 9, 10, 17, | |
14, 15, 16, 3, 4, 5, 6, 12, 7, 8, 9, 10, 18, 13, 14, 15, 16, 3, 4, 5, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/Rscript | |
# Пакеты | |
library("httr") | |
library("XML") | |
library("stringr") | |
library("ggplot2") | |
library("telegram") | |
library("RCurl") | |
library("httr") | |
library("Cairo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Функция-парсер протокола репертуарной решетки из программы | |
# KELLY (В.И. Похилько, Н.Н. Страхов) Автор: Юрий Тукачев | |
# yurij.tukachev@gmail.com | |
importKellyGrid <- function(file, dir = NULL, encode = "UTF-8") { | |
# Необходимые пакеты | |
require(stringr) | |
require(OpenRepGrid) | |
require(tcltk) | |
if (!is.null(dir)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p.disagreement <- function(data) { | |
n <- ncol(data) | |
m <- matrix(0, n, n) | |
rownames(m) <- names(data) | |
colnames(m) <- names(data) | |
for (i in 1:n) { | |
for (j in i:n) { | |
m[i, j] <- mean(data[, i] != data[, j]) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# only works in linux | |
# Install xclip first | |
# $ sudo apt-get install xclip | |
# write to clipboard | |
wclip <- function(x, sep="\t", row.names=FALSE, col.names=TRUE){ | |
con <- pipe("xclip -selection clipboard -i", open="w") | |
write.table(x, con, sep=sep, row.names=row.names, col.names=col.names) | |
close(con) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cowsay <- function(x) { | |
system(paste0("cowsay ", "'", x, "'")) | |
} | |
cowsay("Вечная загадка мира — это его познаваемость. …Сам факт этой познаваемости представляется чудом.") | |
#> cowsay("Вечная загадка мира — это его познаваемость. …Сам факт этой познаваемости представляется чудом.") | |
# _____________________________________ | |
#/ Вечная загадка мира — это его \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dest <- "~/pdf" | |
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE) | |
sapply(myfiles, FUN = function(i){ | |
file.rename(from = i, to = paste0(dirname(i), "/", gsub(" ", "", basename(i)))) | |
}) | |
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE) | |
lapply(myfiles, function(i) system(paste('"pdftotext" -layout', paste0('"', i, '"')), wait = FALSE) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# McCrae's rpa (r profile agreement): calc&plot :) | |
rpa <- function(p1, p2){ | |
if (length(p1) != length(p2)) | |
stop("'p1' and 'p2' must have the same length") | |
k <- length(p1) | |
pr1 <- (p1 - 5.5)/2 | |
pr2 <- (p2 - 5.5)/2 | |
sumM.sq <- sum(((pr1 + pr2)/2)^2) | |
sumd.sq <- sum((pr1 - pr2)^2) | |
ipa <- (k + 2*sumM.sq - sumd.sq) / sqrt(10*k) |