绘制可能购物篮数量
在本练习中,您将直观地看到:随着项集大小增加,可能的购物篮数量会多么快速地增长。这将说明市场篮分析中的一个主要挑战——创建购物篮的组合方式非常多。您将使用 stat_function();该函数允许您在调用 ggplot() 时,通过参数 fun 指定想要绘制的函数。
本练习是课程的一部分
R 中的购物篮分析
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Define number of items in the set
n_items = ___
# Specify the function to be plotted
fun_combi = function(x) choose(___, ___)
# Plot the number of combinations
ggplot(data = data.frame(x = 0), mapping = aes(x = ___)) +
stat_function(fun = ___) + xlim(0,n_items)