This file contains hidden or 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
#' Run the Linux top command | |
#' | |
#' @param user character value indicating a system user to filter tasks by | |
#' @param pid one or more process ids to retrieve | |
#' | |
#' @return | |
#' A data.frame value containing the information returned by top. | |
#' | |
sys.top <- function(user=Sys.getenv("USER"),pid=NULL){ | |
# Run top in batch mode "-b" once "-n 1" |
This file contains hidden or 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(stringr) | |
package_names_from_description <- function(pkg, imports=TRUE){ | |
# include imports as well as depends | |
deps <- c("Depends",if(imports)"Imports") | |
pkg_descr <- packageDescription(pkg,fields=deps) | |
pkg_list <- unlist(pkg_descr) | |
pkg_list <- pkg_list[!is.na(pkg_list)] | |
if (length(pkg_list)==0)return(character(0)) | |
pkg_full_names <- unlist(str_split(as.character(pkg_list),",")) | |
# Strip the version info from the name |
This file contains hidden or 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
#' Find local maxima and minima in R | |
#' @param x numeric vector to search for peaks | |
#' @param partial whether or not to include partial peaks | |
#' at the beginning or end of the vector | |
#' @param decreasing whether to find peaks (the default) | |
#' or valleys | |
which.peaks <- function(x,partial=TRUE,decreasing=FALSE){ | |
if (decreasing){ | |
if (partial){ | |
which(diff(c(TRUE,diff(x)<=0,FALSE))>0) |