我使用plotly包创建了一个Sankey图.
据我所知,节点的默认顺序主要由值定义.但是,我想要字母顺序,而无需手动移动鼠标药物的节点.
我可以用R更改默认顺序吗?
任何帮助将不胜感激.下面是一个示例代码和输出:
node_label <- c("x1_1", "x1_2", "x2_1", "x2_2")
link_source <- c(0, 0, 1, 1)
link_target <- c(2, 3, 2, 3)
link_value <- c(2, 5, 1, 3)
# when link_value <- c(5, 2, 1, 3), the order is changed.
plotly::plot_ly(
type = "sankey",
domain = list(x = c(0,1), y = c(0,1)),
node = list(label = node_label),
link = list(
source = link_source,
target = link_target,
value = link_value))
Run Code Online (Sandbox Code Playgroud)
在基数R中执行以下操作的dplyr模拟是什么?
iris$Sepal.Length[iris$Sepal.Length>2] <- iris$Sepal.Length[iris$Sepal.Length>2] * 10
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用过滤器,但无法返回到原始数据集(不带join)
我的朋友目前正致力于他的关于时间序列模型参数估计的任务,SARIMAX(季节性ARIMA外生),具有最大似然估计(MLE)方法.他使用的数据是关于2000 - 2012年的月降雨量,印度洋偶极子(IOD)指数作为外生变量.这是数据:
MONTH YEAR RAINFALL IOD
1 1 2000 15.3720526 0.0624
2 2 2000 10.3440804 0.1784
3 3 2000 14.6116392 0.3135
4 4 2000 18.6842179 0.3495
5 5 2000 15.2937896 0.3374
6 6 2000 15.0233152 0.1946
7 7 2000 11.1803399 0.3948
8 8 2000 11.0589330 0.4391
9 9 2000 10.1488916 0.3020
10 10 2000 21.1187121 0.2373
11 11 2000 15.3980518 -0.0324
12 12 2000 18.9393770 -0.0148
13 1 2001 19.1075901 -0.2448
14 2 2001 14.9097284 0.1673
15 3 2001 …Run Code Online (Sandbox Code Playgroud)