-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
In summarise draws, a function that returns a character changes all columns to character #355
Comments
This suggests to me that the output is being bound into a matrix (which requires a single type) and then converted to a data frame later, which it should probably not be. Rather than potentially round-tripping through a string (with the possibility for information loss) I would suggest binding results together into a data frame directly, which should be more efficient anyway. |
Yes, this is indeed the case |
I agree. that would make sense
n-kall ***@***.***> schrieb am Do., 14. März 2024, 18:52:
… This suggests to me that the output is being bound into a matrix
Yes, this is indeed the case
—
Reply to this email directly, view it on GitHub
<#355 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2ACGQU7UVGXE5IGYAHDYYHIVHAVCNFSM6AAAAABEVXULC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJXHEYDINRRGU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
It seems this is also caused by the behaviour of However, I don't know of a base R equivalent to |
Would |
I don't think so, at least initial testing adding |
What would purrr::flatten do instead? Not sure I get how this would fix things. |
I think purrr::flatten always returns a list, whereas unlist will return a vector even if recursive = F if there are no nested lists x = list(1, 2,3)
unlist(x, recursive = F)
#> 1 2 3
purrr::flatten(x)
# [[1]]
# [1] 1
# [[2]]
# [1] 2
# [[3]]
# [1] 3 |
I see. makes sense. and would the use of purrr::flatten fix the issue? |
I think so. I can test tomorrow. Are you thinking to copy the function over to posterior? |
I am not sure yet. If it works, perhaps you can make a PR using purrr::flatten and I will then edit the code to no longer require purrr. |
Sure, I can edit the existing PR |
Or any other approach like direct data.frame conversion, if this is also efficient. |
If a summary function that returns a character is used in
summarise_draws
, it makes all columns<chr>
which messes up formatting.Returns
This could be fixed by using
type.convert(out, as.is = TRUE)
on the output tibble insummarise_draws_helper
The text was updated successfully, but these errors were encountered: