【发布时间】:2019-01-03 21:10:45
【问题描述】:
参考问题,Order color based on Hue, Saturation, Value in R
我有以下数据框,我希望根据 h、s 和最后 v 进行排序
> library(dplyr)
> tHSVcol
h s v
[1,] 0.6229508 0.6421053 0.3725490
[2,] 0.2767296 0.5145631 0.8078431
[3,] 0.1323283 0.7928287 0.9843137
[4,] 0.9790476 0.9510870 0.7215686
[5,] 0.9093567 0.5480769 0.4078431
当我执行tHSVcol %>% arrange(desc(h)) 时,我得到了
Error in UseMethod("arrange_") : no applicable method for 'arrange_' applied to an object of class "c('matrix', 'double', 'numeric')"
我做错了什么?
【问题讨论】:
-
你有一个矩阵。转换为 data.frame 它应该可以工作。正如错误所解释的,没有办法处理
matrix类tHSVcol %>% as.data.frame %>% arrange(desc(h)) -
谢谢,会研究矩阵