Strange Error in tidyverse after tibble version updated?

I am not sure it is the reason, but the error happened after I updated the tibble package.

Here is the problem:

I have a tibble, mydt

mydt
# A tibble: 5,704 x 5
   ID         L     D     S transformed
   <chr>  <dbl> <dbl> <dbl> <list>     
 1 0_0_70     0     0    70 <dbl [130]>
 2 1_0_70     1     0    70 <dbl [130]>
 3 2_0_70     2     0    70 <dbl [130]>
 4 3_0_70     3     0    70 <dbl [130]>
 5 0_1_70     0     1    70 <dbl [130]>
 6 1_1_70     1     1    70 <dbl [130]>
 7 2_1_70     2     1    70 <dbl [130]>
 8 3_1_70     3     1    70 <dbl [130]>
 9 0_2_70     0     2    70 <dbl [130]>
10 1_2_70     1     2    70 <dbl [130]>

I'd like to add a new column, "mdata", which should have three columns, one of which is from column 'transformed', for example:

tibble(Date = date, O=d.o, T = xxx$transformed[[1]])
# A tibble: 130 x 3
   Date       O$P_CDM     T
   <date>       <dbl> <dbl>
 1 2016-10-08       0    0 
 2 2016-10-15       0    0 
 3 2016-10-22       0    0 
 4 2016-10-29   51283 1981.
 5 2016-11-05       0    0 
 6 2016-11-12       0    0 
 7 2016-11-19       0    0 
 8 2016-11-26       0    0 
 9 2016-12-03       0    0 
10 2016-12-10       0    0 

Here, Date is a date array, and d.o is a data frame

# A tibble: 130 x 1
   P_CDM
   <dbl>
 1     0
 2     0
 3     0
 4 51283
 5     0
 6     0
 7     0
 8     0
 9     0
10     0

Previously, i have done

mydt %>% mutate(mdata = map(transformed, ~tibble(Date = date, O=d.o, T = .)))

Then I got error.

Error in map(mydt$transformed, ~tibble(Date = date, O = d.o, T = .)) :
'data' must be of class list or data.frame.

If I just run the map() function map(xxx$transformed, ~tibble(Date = date, O = d.o, T = .)), I got the same error.

The same process is error-free on the server, which still use the old version of tibble (tibble_1.4.2), the one on my local machine is tibble_2.1.3, is that the reason? And what should I do to fix it?

I also take a close look for the code, with the old version, running tibble(Date = date, O=d.o, T = xxx$transformed[[1]]) will generate

# A tibble: 130 x 3
   Date           O     T
   <date>     <dbl> <dbl>
 1 2016-10-08     0    0 
 2 2016-10-15     0    0 
 3 2016-10-22     0    0 
 4 2016-10-29 51283 1981.
 5 2016-11-05     0    0 
 6 2016-11-12     0    0 
 7 2016-11-19     0    0 
 8 2016-11-26     0    0 
 9 2016-12-03     0    0 
10 2016-12-10     0    0 

while using the latest version, it gives

# A tibble: 130 x 3
   Date       O$P_CDM     T
   <date>       <dbl> <dbl>
 1 2016-10-08       0    0 
 2 2016-10-15       0    0 
 3 2016-10-22       0    0 
 4 2016-10-29   51283 1981.
 5 2016-11-05       0    0 
 6 2016-11-12       0    0 
 7 2016-11-19       0    0 
 8 2016-11-26       0    0 
 9 2016-12-03       0    0 
10 2016-12-10       0    0 

Notice the second column name. I want the name to be O, not O$P_CDM.

Than you very much, looking forward to help.

Hi.

Missing pieces, such a d.o and xxx make this hard for me to follow. Could you post a reproducible example, called a reprex. No need for all 130 rows, just enough to throw the error.

I wonder about map(). Is this from purrr? If so, transformed must be a vector, and the second argument must be a function or a formula coerced to a function with the ~ operator.

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