Created
October 7, 2019 11:10
-
-
Save KamilSJaron/be74a7eb7ecda15662452a0dc7292859 to your computer and use it in GitHub Desktop.
ProcB solicatations assigment script
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/env Rscript | |
# an R script that processes copy-pasted bioRxiv info | |
# and outputs an csv table with assigned names | |
in_file <- commandArgs(trailingOnly=TRUE)[1] | |
# 'ProcB_Bioinfo_Sep2019.csv' | |
plain_text <- matrix(readLines(in_file), byrow = T, ncol = 4)[,1:3] | |
final_preprint_tab <- data.frame(title = plain_text[,1], | |
authors = plain_text[,2], | |
doi = sapply(strsplit(plain_text[,3], 'doi: '), function(x){x[2]}) ) | |
# randomize rows | |
final_preprint_tab <- final_preprint_tab[sample(nrow(final_preprint_tab)),] | |
# assign one of us to each preprint | |
name_vector <- c('Kamil', 'Tyler', 'Beth', 'Robin') | |
replicates_of_name_vec <- ceiling(nrow(final_preprint_tab) / length(name_vector)) | |
final_preprint_tab$assigned <- rep(name_vector, replicates_of_name_vec)[c(1:nrow(final_preprint_tab))] | |
# sort by name | |
final_preprint_tab <- final_preprint_tab[order(final_preprint_tab$assigned, decreasing = F),] | |
final_preprint_tab$number <- c(1:nrow(final_preprint_tab)) | |
# order columns | |
final_preprint_tab <- final_preprint_tab[, c('number', 'assigned', 'title', 'authors', 'doi')] | |
out_file <- paste0(unlist(strsplit(in_file, '\\..'))[1], '_assigned.csv') | |
write.table(final_preprint_tab, out_file, quote = F, row.names = F, sep = '\t') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment