gpt4 book ai didi

r - 如何从本质上非数字的原始数据创建邻接矩阵

转载 作者:行者123 更新时间:2023-12-02 06:36:22 27 4
gpt4 key购买 nike

<分区>

下面给出了我正在处理的输入示例:

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 中如何可能。任何提示或指示将不胜感激。

提前感谢您的宝贵时间和帮助。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com