我在我的 dfm 上应用了一个模型(wordscore)。结果我得到了一个输出对象,其类是“textmodel_wordscores”“textmodel”“list”。我对输出“wordscores”感兴趣,它是一个“数字”对象(这就是当class应用于对象),如下所示:
extensive fiscal_stimulus measure operation automatic_stabiliser
0.96765485 0.98292581 -0.70247675 0.63275195 0.75272326
will
-0.04568423
现在我有一个包含两列的普通数据框,如下所示:
df <- data.frame(Words = c("commitment", "progress", "implement", "decision", "message", "deficit"), Score = c(-0.984345245754151, -0.983153011766781, -0.978586816039627, -0.977724303324149, -0.976291875611652, -0.975229993562152))
Words Score
1 commitment -0.984345245754151
2 progress -0.983153011766781
3 implement -0.978586816039627
4 decision -0.977724303324149
5 message -0.976291875611652
6 deficit -0.975229993562152
我希望这个数据框的格式与上面的相同。我尝试转换为列表,但它保留了双列框架。
你可以做:
with(df, setNames(Score, Words))
commitment progress implement decision message deficit
-0.9843452 -0.9831530 -0.9785868 -0.9777243 -0.9762919 -0.9752300
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)