I have a data frame with this structure:
tibble [2 × 4] (S3: tbl_df/tbl/data.frame)
$ CTY_GEOID: chr [1:2] "08000" "08001"
$ NAME : chr [1:2] "Colorado" "Adams County"
$ 2020 : num [1:2] 5786877 520489
$ 2024 : num [1:2] 5956729 543760
I have to take the difference between column 4 and column 3. In production these column names will change, so I am using column incides in the calculation:
f.pop_sum <- f.pop_sum %>%
mutate(diff = .[4] - .[3])
This calculation creates a list:
tibble [2 × 5] (S3: tbl_df/tbl/data.frame)
$ CTY_GEOID: chr [1:2] "08000" "08001"
$ NAME : chr [1:2] "Colorado" "Adams County"
$ 2020 : num [1:2] 5786877 520489
$ 2024 : num [1:2] 5956729 543760
$ diff :'data.frame': 2 obs. of 1 variable:
..$ 2024: num [1:2] 169852 23271
This is new, bizarre behavior.
This is happening with R version 4.6.0 and R studio 2026.05.0 Build 218
I have three questions:
- Why is this happening?
- How do I unlist this column to assign the value to the indivual rows in the data frame?
- Is there anyway to prevent this behavior?
TIA