Skip to content

Commit 6bf2d18

Browse files
committed
Issue #55 fix 🔧
* Issue Fix: If "VALUE=DATE", "DTSTART" or "DTEND" exists in the ical-object the dates are now parsed correctly using data.frames instead of lists. * Minor Fix: Removed redundant if-statement. `ic_dataframe()`-function already checks wether the object is a `character` or `list` and therefore the if-statement is redundant. * Layout Fix: Increased spacing between if-statement and conditions, and added vertical space. All `lapply`-functions are now more verbose in the function calls.
1 parent bfd95e0 commit 6bf2d18

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ inst/doc
33
.Rhistory
44
.RData
55
docs
6+
sandbox/

R/ic_dataframe.R

+33-10
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,53 @@
1717
#' identical(x, x_df2)
1818
ic_dataframe <- function(x) {
1919

20-
if(methods::is(object = x, class2 = "data.frame")) {
20+
if (methods::is(object = x, class2 = "data.frame")) {
21+
2122
return(x)
23+
2224
}
2325

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

26-
if(methods::is(object = x, class2 = "character")) {
28+
if (methods::is(object = x, class2 = "character")) {
29+
2730
x_list <- ic_list(x)
28-
} else if(methods::is(object = x, class2 = "list")) {
31+
32+
} else {
33+
2934
x_list <- x
35+
3036
}
3137

32-
x_list_named <- lapply(x_list, function(x) {
33-
ic_vector(x)
34-
})
38+
x_list_named <- lapply(
39+
X = x_list,
40+
FUN = function(x) {
41+
ic_vector(x)
42+
}
43+
)
44+
3545
x_df <- ic_bind_list(x_list_named)
3646

3747
date_cols <- grepl(pattern = "VALUE=DATE", x = names(x_df))
38-
if(any(date_cols)) {
39-
x_df[date_cols] <- lapply(x_df[, date_cols], ic_date)
48+
49+
if (any(date_cols)) {
50+
51+
x_df[date_cols] <- lapply(
52+
X = x_df[date_cols],
53+
FUN = ic_date
54+
)
55+
4056
}
57+
4158
datetime_cols <- names(x_df) %in% c("DTSTART", "DTEND")
42-
if(any(datetime_cols)) {
43-
x_df[datetime_cols] <- lapply(x_df[, datetime_cols], ic_datetime)
59+
60+
if (any(datetime_cols)) {
61+
62+
x_df[datetime_cols] <- lapply(
63+
X = x_df[datetime_cols],
64+
FUN = ic_datetime
65+
)
66+
4467
}
4568

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

0 commit comments

Comments
 (0)