创建和导出汇总统计数据 Table
Create and Export a Summary Statistics Table
我有一个包含加密货币、S&P500 ETF、CRIX、美联储储备、商品等信息的数据集。
我正在尝试创建一个摘要统计 Table 并发现包“stargazer”是最好的研究出版物。
我不希望数据集中的所有变量都在 table 中,所以我尝试了以下代码:
stargazer(df[c("BNBClose", "BTCClose", "ADAClose", "LINKClose", "DODGEClose", "EOSClose", "ETHClose", "MIOTAClose", "LTCClose", "XMRClose", "XEMClose", "XLMClose", "USDTClose", "TRXClose", "XRPClose", "FEDWALCL", "FEDM0Reserves", "FEDM0Total", "CETFClose", "CRIXClose", "SPYClose", "GLDClose", "OILClose")],type="text",title="Summary Statistics", out="table1.txt")
并出现以下错误:
Error in if (length(c(year, month, day, hour, min, sec)) == 6 && all(c(year, :
missing value where TRUE/FALSE needed
我在整个数据集中没有缺失值。我不知道还能做什么。任何帮助将非常感激。如果您有另一个包建议尝试生成和导出(到乳胶)描述性统计数据 table 包含均值、标准差、最小值、最大值、偏度和峰度也会有很大帮助。
可重现的示例数据集如下:
data_stuct <-
structure(
list(
Date = structure(
c(
17441,
17442,
17443,
17444,
17445,
17446,
17447,
17448,
17449,
17450
),
class = "Date"
),
BNBClose = c(
1.96466994285583,
1.82070004940032,
1.60148000717163,
1.67849004268646,
1.57991003990173,
1.58424997329711,
1.21722996234893,
1.4037799835205,
1.39336001873016,
1.43373000621795
),
BNBReturn = c(
0.286941022473697,
-0.0747675854046642,-0.135036469092375,
0.0266057079361807,
-0.058069140833992,
-0.0130882480387323,-0.227734156731425,
0.162348536759326,
-0.0263508788443867,
0.0245026259536907
),
BTCClose = c(
4409.31982421875,
4317.47998046875,
4229.35986328125,
4328.41015625,
4370.81005859375,
4426.89013671875,
4610.47998046875,
4772.02001953125,
4781.990234375,
4826.47998046875
),
BTCReturn = c(
0.00307332788380803,-0.0206375880182435,
-0.0208387453411515,
0.0232938703148199,
0.0107181238986895,
0.0131690154774654,
0.0408179529812949,
0.0341313938033363,
0.00121022180447976,
0.00777365568069113
),
ADAClose = c(
0.0259317997843027,
0.0208158008754253,
0.0219314992427825,
0.0214887000620365,
0.0185391008853912,
0.0209408998489379,
0.0204771999269723,
0.02211369946599,
0.0215313006192445,
0.0225195009261369
),
ADAReturn = c(
0.0538382925523828,
-0.191826507565934,
0.0511596482131408,
-0.0210738824748107,
-0.132019856680562,
0.137233310475833,
-0.0216059683246936,
0.0869727271720155,
-0.026266109908542,
0.0483939151162756
),
LINKClose = c(
0.356766998767852,
0.345535010099411,
0.397361010313034,
0.406538009643554,
0.475764989852905,
0.463656991720199,
0.397136986255645,
0.380589008331298,
0.407469004392623,
0.450462996959686
),
LINKReturn = c(
-0.184843753787707,
-0.059138850859273,
0.157859063823257,
0.0239478473239544,
0.170914967745977,
-0.0181875540911234,
-0.141299439924916,-0.0591264151564786,
0.0711621651773824,
0.0819438214938677
),
DODGEClose = c(
0.00108535995241254,
0.0011083900462836,
0.00102437997702509,
0.001001329976134,
0.00105603004340082,
0.00106609996873885,
0.00105591001920402,
0.000990716973319649,
0.00103567994665354,
0.00104612996801733
)
),
row.names = c(NA,-10L),
class = c("tbl_df",
"tbl", "data.frame")
)
我尝试对 运行 代码未声明为时间序列的数据集进行汇总:
stargazer(WorkingVariables, type = "text", title = "Summary Statistics", out = "table1.txt")
并且控制台中的输出具有我正在寻找的结构(或多或少,缺少观察次数、偏度和峰度)但它是空的。显示如下:
Summary Statistics
===================================================
Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
===================================================
下面什么都没有,有人知道发生了什么吗?相同的样本数据应该有效。
您有一个问题,stargazer
不支持。如果将其更改为数据框,它就可以工作。
library(stargazer)
data_stuct <- data.frame(data_stuct)
stargazer(data_stuct[c("BNBClose", "BTCClose", "ADAClose", "LINKClose",
"DODGEClose")],type="text",title="Summary Statistics", out="table1.txt")
#Summary Statistics
#========================================================================
#Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
#------------------------------------------------------------------------
#BNBClose 10 1.568 0.219 1.217 1.411 1.659 1.965
#BTCClose 10 4,507.324 220.613 4,229.360 4,339.010 4,731.635 4,826.480
#ADAClose 10 0.022 0.002 0.019 0.021 0.022 0.026
#LINKClose 10 0.408 0.043 0.346 0.385 0.440 0.476
#DODGEClose 10 0.001 0.00004 0.001 0.001 0.001 0.001
------------------------------------------------------------------------
我有一个包含加密货币、S&P500 ETF、CRIX、美联储储备、商品等信息的数据集。 我正在尝试创建一个摘要统计 Table 并发现包“stargazer”是最好的研究出版物。 我不希望数据集中的所有变量都在 table 中,所以我尝试了以下代码:
stargazer(df[c("BNBClose", "BTCClose", "ADAClose", "LINKClose", "DODGEClose", "EOSClose", "ETHClose", "MIOTAClose", "LTCClose", "XMRClose", "XEMClose", "XLMClose", "USDTClose", "TRXClose", "XRPClose", "FEDWALCL", "FEDM0Reserves", "FEDM0Total", "CETFClose", "CRIXClose", "SPYClose", "GLDClose", "OILClose")],type="text",title="Summary Statistics", out="table1.txt")
并出现以下错误:
Error in if (length(c(year, month, day, hour, min, sec)) == 6 && all(c(year, :
missing value where TRUE/FALSE needed
我在整个数据集中没有缺失值。我不知道还能做什么。任何帮助将非常感激。如果您有另一个包建议尝试生成和导出(到乳胶)描述性统计数据 table 包含均值、标准差、最小值、最大值、偏度和峰度也会有很大帮助。
可重现的示例数据集如下:
data_stuct <-
structure(
list(
Date = structure(
c(
17441,
17442,
17443,
17444,
17445,
17446,
17447,
17448,
17449,
17450
),
class = "Date"
),
BNBClose = c(
1.96466994285583,
1.82070004940032,
1.60148000717163,
1.67849004268646,
1.57991003990173,
1.58424997329711,
1.21722996234893,
1.4037799835205,
1.39336001873016,
1.43373000621795
),
BNBReturn = c(
0.286941022473697,
-0.0747675854046642,-0.135036469092375,
0.0266057079361807,
-0.058069140833992,
-0.0130882480387323,-0.227734156731425,
0.162348536759326,
-0.0263508788443867,
0.0245026259536907
),
BTCClose = c(
4409.31982421875,
4317.47998046875,
4229.35986328125,
4328.41015625,
4370.81005859375,
4426.89013671875,
4610.47998046875,
4772.02001953125,
4781.990234375,
4826.47998046875
),
BTCReturn = c(
0.00307332788380803,-0.0206375880182435,
-0.0208387453411515,
0.0232938703148199,
0.0107181238986895,
0.0131690154774654,
0.0408179529812949,
0.0341313938033363,
0.00121022180447976,
0.00777365568069113
),
ADAClose = c(
0.0259317997843027,
0.0208158008754253,
0.0219314992427825,
0.0214887000620365,
0.0185391008853912,
0.0209408998489379,
0.0204771999269723,
0.02211369946599,
0.0215313006192445,
0.0225195009261369
),
ADAReturn = c(
0.0538382925523828,
-0.191826507565934,
0.0511596482131408,
-0.0210738824748107,
-0.132019856680562,
0.137233310475833,
-0.0216059683246936,
0.0869727271720155,
-0.026266109908542,
0.0483939151162756
),
LINKClose = c(
0.356766998767852,
0.345535010099411,
0.397361010313034,
0.406538009643554,
0.475764989852905,
0.463656991720199,
0.397136986255645,
0.380589008331298,
0.407469004392623,
0.450462996959686
),
LINKReturn = c(
-0.184843753787707,
-0.059138850859273,
0.157859063823257,
0.0239478473239544,
0.170914967745977,
-0.0181875540911234,
-0.141299439924916,-0.0591264151564786,
0.0711621651773824,
0.0819438214938677
),
DODGEClose = c(
0.00108535995241254,
0.0011083900462836,
0.00102437997702509,
0.001001329976134,
0.00105603004340082,
0.00106609996873885,
0.00105591001920402,
0.000990716973319649,
0.00103567994665354,
0.00104612996801733
)
),
row.names = c(NA,-10L),
class = c("tbl_df",
"tbl", "data.frame")
)
我尝试对 运行 代码未声明为时间序列的数据集进行汇总:
stargazer(WorkingVariables, type = "text", title = "Summary Statistics", out = "table1.txt")
并且控制台中的输出具有我正在寻找的结构(或多或少,缺少观察次数、偏度和峰度)但它是空的。显示如下:
Summary Statistics
===================================================
Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
===================================================
下面什么都没有,有人知道发生了什么吗?相同的样本数据应该有效。
您有一个问题,stargazer
不支持。如果将其更改为数据框,它就可以工作。
library(stargazer)
data_stuct <- data.frame(data_stuct)
stargazer(data_stuct[c("BNBClose", "BTCClose", "ADAClose", "LINKClose",
"DODGEClose")],type="text",title="Summary Statistics", out="table1.txt")
#Summary Statistics
#========================================================================
#Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
#------------------------------------------------------------------------
#BNBClose 10 1.568 0.219 1.217 1.411 1.659 1.965
#BTCClose 10 4,507.324 220.613 4,229.360 4,339.010 4,731.635 4,826.480
#ADAClose 10 0.022 0.002 0.019 0.021 0.022 0.026
#LINKClose 10 0.408 0.043 0.346 0.385 0.440 0.476
#DODGEClose 10 0.001 0.00004 0.001 0.001 0.001 0.001
------------------------------------------------------------------------