From 0a2d416075bd8722ec57d8819e748d7666d05b15 Mon Sep 17 00:00:00 2001 From: Stefan Widgren Date: Sat, 2 Nov 2019 09:53:43 +0100 Subject: [PATCH] code style: add space after comma --- R/ingoing-contact-chain.R | 2 +- R/network-summary.R | 2 +- R/outgoing-contact-chain.R | 2 +- R/plot.R | 2 +- R/report.R | 13 ++++++------- R/shortest-paths.R | 18 ++++++++---------- R/trace.R | 30 +++++++++++++++--------------- R/tree.R | 14 ++++++-------- 8 files changed, 39 insertions(+), 44 deletions(-) diff --git a/R/ingoing-contact-chain.R b/R/ingoing-contact-chain.R index ef4a43d..88283ac 100644 --- a/R/ingoing-contact-chain.R +++ b/R/ingoing-contact-chain.R @@ -186,7 +186,7 @@ setMethod("IngoingContactChain", "for outgoing contacts") } - return(length(setdiff(x@source,x@root))) + return(length(setdiff(x@source, x@root))) } ) diff --git a/R/network-summary.R b/R/network-summary.R index 443fb99..92a64d5 100644 --- a/R/network-summary.R +++ b/R/network-summary.R @@ -194,7 +194,7 @@ ##' ##' ## When calculating the network summary for a data.frame of movements ##' ## a data.frame for each combination of root, tEnd and days are returned. -##' root <- c(1,2,3) +##' root <- c(1, 2, 3) ##' tEnd <- c("2005-09-01", "2005-10-01") ##' days <- c(30, 45) ##' diff --git a/R/outgoing-contact-chain.R b/R/outgoing-contact-chain.R index 1420aa9..1666ad2 100644 --- a/R/outgoing-contact-chain.R +++ b/R/outgoing-contact-chain.R @@ -137,7 +137,7 @@ setMethod("OutgoingContactChain", stop("Unable to determine OutgoingContactChain for ingoing contacts") } - return(length(setdiff(x@destination,x@root))) + return(length(setdiff(x@destination, x@root))) } ) diff --git a/R/plot.R b/R/plot.R index 1255697..9413dce 100644 --- a/R/plot.R +++ b/R/plot.R @@ -104,7 +104,7 @@ setMethod("plot", if (is.null(vertices)) { vertices <- tree$outgoing } else { - vertices <- rbind(vertices, tree$outgoing[-1,]) + vertices <- rbind(vertices, tree$outgoing[-1, ]) } } diff --git a/R/report.R b/R/report.R index 7b31754..bdcaa52 100644 --- a/R/report.R +++ b/R/report.R @@ -59,7 +59,7 @@ html_detailed_table <- function(contacts, direction) { arrow <- "→" } - contacts <- contacts[order(contacts$t, contacts$id, decreasing = FALSE),] + contacts <- contacts[order(contacts$t, contacts$id, decreasing = FALSE), ] contacts$id <- as.character(contacts$id) contacts$id[is.na(contacts$id)] <- " " @@ -100,8 +100,7 @@ html_detailed_table <- function(contacts, direction) { }))) } -html_report <- function(x) -{ +html_report <- function(x) { lines <- c("", "", sprintf("%s", x@root), @@ -174,9 +173,9 @@ html_report <- function(x) df$rhs <- df$source lines <- c(lines, - html_detailed_table(df[df$destination == df$root,], "in")) + html_detailed_table(df[df$destination == df$root, ], "in")) - df <- df[df$destination != df$root,] + df <- df[df$destination != df$root, ] if (nrow(df) > 0) { lines <- c(lines, "
", @@ -196,9 +195,9 @@ html_report <- function(x) df$lhs <- df$source df$rhs <- df$destination - html_detailed_table(df[df$source == df$root,], "out") + html_detailed_table(df[df$source == df$root, ], "out") - df <- df[df$source != df$root,] + df <- df[df$source != df$root, ] if (nrow(df) > 0) { lines <- c(lines, "
", diff --git a/R/shortest-paths.R b/R/shortest-paths.R index 925dc2d..6d7c80a 100644 --- a/R/shortest-paths.R +++ b/R/shortest-paths.R @@ -133,23 +133,22 @@ setGeneric("ShortestPaths", ##' @export setMethod("ShortestPaths", signature(x = "ContactTrace"), - function(x) - { + function(x) { ns <- NetworkStructure(x) - ns.in <- ns[ns$direction == "in",] - ns.out <- ns[ns$direction == "out",] + ns.in <- ns[ns$direction == "in", ] + ns.out <- ns[ns$direction == "out", ] result <- NULL if (nrow(ns.in)) { - ns.in <- ns.in[order(ns.in$distance, ns.in$source),] - ns.in <- ns.in[!duplicated(ns.in$source),] + ns.in <- ns.in[order(ns.in$distance, ns.in$source), ] + ns.in <- ns.in[!duplicated(ns.in$source), ] ns.in$destination <- NA_character_ result <- ns.in } if (nrow(ns.out)) { - ns.out <- ns.out[order(ns.out$distance, ns.out$destination),] - ns.out <- ns.out[!duplicated(ns.out$destination),] + ns.out <- ns.out[order(ns.out$distance, ns.out$destination), ] + ns.out <- ns.out[!duplicated(ns.out$destination), ] ns.out$source <- NA_character_ result <- rbind(result, ns.out) } @@ -175,8 +174,7 @@ setMethod("ShortestPaths", inBegin = NULL, inEnd = NULL, outBegin = NULL, - outEnd = NULL) - { + outEnd = NULL) { ## Check that arguments are ok from various perspectives... ## Check the data.frame x with movements diff --git a/R/trace.R b/R/trace.R index af741f8..c62af41 100644 --- a/R/trace.R +++ b/R/trace.R @@ -455,10 +455,10 @@ Trace <- function(movements, trace_contacts <- .Call("traceContacts", - as.integer(factor(movements$source, levels=levels(nodes))), - as.integer(factor(movements$destination, levels=levels(nodes))), + as.integer(factor(movements$source, levels = levels(nodes))), + as.integer(factor(movements$destination, levels = levels(nodes))), as.integer(julian(movements$t)), - as.integer(factor(root, levels=levels(nodes))), + as.integer(factor(root, levels = levels(nodes))), as.integer(julian(inBegin)), as.integer(julian(inEnd)), as.integer(julian(outBegin)), @@ -488,12 +488,12 @@ Trace <- function(movements, root = root[i], tBegin = inBegin[i], tEnd = inEnd[i], - source = contacts[,1], - destination = contacts[,2], - t = contacts[,3], - id = contacts[,4], - n = contacts[,5], - category = contacts[,6], + source = contacts[, 1], + destination = contacts[, 2], + t = contacts[, 3], + id = contacts[, 4], + n = contacts[, 5], + category = contacts[, 6], index = index, distance = distance, direction = "in") @@ -516,12 +516,12 @@ Trace <- function(movements, root = root[i], tBegin = outBegin[i], tEnd = outEnd[i], - source = contacts[,1], - destination = contacts[,2], - t = contacts[,3], - id = contacts[,4], - n = contacts[,5], - category = contacts[,6], + source = contacts[, 1], + destination = contacts[, 2], + t = contacts[, 3], + id = contacts[, 4], + n = contacts[, 5], + category = contacts[, 6], index = index, distance = distance, direction = "out") diff --git a/R/tree.R b/R/tree.R index 2d992a3..c3c42bb 100644 --- a/R/tree.R +++ b/R/tree.R @@ -27,14 +27,13 @@ ##' \code{data.frame} with the tree. The fields are \code{NULL} if ##' there are no in- or outgoing contacts. ##' @keywords internal -build_tree <- function(network_structure) -{ +build_tree <- function(network_structure) { stopifnot(is.data.frame(network_structure)) root <- unique(network_structure$root) stopifnot(identical(length(root), 1L)) - tree.in <- network_structure[network_structure$direction == "in",] - tree.out <- network_structure[network_structure$direction == "out",] + tree.in <- network_structure[network_structure$direction == "in", ] + tree.out <- network_structure[network_structure$direction == "out", ] result <- list(ingoing=NULL, outgoing=NULL) @@ -46,7 +45,7 @@ build_tree <- function(network_structure) if (nrow(tree.in)) { i <- order(tree.in$distance, tree.in$source) tree.in <- tree.in[i, c("source", "distance")] - tree.in <- tree.in[!duplicated(tree.in$source),] + tree.in <- tree.in[!duplicated(tree.in$source), ] tree.in$parent <- NA_character_ colnames(tree.in)[1:2] <- c("node", "level") tree.in <- tree.in[, colnames(root_node)] @@ -76,7 +75,7 @@ build_tree <- function(network_structure) if (nrow(tree.out)) { i <- order(tree.out$distance, tree.out$destination) tree.out <- tree.out[i, c("destination", "distance")] - tree.out <- tree.out[!duplicated(tree.out$destination),] + tree.out <- tree.out[!duplicated(tree.out$destination), ] tree.out$parent <- NA_character_ colnames(tree.out)[1:2] <- c("node", "level") tree.out <- tree.out[, colnames(root_node)] @@ -142,8 +141,7 @@ position_tree <- function(tree, left_size = 1, right_size = 1, top_size = 1, - bottom_size = 1) -{ + bottom_size = 1) { ## Clean up the positioning of small sibling subtrees apportion <- function(node) { left_most <- first_child(node)