|
17 | 17 | #' identical(x, x_df2)
|
18 | 18 | ic_dataframe <- function(x) {
|
19 | 19 |
|
20 |
| - if(methods::is(object = x, class2 = "data.frame")) { |
| 20 | + if (methods::is(object = x, class2 = "data.frame")) { |
| 21 | + |
21 | 22 | return(x)
|
| 23 | + |
22 | 24 | }
|
23 | 25 |
|
24 | 26 | stopifnot(methods::is(object = x, class2 = "character") | methods::is(object = x, class2 = "list"))
|
25 | 27 |
|
26 |
| - if(methods::is(object = x, class2 = "character")) { |
| 28 | + if (methods::is(object = x, class2 = "character")) { |
| 29 | + |
27 | 30 | x_list <- ic_list(x)
|
28 |
| - } else if(methods::is(object = x, class2 = "list")) { |
| 31 | + |
| 32 | + } else { |
| 33 | + |
29 | 34 | x_list <- x
|
| 35 | + |
30 | 36 | }
|
31 | 37 |
|
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 | + |
35 | 45 | x_df <- ic_bind_list(x_list_named)
|
36 | 46 |
|
37 | 47 | 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 | + |
40 | 56 | }
|
| 57 | + |
41 | 58 | 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 | + |
44 | 67 | }
|
45 | 68 |
|
46 | 69 | # names(x_df) <- gsub(pattern = ".VALUE.DATE", replacement = "", names(x_df))
|
|
0 commit comments