Wraps read.table. Typically useful for raw text file, such as those generated by the popular "ImageJ's > Export as xy coordinates".

import_txt(x, from_col, to_col, ...)

Arguments

x

paths to .txt files

from_col, to_col

column names where to get paths and where to store results

...

additional arguments to feed utils::read.table

Value

Momocs2::coo_single

See also

Other import: import_mask(), import_multimask()

Examples

# list of files case lf <- Momit_data("txt") %>% list_files() lf
#> [1] "/tmp/RtmpuCmU8O/temp_libpath3e5420e10ed6/Momit/extdata/txt/face1.txt" #> [2] "/tmp/RtmpuCmU8O/temp_libpath3e5420e10ed6/Momit/extdata/txt/face2.txt"
# single case lf[1] %>% import_txt()
#> # A tibble: 13 x 2 #> x y #> <dbl> <dbl> #> 1 206 148 #> 2 251 148 #> 3 218 178 #> 4 232 178 #> 5 242 178 #> 6 210 200 #> 7 248 199 #> 8 178 187 #> 9 275 181 #> 10 231 240 #> 11 228 91 #> 12 186 103 #> 13 268 106 #> ❯coo_single with 13 coordinates
# multi case lf %>% import_txt()
#> [[1]] #> # A tibble: 13 x 2 #> x y #> <dbl> <dbl> #> 1 206 148 #> 2 251 148 #> 3 218 178 #> 4 232 178 #> 5 242 178 #> 6 210 200 #> 7 248 199 #> 8 178 187 #> 9 275 181 #> 10 231 240 #> 11 228 91 #> 12 186 103 #> 13 268 106 #> ❯coo_single with 13 coordinates #> #> [[2]] #> # A tibble: 13 x 2 #> x y #> <dbl> <dbl> #> 1 206 146 #> 2 253 149 #> 3 217 176 #> 4 232 176 #> 5 242 176 #> 6 212 199 #> 7 250 200 #> 8 180 184 #> 9 275 184 #> 10 232 235 #> 11 230 89 #> 12 186 100 #> 13 269 107 #> ❯coo_single with 13 coordinates #>
# mom_tbl case z <- Momit_data("txt") %>% sniff()
#> ℹ sniffing files in /tmp/RtmpuCmU8O/temp_libpath3e5420e10ed6/Momit/extdata/txt
z %>% import_txt()
#> # A tibble: 2 x 6 #> size path path_dir file ext coo #> <fs::b> <fs::path> <chr> <chr> <chr> <list<co> #> 1 233 /tmp/RtmpuCmU8O/temp_libp… /tmp/RtmpuCmU8O/tem… face1… txt <tibble … #> 2 233 /tmp/RtmpuCmU8O/temp_libp… /tmp/RtmpuCmU8O/tem… face2… txt <tibble … #> ❯mom_tbl
# case with different from/to_col names z %>% dplyr::rename(plop=path) %>% import_txt(from_col=plop, to_col=plip)
#> # A tibble: 2 x 6 #> size plop path_dir file ext plip #> <fs::b> <fs::path> <chr> <chr> <chr> <list<co> #> 1 233 /tmp/RtmpuCmU8O/temp_libp… /tmp/RtmpuCmU8O/tem… face1… txt <tibble … #> 2 233 /tmp/RtmpuCmU8O/temp_libp… /tmp/RtmpuCmU8O/tem… face2… txt <tibble … #> ❯mom_tbl