Prradep
Prradep

Reputation: 5696

Reading the same file has different output in newer readr version

Reading a file doesn't return the same output in the newer R versions.

I have a file with the format:

      Symbol                 Location  N_ind_freqs
     A3GALT2      1:33772367-33786699            1
      ABCB10    1:229652329-229694442            1
       ABCD3      1:94883933-94984222            4
        ABL2    1:179068462-179198819            6

and used to read using the line:

df_out <- read_delim("file.out", delim = " ", trim_ws = TRUE, col_types = "ccd")

You could observe the spaces in the first column Symbol and needs to be trimmed. This code snippet returns the dataframe as expected (3 columns and 4 rows).

However, the readr::read_delim doesn't result in the same output (df_out) in the newer versions of the R (R 4.1.0).

What do you suggest as the problem?

Upvotes: 0

Views: 109

Answers (1)

AEF
AEF

Reputation: 5650

I suspect that the problem is not caused by the new version of R, but by a new version of the readr package (assuming you function read_delim is from readr). They released version 2.0.0 mid July and quite a few details have changed.

If this is really the source of yourr problem, you should be able to return to the old behaviour by using the with_edition function.

df_out <- with_edition(1, read_delim("file.out", delim = " ", trim_ws = TRUE, col_types = "ccd"))

Upvotes: 1

Related Questions