[英]Export plot data from R to Excel
I have this plot which i generate it from this code: 我有这个图,我从这段代码生成它:
m <- bcea(e=effects,c=costs, ref=2, interventions=treatments, Kmax=50000)
The plot is: 情节是:
evi.plot(m)
Now, i need to export this evpi.plot(m) in an excel file, not the jpeg created, but the data along with it, i mean what created the X and Y axis. 现在,我需要在excel文件中导出这个evpi.plot(m),而不是创建的jpeg,但是数据和它一起,我的意思是创建了X和Y轴。
I've been using something like this but it's not for this case 我一直在使用这样的东西,但不是这种情况
write.table( thresholds, 'clipboard', sep='\t', row.names=FALSE, col.names=FALSE )
In the documentation for function bcea
from package BCEA
you can see the structure of your object: 在函数的文档
bcea
从包BCEA
你可以看到你对象的结构:
Value
值
An object of the class "bcea" containing the following elements
包含以下元素的类“bcea”的对象
n.sim Number of simulations produced by the Bayesian model
n.sim贝叶斯模型产生的模拟数
n.comparators Number of interventions being analysed
n.comparators正在分析的干预措施的数量
...
...
k The vector of values for the grid approximation of the willingness to pay
k网格近似值支付意愿的向量
...
...
evi The vector of values for the Expected Value of Information, as a function of the willingness to pay
evi信息的预期价值的值向量,作为支付意愿的函数
And if you look at the function definition of evi.plot
you will see that your x and y-values are the elements named k
and evi
: 如果你看一下
evi.plot
的函数定义,你会发现你的x和y值是名为k
和evi
的元素:
> evi.plot
function (he)
{
options(scipen = 10)
plot(he$k, he$evi, t = "l", xlab = "Willingness to pay",
ylab = "EVPI", main = "Expected Value of Information")
if (length(he$kstar) > 0) {
points(rep(he$kstar, 3), c(-10000, he$evi[he$k == he$kstar]/2,
he$evi[he$k == he$kstar]), t = "l", lty = 2, col = "dark grey")
points(c(-10000, he$kstar/2, he$kstar), rep(he$evi[he$k ==
he$kstar], 3), t = "l", lty = 2, col = "dark grey")
}
}
<environment: namespace:BCEA>
So: 所以:
res <- cbind(m$k, m$evi)
write.table(res, file="bcea.csv", sep=',', row.names=FALSE, col.names=FALSE )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.