Skip to content

Commit

Permalink
DataEditR v0.0.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
DillonHammill committed Aug 25, 2020
1 parent 5c3832e commit 91f9996
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 71 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: DataEditR
Title: An Interactive Editor for Viewing, Entering & Editing Data
Version: 0.0.5
Date: 2020-07-30
Version: 0.0.6
Date: 2020-08-25
Authors@R:
person(given = "Dillon",
family = "Hammill",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# DataEditR 0.0.6

* Add ability to pass column names to `data_edit()` to construct a template data.frame with pre-defined column names.

# DataEditR 0.0.5

* Fix row indices when rows are added or removed.
Expand Down
66 changes: 39 additions & 27 deletions R/data_edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,36 +140,48 @@ data_edit <- function(x,

# READ IN DATA
if (is.null(dim(x))) {
# READ IN FILE
if (length(x) == 1) {
# FUNCTION
read_fun <- match.fun(read_fun)
# CHECK READ ARGUMENTS
if (!is.null(read_args)) {
if (!class(read_args) == "list") {
stop("read_args must be a named list of arguments for read_fun.")
# FILE/COLUMN NAMES
if(is.character(x)) {
# FILE NAME - SINGLE + EXTENSION
if(length(x) == 1 & all(nchar(file_ext(x)) != 0)) {
# FUNCTION
read_fun <- match.fun(read_fun)
# CHECK READ ARGUMENTS
if (!is.null(read_args)) {
if (!class(read_args) == "list") {
stop("read_args must be a named list of arguments for read_fun.")
}
}
# READ ARGUMENTS
read_args <- c(list(x), read_args)
# EXTRA ARGUMENTS
extra_args <- list(...)
read_args <- c(
read_args,
extra_args[!names(extra_args) %in% names(read_args)]
)
# CALL FUNCTION
x <- do.call(read_fun, read_args)
# COLUMN NAMES
} else {
x <- data.frame(
structure(rep(list(""), length(x)),
names = x),
check.names = FALSE,
stringsAsFactors = FALSE
)
}
# READ ARGUMENTS
read_args <- c(list(x), read_args)
# EXTRA ARGUMENTS
extra_args <- list(...)
read_args <- c(
read_args,
extra_args[!names(extra_args) %in% names(read_args)]
)
# CALL FUNCTION
x <- do.call(read_fun, read_args)
# EMPTY MATRIX/DATA.FRAME
} else if (length(x) == 2) {
x <- matrix(rep("", prod(x)),
nrow = x[1],
ncol = x[2]
)
x <- as.data.frame(x)
# DIMENSIONS
} else if(is.numeric(x)) {
x <- data.frame(
structure(rep(list(rep("", x[1])), x[2]),
names = paste0("V", seq_len(x[2]))),
check.names = FALSE,
stringsAsFactors = FALSE
)
}
}

# BIND ROWS
if (!is.null(row_bind)) {
# NEW ROWS
Expand Down Expand Up @@ -585,7 +597,7 @@ data_edit <- function(x,
quiet = TRUE
)
}

# RETURN ORIGINAL CLASS
if ("matrix" %in% data_class) {
x <- as.matrix(x)
Expand Down
9 changes: 9 additions & 0 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ java_script <- function(...) {
stop("The arguments for JS() must be a character vector")
x <- paste(x, collapse = '\n')
structure(x, class = unique(c("JS_EVAL", oldClass(x))))
}

## FILE_EXT --------------------------------------------------------------------

#' Get file extensions from file names
#' @noRd
file_ext <- function(x) {
pos <- regexpr("\\.([[:alnum:]]+)$", x)
ifelse(pos > -1L, substring(x, pos + 1L), "")
}
2 changes: 2 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ knitr::opts_chunk$set(
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Travis build status](https://travis-ci.com/DillonHammill/DataEditR.svg?branch=master)](https://travis-ci.com/DillonHammill/DataEditR)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/DillonHammill/DataEditR?branch=master&svg=true)](https://ci.appveyor.com/project/DillonHammill/DataEditR)
[![CRAN status](https://www.r-pkg.org/badges/version/DataEditR)](https://CRAN.R-project.org/package=DataEditR)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
<!-- badges: end -->

Manual data entry and editing in R can be tedious, especially if you have limited coding experience and are accustomed to using software with a Graphical User Interface (GUI). **DataEditR** is an R package that makes it easy to view, enter and edit data within R, due to its convenient interactive GUI that supports many of the data manipulation operations supported by other commonly used GUI-oriented software. If you are new to **DataEditR** visit https://dillonhammill.github.io/DataEditR/ to get started.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.re
status](https://travis-ci.com/DillonHammill/DataEditR.svg?branch=master)](https://travis-ci.com/DillonHammill/DataEditR)
[![AppVeyor build
status](https://ci.appveyor.com/api/projects/status/github/DillonHammill/DataEditR?branch=master&svg=true)](https://ci.appveyor.com/project/DillonHammill/DataEditR)
[![CRAN
status](https://www.r-pkg.org/badges/version/DataEditR)](https://CRAN.R-project.org/package=DataEditR)
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
<!-- badges: end -->

Manual data entry and editing in R can be tedious, especially if you
Expand Down Expand Up @@ -103,7 +107,7 @@ citation("DataEditR")
#> To cite package 'DataEditR' in publications use:
#>
#> Dillon Hammill (2020). DataEditR: An Interactive Editor for Viewing,
#> Entering & Editing Data. R package version 0.0.5.
#> Entering & Editing Data. R package version 0.0.6.
#> https://github.com/DillonHammill/DataEditR
#>
#> A BibTeX entry for LaTeX users is
Expand All @@ -112,7 +116,7 @@ citation("DataEditR")
#> title = {DataEditR: An Interactive Editor for Viewing, Entering & Editing Data},
#> author = {Dillon Hammill},
#> year = {2020},
#> note = {R package version 0.0.5},
#> note = {R package version 0.0.6},
#> url = {https://github.com/DillonHammill/DataEditR},
#> }
```
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 91f9996

Please sign in to comment.