下面给出了我正在处理的输入示例:
User ID 1 --- Artist 5
User ID 2 --- Artist 1
User ID 3 --- Artist 7
User ID 4 --- Artist 2
User ID 5 --- Artist 3
User ID 1 --- Artist 2
User ID 3 --- Artist 1
上述数据是应用用户听过的音乐记录。
我想生成一个与以下给定示例相对应的邻接矩阵:
ARTIST 1 ARTIST 2 ARTIST 3 ARTIST 4 ARTIST 5 ARTIST 6 ARTIST 7
USER ID 1 0 1 0 0 1 0 0
USER ID 2 1 0 0 0 0 0 0
USER ID 3 1 0 0 0 0 0 1
USER ID 4 0 1 0 0 0 0 0
USER ID 5 0 0 1 0 0 0 0
这在 R 中怎么可能实现。任何提示或指示将不胜感激。
提前感谢您的时间和帮助。