Coder Social home page Coder Social logo

lumberjack's People

Contributors

markvanderloo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lumberjack's Issues

logging does not work with mutate()

Using mutate during logging generates errors. For example, the following code generates the error:

Error in dump_log(., stop = TRUE, file = "train_log.csv") :
attempt to apply non-function

`

rm(list = ls())

train_data <- read.csv("train_original.csv",
header = TRUE,
stringsAsFactors = FALSE)
train_data <- train_data %>>%
mutate(id = seq(1, nrow(train_data), 1)) %>%
replace_with_na_all(condition = ~.x == "")

doesn't work:

train_data <- train_data %>>%
as.data.frame() %>>%
start_log(log = cellwise$new(key = "id")) %>>%
mutate(MWC = character(length = nrow(train_data))) %>>%
impute_lm(Age ~ Fare + Pclass + Sex + Embarked) %>>%
dump_log(stop = TRUE, file = "train_log.csv")

works:

train_data <- train_data %>>%
as.data.frame() %>>%
start_log(log = cellwise$new(key = "id")) %>>%
# mutate(MWC = character(length = nrow(train_data))) %>>%
impute_lm(Age ~ Fare + Pclass + Sex + Embarked) %>>%
dump_log(stop = TRUE, file = "train_log.csv")`

logging fails when tibble is supplied vs. data.frame

When an operation is performed that coerces the data into a tibble, the logging fails with errors. In the below example, the error is:

Error in $<-.data.frame(*tmp*, value, value = c("1", "2", "3", "4", :
replacement has 10692 rows, data has 12

`

library(lumberjack)
rm(list = ls())

train_data <- read.csv("train_original.csv",
header = TRUE,
stringsAsFactors = FALSE)
train_data <- train_data %>>%
mutate(id = seq(1, nrow(train_data), 1)) %>%

following ensures blanks are NA, but also coerces to tibble

replace_with_na_all(condition = ~.x == "")

doesn't work:

train_data <- train_data %>>%
#as.data.frame() %>>%
start_log(log = cellwise$new(key = "id")) %>>%
impute_lm(Age ~ Fare + Pclass + Sex + Embarked) %>>%
dump_log(stop = TRUE, file = "train_log.csv")

works

train_data <- train_data %>>%
as.data.frame() %>>%
start_log(log = cellwise$new(key = "id")) %>>%
impute_lm(Age ~ Fare + Pclass + Sex + Embarked) %>>%
dump_log(stop = TRUE, file = "train_log.csv")`

cellwise log does not handle the expression with quotes

Repro with the following example, the expression is broken down to 2 columns / shift the other columns to the right and makes the logs incorrect

data(women)
women$sleutel <- 1:nrow(women)
head(women)
women <- women %L>%
  start_log(log=cellwise$new(key="sleutel")) %L>%
  mutate( istall = ifelse(height>60, "Yes", "NO")) %L>%
  dump_log(file=logfile, stop=TRUE)
head(women)

image

Feature request: Add columns to dump_log object before write

Use-case: Add username-column to log-rows to backtrack who made the changes.

Non-working solution, before dump_log():
transform( user = Sys.getenv("USERNAME")) %>>%
Results in all user-add-edits being logged, instead of username being added to existing rows in logs.

Better, but verbose solution:
After dump, read file back in, add column, write out again.

log_cellwise <- read.csv("log_cellwise.csv")
log_cellwise <- transform(log_cellwise, user = Sys.getenv("USERNAME"))
write.csv(log_cellwise, "log_cellwise.csv")

Are there some "Arguments passed to the dump method of the logger." that can be passed to achieve adding a column before the dump?
I would love if something like this was possible:
dump_log(data, "cellwise", file ="log.csv", cols = single_value/expression/transform() )
But I can see how it would open a can of worms potentially. Maybe there is some smart set of parameters / methods I am unaware of that could fit?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.