Мои данные:
my_basket <- data.frame(ITEM_GROUP = c("Fruit","Fruit","Fruit","Fruit","Fruit","Vegetable","Vegetable","Vegetable","Vegetable","Dairy","Dairy","Dairy","Dairy","Dairy"),
ITEM_NAME = c("Apple","Banana","Orange","Mango","Papaya","Carrot","Potato","Brinjal","Raddish","Milk","Curd","Cheese","Milk","Paneer"),
Price = c(100,80,80,90,65,70,60,70,25,60,40,35,50,120))
Я хотел бы вычислить столбец для процентилей, используя функцию ntile
df1 = mutate(my_basket, percentile_rank = ntile(my_basket$Price,100))
Это должно дать мне фрейм данных, который выглядит как right_df
correct_df<- data.frame(ITEM_GROUP = c("Fruit","Fruit","Fruit","Fruit","Fruit","Vegetable","Vegetable","Vegetable","Vegetable","Dairy","Dairy","Dairy","Dairy","Dairy"),
ITEM_NAME = c("Apple","Banana","Orange","Mango","Papaya","Carrot","Potato","Brinjal","Raddish","Milk","Curd","Cheese","Milk","Paneer"),
Price = c(100,80,80,90,65,70,60,70,25,60,40,35,50,120),
percentile_rank=c(86,65,72,79,43,51,29,58,1,36,15,8,22,93))
Но вместо этого я получаю фрейм данных, который выглядит как error_df
wrong_df<- data.frame(ITEM_GROUP = c("Fruit","Fruit","Fruit","Fruit","Fruit","Vegetable","Vegetable","Vegetable","Vegetable","Dairy","Dairy","Dairy","Dairy","Dairy"),
ITEM_NAME = c("Apple","Banana","Orange","Mango","Papaya","Carrot","Potato","Brinjal","Raddish","Milk","Curd","Cheese","Milk","Paneer"),
Price = c(100,80,80,90,65,70,60,70,25,60,40,35,50,120),
percentile_rank=c(13,10,11,12,7,8,5,9,1,6,3,3,4,14))
Эта проблема возникла только после того, как я обновил свою версию R до 4.0.2