Prevent data type change

I have data frame A comprising COLLECTIBILITY and CIFNO. COLLECTIBILITY can range from 1 to 5 for the same CIFNO. I want to group by CIFNO, replacing all COLLECTIBILITY by the maximum value for the CIFNO.

COLLECTIBILITY CIFNO
5 D014418
5 D014418
5 D014418
5 D014418

I use B <- A %>% group_by(CIFNO) %>% summarise(KOLEKTIBILITAS = max(KOLEKTIBILITAS)). Data frame B looks as follows:

CIFNO KOLEKTIBILITAS

1 "" 1
2 "0000026" 2
3 "0000094" 2
4 "1000109" 2
5 "1000133" 2

The format of CIFNO gets changed from an alphabet followed by 6 digits to 7 digits.

How can I keep the data format of CIFNO from changing?

Mmm. I tried this code

library(tidyverse)

A <- tribble(~COLLECTIBILITY, ~CIFNO,
2, "D014418",
3, "D014418",
5, "D014418",
5, "D014418",
3, "S015353",
1, "S015353",
)

B <- A %>% 
  group_by(CIFNO) %>% 
  summarise(COLLECTIBILITY = max(COLLECTIBILITY))

And the output is as expected.

B

# A tibble: 2 × 2
  CIFNO   COLLECTIBILITY
  <chr>            <dbl>
1 D014418              5
2 S015353              3

Can you provide your df using dput(head(YOURDF, 10))?

Thanks. I've figured out the problem. Appreciate your quick response.