From dc07071e643c8dffb9e06777e8b8ab5ce4343e1f Mon Sep 17 00:00:00 2001
From: Helmer Belbo <Helmer.Belbo@nibio.no>
Date: Sat, 21 Mar 2020 09:34:05 +0100
Subject: [PATCH] Adding kommunevis() function to gather kommunevis data

---
 NAMESPACE          |  1 +
 R/VSOP_fylke_mnd.R | 22 ++++++++++++++++++++++
 man/kommunevis.Rd  | 21 +++++++++++++++++++++
 3 files changed, 44 insertions(+)
 create mode 100644 man/kommunevis.Rd

diff --git a/NAMESPACE b/NAMESPACE
index 5a60465..07755e3 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,3 +1,4 @@
 # Generated by roxygen2: do not edit by hand
 
 export(fylkesvis_mnd)
+export(kommunevis)
diff --git a/R/VSOP_fylke_mnd.R b/R/VSOP_fylke_mnd.R
index fb2bf33..e1df444 100644
--- a/R/VSOP_fylke_mnd.R
+++ b/R/VSOP_fylke_mnd.R
@@ -21,3 +21,25 @@ fylkesvis_mnd = function(){
 }
 
 
+#' Kommunevis vsop
+#'
+#' @return a tibble with logging statistics
+#' @param Behøver ingen parametere. Datafilene ligger i egen folder.
+#' @export
+#'
+#' @examples devtools::install_github("hbelbo/vsop")
+#' kommunevis()
+kommunevis = function(){
+  files <-   list.files(path = (system.file("extdata", package = "vsop")) ,
+                        pattern = ".xlsx", full.names = T) %>%
+    .[which(!stringr::str_detect(., "~"))] %>%
+    .[which(stringr::str_detect(., "Kommunevis avvirkning"))]
+
+  df = readxl::read_xlsx(path = files[1], sheet = 1, skip = 2, col_names = T)[NULL, ]
+  for (i in seq_along(files)){
+    df = rbind(df, readxl::read_xlsx(path = files[i], sheet = 1, skip = 2, col_names = T))
+  }
+  return(df)
+}
+
+
diff --git a/man/kommunevis.Rd b/man/kommunevis.Rd
new file mode 100644
index 0000000..12f3438
--- /dev/null
+++ b/man/kommunevis.Rd
@@ -0,0 +1,21 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/VSOP_fylke_mnd.R
+\name{kommunevis}
+\alias{kommunevis}
+\title{Kommunevis vsop}
+\usage{
+kommunevis()
+}
+\arguments{
+\item{Behøver}{ingen parametere. Datafilene ligger i egen folder.}
+}
+\value{
+a tibble with logging statistics
+}
+\description{
+Kommunevis vsop
+}
+\examples{
+devtools::install_github("hbelbo/vsop")
+kommunevis()
+}
-- 
GitLab