-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
huge update, cleaned up all functions from Rprofile into this package…
…, major relief. still alot of working documenting and perhaps changing some names, but the core functionality is now in the package instead of my .Rprofile.
- Loading branch information
Showing
80 changed files
with
2,408 additions
and
88 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
^data-raw$ |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#' closes all open data viewers in linux | ||
#' | ||
#' @description requires wmctrl to be installed. sudo apt-get install wmctrl in Ubuntu (and perhaps also other debian-based systems) | ||
#' | ||
#' @param argument1 arg-description | ||
#' | ||
#' @return This function returns \code{the url} blah blah blah | ||
#' @examples | ||
#'\dontrun{ | ||
#' function(arg1) | ||
#'} | ||
#' @export | ||
|
||
cv <- function(){ | ||
cmd <- paste0('wmctrl -c "Data:" -v') | ||
ok <- TRUE | ||
while(ok){ | ||
out <- suppressWarnings(system(cmd,intern=TRUE,ignore.stderr=TRUE)) | ||
Sys.sleep(0.1) | ||
ok <- is.null(attr(out,"status")) | ||
print(ok) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' short description 1 | ||
#' | ||
#' @description descriptin 2?? | ||
#' | ||
#' @param argument1 arg-description | ||
#' | ||
#' @importFrom clipr write_clip | ||
#' | ||
#' @return This function returns \code{the url} blah blah blah | ||
#' @examples | ||
#'\dontrun{ | ||
#' function(arg1) | ||
#'} | ||
#' @export | ||
|
||
# ikke så vigtig lige nu - skriv til clipboard | ||
# #' @export | ||
# # write to clip manager | ||
dt_write_clip <- function(df1, var, n=10, all=FALSE, sample=TRUE) { | ||
# require(clipr) | ||
if(all==TRUE) n <- nrow(df1) | ||
|
||
if(sample==TRUE) { | ||
clipr::write_clip( | ||
df1[seq(1,nrow(df1),ceiling((nrow(df1)/n))), get(var)] | ||
, col.names=F) | ||
} else clipr::write_clip(df1[1:n, get(var)] , col.names=F) | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#' short description 1 | ||
#' | ||
#' @description descriptin 2?? | ||
#' | ||
#' | ||
#' @import data.table | ||
#' | ||
#' @return This function returns \code{the url} blah blah blah | ||
#' @examples | ||
#'\dontrun{ | ||
#' function(arg1) | ||
#'} | ||
#' @export | ||
|
||
|
||
|
||
dtcolc <- function(dt, ...) { | ||
thecols <- colc(dt, ...) | ||
dt[, thecols, with = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' short description 1 | ||
#' | ||
#' @description descriptin 2?? | ||
#' | ||
#' @param argument1 arg-description | ||
#' | ||
#' @importFrom scales percent | ||
#' @importFrom stats quantile | ||
#' @import data.table | ||
#' | ||
#' @return This function returns \code{the url} blah blah blah | ||
#' @examples | ||
#'\dontrun{ | ||
#' function(arg1) | ||
#'} | ||
#' @export | ||
|
||
|
||
# quantiler som data.table | ||
dtquantile <- function(x,start=0,slut=1,interval=0.05,char=TRUE, na.rm=TRUE) { | ||
# x <- sru1$name_ssh | ||
# start <- 0 | ||
# slut <- 1 | ||
# interval <- 0.05 | ||
# char <- TRUE | ||
# na.rm <- TRUE | ||
value <- value_chr <- NULL # programming with data.table | ||
|
||
seq_vector <- seq(start,slut,interval) | ||
dtx <- data.table( | ||
value=quantile(x,seq_vector,na.rm=na.rm), | ||
p_char=scales::percent(seq_vector), | ||
p=seq_vector*100 | ||
) | ||
if( char==TRUE){ | ||
dtx[, value_chr := eu_format(value)] | ||
setcolorder(dtx, 'value_chr') | ||
return(copy(dtx)) # output | ||
} else(return(dtx)) | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' short description 1 | ||
#' | ||
#' @description descriptin 2?? | ||
#' | ||
#' @param argument1 arg-description | ||
#' | ||
#' @importFrom purrr map | ||
#' @import data.table | ||
#' | ||
#' @return This function returns \code{the url} blah blah blah | ||
#' @examples | ||
#'\dontrun{ | ||
#' function(arg1) | ||
#'} | ||
#' @export | ||
|
||
|
||
|
||
|
||
# function til at taelle antal i kategorier | ||
dttools_catn <- function(dt, varliste) { | ||
# dt <- copy(ae1)oe | ||
# varliste <- c('howmanyfirms') | ||
map(varliste, ~ { | ||
# .x <- varliste | ||
dt_out <- dt[, .N, by=.x] [, `:=` (pct = round(100*(N/sum(N)),1), and = round(N/sum(N), 4))] | ||
dt_out[order(get(.x))] | ||
}) | ||
} |
Oops, something went wrong.