-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discrepancy displaying dates with colFormat #38
Comments
Thanks for reporting this. The problem is that I'll get this fixed. For now, some workarounds would be to:
For example: data <- data.frame(
date = c("2020-03-20", "2019-12-02"),
date_string_slash = c("2020/03/20", "2019/12/02"),
date_POSIXt = as.POSIXct(c("2020-03-20", "2019-12-02")),
date_custom = c("2020-03-20", "2019-12-02")
)
reactable(
data,
columns = list(
date_string_slash = colDef(format = colFormat(date = TRUE)),
date_POSIXt = colDef(format = colFormat(date = TRUE)),
date_custom = colDef(cell = function(value) strftime(value, "%m/%d/%Y"))
)
) |
Following up with the same issue, but slightly different... I am trying to sort the date variables but it seems to fail...
|
nergiszaim, |
It is sortable, but the initial output where the default order is set to be descending is not sorted? |
The generated table displays in the same order as the data frame, so if you want it to be sorted initially the dataframe needs to be sorted.
|
This should now be fixed in the latest master (7d67aa0). Both reactable(
data.frame(
date = c("2020-03-20", "2019-12-02", "2019-07-08"),
date_string = c("2020-03-20", "2019-12-02", "2019-07-08"),
date_Date = as.Date(c("2020-03-20", "2019-12-02", "2019-07-08"))
),
columns = list(
date_string = colDef(format = colFormat(date = TRUE)),
date_Date = colDef(format = colFormat(date = TRUE))
)
) Let me know if you find further issues. @nergiszaim You'll also need to set data <- data.frame(
date_custom = c("2020-03-20", "2019-12-02", "2019-02-01", "2019-11-01", "2019-07-08", "2019-08-11")
)
reactable(
data,
defaultSorted = "date_custom",
columns = list(
date_custom = colDef(
cell = function(value) strftime(value, "%m/%d/%Y"),
defaultSortOrder = "desc"
)
)
) |
@glin Thanks for the update! |
I am making a table of a dataframe containing stock market data. If I use the argument colDef(colFormat(date=TRUE)) to format the column the date is formatted the way I want but shows 1 day prior to the value stored in the data. If I do not use this argument the table displays the value accurately but not in the format I want.
I worked around this issue by adding a day to the date and then formatting it but I wanted to share my experience in case anyone else had a similar issue.
Example code below:
Results in output as follows:
However, if I replace the colDef arguments with the following:
I get the following output:
The text was updated successfully, but these errors were encountered: