将绘图数据从R导出到Excel

时间:2022-04-10 23:16:00

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 )

1 个解决方案

#1


4  

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。贝叶斯模型模拟的仿真数目

n.comparators Number of interventions being analysed

n.正在分析的干预措施的数量

...

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的函数定义。你会发现你的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 )

#1


4  

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。贝叶斯模型模拟的仿真数目

n.comparators Number of interventions being analysed

n.正在分析的干预措施的数量

...

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的函数定义。你会发现你的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 )