修订版 | 8463800b0ebc451a225370be0ec3ba7219111e23 (tree) |
---|---|
时间 | 2022-06-23 23:50:14 |
作者 | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I added a function to deal with the tsv files.
@@ -215,6 +215,37 @@ | ||
215 | 215 | } |
216 | 216 | |
217 | 217 | |
218 | +read_tsv_to_char <- function(x, ...){ | |
219 | + | |
220 | + res <- read_tsv(x, ...) %>% | |
221 | + as_tibble %>% | |
222 | + all_to_char() | |
223 | + | |
224 | + return(res) | |
225 | + | |
226 | + | |
227 | +} | |
228 | + | |
229 | + | |
230 | + | |
231 | + | |
232 | +read_all_tsv_to_char <- function( mypath=".", pattern="*tsv", ...){ | |
233 | + | |
234 | + | |
235 | +f <- list.files( | |
236 | + mypath, | |
237 | + pattern, | |
238 | + full.names = TRUE) | |
239 | + | |
240 | +d <- purrr::map_df(f, read_tsv_to_char, .id = "id", ...) | |
241 | + | |
242 | +return(d) | |
243 | + | |
244 | + | |
245 | +} | |
246 | + | |
247 | + | |
248 | + | |
218 | 249 | ## same but for any files |
219 | 250 | |
220 | 251 | read_all_extensions <- function( extension, mypath=".", ...){ |