From 477db7dfecac3a6776e1584fef75d9ad8aa8d829 Mon Sep 17 00:00:00 2001
From: Bergant <darko.bergant@adacta.si>
Date: Tue, 15 Dec 2015 04:37:45 +0100
Subject: [PATCH] Check calculation hierarchy + minor changes

---
 .Rbuildignore                  |  2 ++
 .gitignore                     |  1 +
 .travis.yml                    |  6 ++++++
 DESCRIPTION                    | 21 ++++++++++++---------
 NAMESPACE                      |  4 +---
 R/finstr.R                     | 32 ++++++++++++++++++++++++--------
 R/finstr_plot.R                | 16 ----------------
 R/finstr_print.R               |  2 +-
 README.Rmd                     |  4 ++--
 man/autoplot.statement.Rd      | 18 ------------------
 man/calculate.Rd               | 10 +++++-----
 man/calculation.Rd             |  2 +-
 man/check_statement.Rd         |  2 +-
 man/diff.statement.Rd          |  2 +-
 man/expose.Rd                  |  5 +++--
 man/get_ascendant.Rd           |  2 +-
 man/get_descendants.Rd         |  2 +-
 man/get_elements.Rd            |  2 +-
 man/get_elements_h.Rd          |  2 +-
 man/get_parent.Rd              |  2 +-
 man/grapes-without-grapes.Rd   |  2 +-
 man/merge.elements.Rd          |  2 +-
 man/merge.statement.Rd         | 12 +++++++-----
 man/merge.statements.Rd        |  6 ++++--
 man/other.Rd                   |  2 +-
 man/plot_double_stacked_bar.Rd |  2 +-
 man/plot_waterfall.Rd          |  2 +-
 man/print.check.Rd             |  2 +-
 man/print.statement.Rd         |  2 +-
 man/print.statements.Rd        |  2 +-
 man/proportional.Rd            |  2 +-
 man/reshape_long.Rd            | 12 +++++-------
 man/reshape_table.Rd           |  2 +-
 man/xbrl_create_data.Rd        |  2 +-
 man/xbrl_data_aapl2013.Rd      |  4 ++--
 man/xbrl_data_aapl2014.Rd      |  4 ++--
 man/xbrl_get_data.Rd           |  2 +-
 man/xbrl_get_relations.Rd      |  2 +-
 man/xbrl_get_statement_ids.Rd  |  2 +-
 man/xbrl_get_statements.Rd     |  3 ++-
 readme.md                      |  6 +++---
 41 files changed, 104 insertions(+), 108 deletions(-)
 create mode 100644 .travis.yml
 delete mode 100644 man/autoplot.statement.Rd

diff --git a/.Rbuildignore b/.Rbuildignore
index 2fdf8c7..10c55ef 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -3,3 +3,5 @@
 ^README\.Rmd$
 ^README\.html$
 ^IMG$
+^XBRLcache$
+^\.travis\.yml$
diff --git a/.gitignore b/.gitignore
index 01d42ff..0710a90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ README_files/
 finstr.Rproj
 .Rproj.user
 README.html
+XBRLcache
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..6de9789
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+# Sample .travis.yml for R projects
+
+language: r
+warnings_are_errors: true
+sudo: required
+
diff --git a/DESCRIPTION b/DESCRIPTION
index b035448..4d04a9b 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -5,22 +5,25 @@ Version: 0.1
 Date: 2015-03-22
 Author: Darko Bergant
 Maintainer: Darko Bergant <darko.bergant@gmail.com>
-Description: Data structures and functions for manipulating financial 
-  statements. Using parsed XBRL data and validating statement consistency.
-  Merging statements from different periods or different statement types.
-  Calculating custom financial ratios and creating custom statements
-  by aggregating financial categories.
-Depends: R (>= 2.10)
+Description: Data structures and functions for manipulating financial
+    statements. Using parsed XBRL data and validating statement consistency.
+    Merging statements from different periods or different statement types.
+    Calculating custom financial ratios and creating custom statements
+    by aggregating financial categories.
+Depends:
+    R (>= 2.10)
 License: GPL-2
-Imports: 
+Imports:
     magrittr,
     dplyr,
     tidyr,
     XBRL,
     lazyeval
-Suggests: testthat,
+Suggests:
+    testthat,
     knitr,
     ggplot2,
-    scales, 
+    scales,
     htmlTable
 VignetteBuilder: knitr
+RoxygenNote: 5.0.1
diff --git a/NAMESPACE b/NAMESPACE
index 2571919..e13d023 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,4 +1,4 @@
-# Generated by roxygen2 (4.1.1): do not edit by hand
+# Generated by roxygen2: do not edit by hand
 
 S3method(diff,statement)
 S3method(merge,elements)
@@ -8,7 +8,6 @@ S3method(print,check)
 S3method(print,statement)
 S3method(print,statements)
 export("%without%")
-export(autoplot.statement)
 export(calculate)
 export(calculation)
 export(check_statement)
@@ -22,7 +21,6 @@ export(other)
 export(plot_double_stacked_bar)
 export(plot_waterfall)
 export(proportional)
-export(reshape_long)
 export(reshape_table)
 export(xbrl_get_data)
 export(xbrl_get_relations)
diff --git a/R/finstr.R b/R/finstr.R
index e3f187d..e94aa14 100644
--- a/R/finstr.R
+++ b/R/finstr.R
@@ -115,10 +115,11 @@ xbrl_get_data <- function(elements, xbrl_vars, complete_only = TRUE) {
     dplyr::mutate_(fact = ~as.numeric(fact), decimals = ~min_dec )%>%
     dplyr::inner_join(xbrl_vars$context, by = "contextId") %>%
     dplyr::select_(~contextId ,  ~startDate ,  ~endDate ,  ~elementId ,  ~fact ,  ~decimals) %>%
+    #dplyr::add_rownames() %>% 
     tidyr::spread_("elementId", "fact") %>%
     dplyr::arrange_(~endDate)
   
-  
+
   vec1 <- elements$elementId[! elements$elementId %in% names(res)]
   df1 <- setNames( data.frame(rbind(rep(0, length(vec1)))), vec1)
   res <- cbind(res, df1)
@@ -182,7 +183,8 @@ get_elements_h <- function(elements) {
   level <- 1
   df1 <- elements %>%
     dplyr::filter_(~is.na(parentId)) %>%
-    dplyr::mutate(id = "")
+    dplyr::mutate(id = "") %>% 
+    dplyr::arrange_(~dplyr::desc(balance))
 
   while({
     level_str <- 
@@ -229,6 +231,12 @@ xbrl_get_relations <- function(xbrl_vars, role_id, lbase = "calculation") {
     dplyr::mutate(order = as.numeric(order)) %>%
     unique() 
 
+  # check the hierarchy: children should not be duplicated
+  duplicated_children <- duplicated(res$toElementId)
+  if(any(duplicated_children)) {
+    res <- res[!duplicated_children, ]
+    warning("Found and removed duplicated children in ", lbase, "/",role_id, call. = FALSE)
+  }
   class(res) <- c("xbrl_relations", "data.frame")
   return(res)
 }
@@ -329,7 +337,11 @@ get_elements <- function(x, parent_id = NULL, all = TRUE) {
   elements <- attr(x, "elements")
   
   if(!missing(parent_id)) {
-    id_parent <- elements[["id"]][elements[["elementId"]] == parent_id]
+    children <- elements[["elementId"]] == parent_id
+    if(!any(children)) {
+      stop("No children with parent ", parent_id, " found", call. = FALSE)
+    }
+    id_parent <- elements[["id"]][children]
     elements <- elements %>%
       dplyr::filter_(~substring(id, 1, nchar(id_parent)) == id_parent) %>%
       as.elements()
@@ -484,10 +496,11 @@ merge.elements <- function(x, y, ...) {
 #' 
 #' @param x statement object
 #' @param y statement object
+#' @param replace_na (boolean) replace NAs with zeros  
 #' @param ... further arguments passed to or from other methods
 #' @return statement object
 #' @export
-merge.statement <- function(x, y, ...) {
+merge.statement <- function(x, y, replace_na = TRUE, ...) {
 
   if( !"statement" %in% class(x) || !"statement" %in% class(y) ) {
     stop("Not statement objects")
@@ -510,7 +523,9 @@ merge.statement <- function(x, y, ...) {
     
     z <- merge.data.frame(x, y, all = TRUE, ...)
     # replace NAs in values by zeros
-    z[,5:ncol(z)][is.na(z[,5:ncol(z)])] <- 0
+    if(replace_na) {
+      z[,5:ncol(z)][is.na(z[,5:ncol(z)])] <- 0
+    }
     # remove duplicated rows (based on periods)
     z <- z[!duplicated(z[c("endDate")], fromLast = TRUE), ]
     # order rows by endDate
@@ -533,11 +548,12 @@ merge.statement <- function(x, y, ...) {
 #' @details Merges all statements in x with all statements in y
 #' @param x statements object
 #' @param y statements object
+#' @param replace_na (boolean) replace NAs with zeros  
 #' @param ... further arguments passed to or from other methods
 #' @return statements object
 #' @seealso \link{merge.statement} for merging two statements
 #' @export
-merge.statements <- function(x, y, ...) {
+merge.statements <- function(x, y, replace_na = TRUE, ...) {
 
   if( !"statements" %in% class(x) || !"statements" %in% class(y) ) {
     stop("Not statements objects")
@@ -545,7 +561,7 @@ merge.statements <- function(x, y, ...) {
   
   z <-
     lapply(names(x), function(statement){
-      merge(x[[statement]], y[[statement]], ...)
+      merge(x[[statement]], y[[statement]], replace_na = replace_na, ...)
     })
   names(z) <- names(y)
   class(z) <- "statements"
@@ -857,7 +873,7 @@ expose <- function(x, ..., e_list = NULL) {
     xc <- na.omit(x_els[x_els$elementId %in% els, "elementId"])
     xcb <- x_els[x_els$elementId %in% xc, "balance"]
     xcs <- ifelse(xb == xcb, 1, -1)
-    xcv <- rowSums(crossprod(t(x[, xc]), xcs) )
+    xcv <- rowSums(crossprod(t(x[, xc]), xcs), na.rm = TRUE )
     y[[exp_name]] <- xcv
     
     # rearrange hierarchy
diff --git a/R/finstr_plot.R b/R/finstr_plot.R
index 4af3f75..2ac06e7 100644
--- a/R/finstr_plot.R
+++ b/R/finstr_plot.R
@@ -118,7 +118,6 @@ plot_waterfall <- function(x, date = NULL, ...) {
     stop("Package scales needed for this function to work. Please install it.",
          call. = FALSE)
   }
-  library(ggplot2)
 
   row_num <- 1
   if(!missing(date)) {
@@ -170,18 +169,3 @@ plot_waterfall <- function(x, date = NULL, ...) {
                     panel.border = ggplot2::element_blank()
     )
 }
-
-#' autoplot statement
-#' @param x statement object
-#' @param ... other params
-#' @export
-#' @keywords internal
-autoplot.statement <- function(x, ...) {
-  if( sum(is.na(get_elements(x)[["parentId"]] )) ) {
-    plot_double_stacked_bar(x, ...)
-  } else {
-    plot_waterfall(x, ...)
-  }
-}
-
-
diff --git a/R/finstr_print.R b/R/finstr_print.R
index 663ace7..b380023 100644
--- a/R/finstr_print.R
+++ b/R/finstr_print.R
@@ -69,7 +69,7 @@ print.statement <- function (x, descriptions = FALSE, html = FALSE, big.mark = "
     )
   s_names <- substring(s_names, 3)
     
-  df1 <- cbind( Element = s_names, xt[,7:ncol(xt)] )
+  df1 <- cbind( Element = s_names, xt[,7:ncol(xt), drop = FALSE] )
   df1 <- df1[, c(1, ncol(df1):2)]
   print.data.frame(df1, right = FALSE, row.names = FALSE, ...)
   
diff --git a/README.Rmd b/README.Rmd
index 6755c02..f2f5ba5 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -50,8 +50,8 @@ For now it is offering:
   - Time lagged difference
 
 
-## Install finstr
-To install finstr from github use install_github from devtools package: 
+## Installation
+To install finstr from github use `install_github` from devtools package: 
 ```{r, eval=FALSE}
 library(devtools)
 install_github("bergant/finstr")
diff --git a/man/autoplot.statement.Rd b/man/autoplot.statement.Rd
deleted file mode 100644
index c50bfe1..0000000
--- a/man/autoplot.statement.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
-% Please edit documentation in R/finstr_plot.R
-\name{autoplot.statement}
-\alias{autoplot.statement}
-\title{autoplot statement}
-\usage{
-autoplot.statement(x, ...)
-}
-\arguments{
-\item{x}{statement object}
-
-\item{...}{other params}
-}
-\description{
-autoplot statement
-}
-\keyword{internal}
-
diff --git a/man/calculate.Rd b/man/calculate.Rd
index a3293f7..7e4bf26 100644
--- a/man/calculate.Rd
+++ b/man/calculate.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{calculate}
 \alias{calculate}
@@ -27,11 +27,11 @@ Calculate formulas
 \dontrun{
 
 balance_sheet \%>\% calculate(
-
+  
   current_ratio = AssetsCurrent / LiabilitiesCurrent,
-
-  quick_ratio =
-    ( CashAndCashEquivalentsAtCarryingValue +
+  
+  quick_ratio =  
+    ( CashAndCashEquivalentsAtCarryingValue + 
         AvailableForSaleSecuritiesCurrent +
         AccountsReceivableNetCurrent
       ) / LiabilitiesCurrent
diff --git a/man/calculation.Rd b/man/calculation.Rd
index 75fcb81..65703d8 100644
--- a/man/calculation.Rd
+++ b/man/calculation.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{calculation}
 \alias{calculation}
diff --git a/man/check_statement.Rd b/man/check_statement.Rd
index ad8647c..d1acbee 100644
--- a/man/check_statement.Rd
+++ b/man/check_statement.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{check_statement}
 \alias{check_statement}
diff --git a/man/diff.statement.Rd b/man/diff.statement.Rd
index bbcaa38..0a1672b 100644
--- a/man/diff.statement.Rd
+++ b/man/diff.statement.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{diff.statement}
 \alias{diff.statement}
diff --git a/man/expose.Rd b/man/expose.Rd
index ae857d8..ed86e26 100644
--- a/man/expose.Rd
+++ b/man/expose.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{expose}
 \alias{expose}
@@ -18,9 +18,10 @@ Simplifies statement to 2-level hierarchy.
 Elements are defined by list of element vectors.
 }
 \examples{
+
 \dontrun{
 expose(balance_sheet,
-
+                     
   # Assets
   `Current Assets` = "AssetsCurrent",
   `Noncurrent Assets` = other("Assets"),
diff --git a/man/get_ascendant.Rd b/man/get_ascendant.Rd
index d7b5189..65cea60 100644
--- a/man/get_ascendant.Rd
+++ b/man/get_ascendant.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{get_ascendant}
 \alias{get_ascendant}
diff --git a/man/get_descendants.Rd b/man/get_descendants.Rd
index f3a931d..f12dfd9 100644
--- a/man/get_descendants.Rd
+++ b/man/get_descendants.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{get_descendants}
 \alias{get_descendants}
diff --git a/man/get_elements.Rd b/man/get_elements.Rd
index c682f62..fa7b353 100644
--- a/man/get_elements.Rd
+++ b/man/get_elements.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{get_elements}
 \alias{get_elements}
diff --git a/man/get_elements_h.Rd b/man/get_elements_h.Rd
index 1f3786c..e79961e 100644
--- a/man/get_elements_h.Rd
+++ b/man/get_elements_h.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{get_elements_h}
 \alias{get_elements_h}
diff --git a/man/get_parent.Rd b/man/get_parent.Rd
index 94e685f..8641b44 100644
--- a/man/get_parent.Rd
+++ b/man/get_parent.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{get_parent}
 \alias{get_parent}
diff --git a/man/grapes-without-grapes.Rd b/man/grapes-without-grapes.Rd
index f579c2a..6564de7 100644
--- a/man/grapes-without-grapes.Rd
+++ b/man/grapes-without-grapes.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{\%without\%}
 \alias{\%without\%}
diff --git a/man/merge.elements.Rd b/man/merge.elements.Rd
index e40e1ad..84afb03 100644
--- a/man/merge.elements.Rd
+++ b/man/merge.elements.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{merge.elements}
 \alias{merge.elements}
diff --git a/man/merge.statement.Rd b/man/merge.statement.Rd
index b4d7c59..7e8a713 100644
--- a/man/merge.statement.Rd
+++ b/man/merge.statement.Rd
@@ -1,16 +1,18 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{merge.statement}
 \alias{merge.statement}
 \title{Merge two financial statements}
 \usage{
-\method{merge}{statement}(x, y, ...)
+\method{merge}{statement}(x, y, replace_na = TRUE, ...)
 }
 \arguments{
 \item{x}{statement object}
 
 \item{y}{statement object}
 
+\item{replace_na}{(boolean) replace NAs with zeros}
+
 \item{...}{further arguments passed to or from other methods}
 }
 \value{
@@ -23,10 +25,10 @@ Merge two statements from different time periods.
 Since statements are basically data.frames the functions are similar. Except:
 \itemize{
 \item new statement elements are allways union of input elements,
-  if taxonomy changes new and old elements are visible in all periods
-\item missing values are set to 0 not to NA as merge would normally do
+  if taxonomy changes new and old elements are visible in all periods 
+\item missing values are set to 0 not to NA as merge would normally do 
 \item hierarchy is merged from both statements hierarchies
-\item rows are treated as duplicated based on endDate and the row of x is
+\item rows are treated as duplicated based on endDate and the row of x is 
 allways considered as duplicate (so y should allways be the later statement)
 }
 }
diff --git a/man/merge.statements.Rd b/man/merge.statements.Rd
index f08b993..d1b26e1 100644
--- a/man/merge.statements.Rd
+++ b/man/merge.statements.Rd
@@ -1,16 +1,18 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{merge.statements}
 \alias{merge.statements}
 \title{Merge two lists of statements}
 \usage{
-\method{merge}{statements}(x, y, ...)
+\method{merge}{statements}(x, y, replace_na = TRUE, ...)
 }
 \arguments{
 \item{x}{statements object}
 
 \item{y}{statements object}
 
+\item{replace_na}{(boolean) replace NAs with zeros}
+
 \item{...}{further arguments passed to or from other methods}
 }
 \value{
diff --git a/man/other.Rd b/man/other.Rd
index 5ecb87e..c0eaff3 100644
--- a/man/other.Rd
+++ b/man/other.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{other}
 \alias{other}
diff --git a/man/plot_double_stacked_bar.Rd b/man/plot_double_stacked_bar.Rd
index b374c1e..448659e 100644
--- a/man/plot_double_stacked_bar.Rd
+++ b/man/plot_double_stacked_bar.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr_plot.R
 \name{plot_double_stacked_bar}
 \alias{plot_double_stacked_bar}
diff --git a/man/plot_waterfall.Rd b/man/plot_waterfall.Rd
index 0e66e91..ba4775b 100644
--- a/man/plot_waterfall.Rd
+++ b/man/plot_waterfall.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr_plot.R
 \name{plot_waterfall}
 \alias{plot_waterfall}
diff --git a/man/print.check.Rd b/man/print.check.Rd
index 092e6d6..10b690b 100644
--- a/man/print.check.Rd
+++ b/man/print.check.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr_print.R
 \name{print.check}
 \alias{print.check}
diff --git a/man/print.statement.Rd b/man/print.statement.Rd
index 9363e3b..144781c 100644
--- a/man/print.statement.Rd
+++ b/man/print.statement.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr_print.R
 \name{print.statement}
 \alias{print.statement}
diff --git a/man/print.statements.Rd b/man/print.statements.Rd
index e064cd3..c010855 100644
--- a/man/print.statements.Rd
+++ b/man/print.statements.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr_print.R
 \name{print.statements}
 \alias{print.statements}
diff --git a/man/proportional.Rd b/man/proportional.Rd
index 33a224b..07900e4 100644
--- a/man/proportional.Rd
+++ b/man/proportional.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{proportional}
 \alias{proportional}
diff --git a/man/reshape_long.Rd b/man/reshape_long.Rd
index 5dbfc9b..f541721 100644
--- a/man/reshape_long.Rd
+++ b/man/reshape_long.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{reshape_long}
 \alias{reshape_long}
@@ -6,13 +6,11 @@
 \usage{
 reshape_long(x, levels = NULL)
 }
-\arguments{
-\item{x}{a statement object}
-
-\item{levels}{if defined only elements from specified levels will be included}
-}
 \description{
 Reshapes statement object to a data frame with one value column
- and dimension columns (endDate, elementId and parentId).
+ and dimension columns (endDate, elementId and parentId). 
+ @param x a statement object
+ @param levels if defined only elements from specified levels will be included
+ @export
 }
 
diff --git a/man/reshape_table.Rd b/man/reshape_table.Rd
index 35d80f2..bb816e3 100644
--- a/man/reshape_table.Rd
+++ b/man/reshape_table.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{reshape_table}
 \alias{reshape_table}
diff --git a/man/xbrl_create_data.Rd b/man/xbrl_create_data.Rd
index 2adb5ed..c9b2be8 100644
--- a/man/xbrl_create_data.Rd
+++ b/man/xbrl_create_data.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{xbrl_create_data}
 \alias{xbrl_create_data}
diff --git a/man/xbrl_data_aapl2013.Rd b/man/xbrl_data_aapl2013.Rd
index 5dd5ced..46f2cb0 100644
--- a/man/xbrl_data_aapl2013.Rd
+++ b/man/xbrl_data_aapl2013.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \docType{data}
 \name{xbrl_data_aapl2013}
@@ -8,7 +8,7 @@
 data(xbrl_data_aapl2013)
 }
 \description{
-parsed XBRL files from
+parsed XBRL files from 
    http://edgar.sec.gov/Archives/edgar/data/320193/000119312513416534/aapl-20130928.xml
    using XBRL::xbrlDoAll
    and truncating to only necessary data
diff --git a/man/xbrl_data_aapl2014.Rd b/man/xbrl_data_aapl2014.Rd
index d0b72d5..85ce48e 100644
--- a/man/xbrl_data_aapl2014.Rd
+++ b/man/xbrl_data_aapl2014.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \docType{data}
 \name{xbrl_data_aapl2014}
@@ -8,7 +8,7 @@
 data(xbrl_data_aapl2014)
 }
 \description{
-parsed XBRL files from
+parsed XBRL files from 
    http://edgar.sec.gov/Archives/edgar/data/320193/000119312514383437/aapl-20140927.xml
    using XBRL::xbrlDoAll
    and truncating to only necessary data
diff --git a/man/xbrl_get_data.Rd b/man/xbrl_get_data.Rd
index 9c8fc06..29f9209 100644
--- a/man/xbrl_get_data.Rd
+++ b/man/xbrl_get_data.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{xbrl_get_data}
 \alias{xbrl_get_data}
diff --git a/man/xbrl_get_relations.Rd b/man/xbrl_get_relations.Rd
index 9900e41..3f38de5 100644
--- a/man/xbrl_get_relations.Rd
+++ b/man/xbrl_get_relations.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{xbrl_get_relations}
 \alias{xbrl_get_relations}
diff --git a/man/xbrl_get_statement_ids.Rd b/man/xbrl_get_statement_ids.Rd
index c9b1b27..067ee04 100644
--- a/man/xbrl_get_statement_ids.Rd
+++ b/man/xbrl_get_statement_ids.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{xbrl_get_statement_ids}
 \alias{xbrl_get_statement_ids}
diff --git a/man/xbrl_get_statements.Rd b/man/xbrl_get_statements.Rd
index be5867a..99accea 100644
--- a/man/xbrl_get_statements.Rd
+++ b/man/xbrl_get_statements.Rd
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/finstr.R
 \name{xbrl_get_statements}
 \alias{xbrl_get_statements}
@@ -29,6 +29,7 @@ st1 <- xbrl_get_statements(xbrl_data)
 xbrl_url <- "http://edgar.sec.gov/Archives/edgar/data/320193/000119312514383437/aapl-20140927.xml"
 st1 <- xbrl_get_statements(xbrl_url)
 }
+
 }
 \seealso{
 \link{finstr}
diff --git a/readme.md b/readme.md
index 1fedf71..023a61b 100644
--- a/readme.md
+++ b/readme.md
@@ -27,10 +27,10 @@ For now it is offering:
 -   Exposing data by rearranging the statament hierarchy
 -   Time lagged difference
 
-Install finstr
---------------
+Installation
+------------
 
-To install finstr from github use install\_github from devtools package:
+To install finstr from github use `install_github` from devtools package:
 
 ``` r
 library(devtools)
-- 
GitLab