Skip to content

Commit

Permalink
Merge pull request #56 from serkor1/master
Browse files Browse the repository at this point in the history
Issue #55 fix 🔧
  • Loading branch information
Robinlovelace authored Aug 7, 2024
2 parents bfd95e0 + 6bf2d18 commit 4c7dc1c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ inst/doc
.Rhistory
.RData
docs
sandbox/
43 changes: 33 additions & 10 deletions R/ic_dataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,53 @@
#' identical(x, x_df2)
ic_dataframe <- function(x) {

if(methods::is(object = x, class2 = "data.frame")) {
if (methods::is(object = x, class2 = "data.frame")) {

return(x)

}

stopifnot(methods::is(object = x, class2 = "character") | methods::is(object = x, class2 = "list"))

if(methods::is(object = x, class2 = "character")) {
if (methods::is(object = x, class2 = "character")) {

x_list <- ic_list(x)
} else if(methods::is(object = x, class2 = "list")) {

} else {

x_list <- x

}

x_list_named <- lapply(x_list, function(x) {
ic_vector(x)
})
x_list_named <- lapply(
X = x_list,
FUN = function(x) {
ic_vector(x)
}
)

x_df <- ic_bind_list(x_list_named)

date_cols <- grepl(pattern = "VALUE=DATE", x = names(x_df))
if(any(date_cols)) {
x_df[date_cols] <- lapply(x_df[, date_cols], ic_date)

if (any(date_cols)) {

x_df[date_cols] <- lapply(
X = x_df[date_cols],
FUN = ic_date
)

}

datetime_cols <- names(x_df) %in% c("DTSTART", "DTEND")
if(any(datetime_cols)) {
x_df[datetime_cols] <- lapply(x_df[, datetime_cols], ic_datetime)

if (any(datetime_cols)) {

x_df[datetime_cols] <- lapply(
X = x_df[datetime_cols],
FUN = ic_datetime
)

}

# names(x_df) <- gsub(pattern = ".VALUE.DATE", replacement = "", names(x_df))
Expand Down

0 comments on commit 4c7dc1c

Please sign in to comment.