How can I use readr's automatic column type guessing for in memory tibble?

I am fetching data from an api which returns the data in tibble format without parsing column types for some columns. I would like to use readr's built in column type guessing functionality/a dedicated package to guess all column types from data as best it it can. Is that something possible?

I can write the data to disk as csv and read it back using readr but that is kind of hack I would like to avoid.

This is the api I am using, it uses the package cricketdata to get the data.

 career<- fetch_player_data(
                                 playerid =253802,
,                                matchtype = c("odi"),
                                 activity = c("batting")
                           )

I understand that within tidyverse each package tries to do one thing and do it well instead of building a monolithic api. It would be a cleaner solution to use the package readr depends upon to guess the column types instead of directly using readr.

Thanks in advance.

I believe it's readr::guess_parser(). Or readr::parse_guess() to parse directly. So a mutate(across(.fns = parse_guess)) should do what you need.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.