Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 两个函数-一个可以,一个有错误:$运算符对原子向量无效 我的问题:_R_Vector_Shiny - Fatal编程技术网

R 两个函数-一个可以,一个有错误:$运算符对原子向量无效 我的问题:

R 两个函数-一个可以,一个有错误:$运算符对原子向量无效 我的问题:,r,vector,shiny,R,Vector,Shiny,我有两个在相同逻辑上运行的函数。我已将错误精确定位到以下代码行。在第一个示例中,代码运行正常:StressQoQ在第二个函数中,您将以前制作的monthly_HPF替换为: monthly_HPF在函数monthly_Stress_路径的开头,对象monthly_HPF是一个data.frame。 但稍后您将把它重新指定给mstress_索引,它是一个向量 class(monthly_HPF) [1] "data.frame" class(mstress_index) [1] "numeric

我有两个在相同逻辑上运行的函数。我已将错误精确定位到以下代码行。在第一个示例中,代码运行正常:
StressQoQ在第二个函数中,您将以前制作的
monthly_HPF
替换为:


monthly_HPF在函数monthly_Stress_路径的开头,对象monthly_HPF是一个data.frame。
但稍后您将把它重新指定给mstress_索引,它是一个向量

class(monthly_HPF)
[1] "data.frame"

class(mstress_index)
[1] "numeric"
不能对向量使用$运算符。 相反,您可以将mstress_索引转换为data.frame

monthly_HPF <- data.frame(col1 = mstress_index)

monthly\u HPF请提供您正在使用的软件包,例如,left\u join或na
dput(head(HPF, 25))
structure(list(region = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), path = c(1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
), date = c(20140215, 20140515, 20140815, 20141115, 20150215, 
20150515, 20150815, 20151115, 20160215, 20160515, 20160815, 20161115, 
20170215, 20170515, 20170815, 20171115, 20180215, 20180515, 20180815, 
20181115, 20190215, 20190515, 20190815, 20191115, 20200215), 
    index_value = c(1, 1.033852765, 1.041697122, 1.038876363, 
    1.041043093, 1.060900982, 1.073728928, 1.075879441, 1.080898915, 
    1.10368893, 1.119240863, 1.122827602, 1.128639801, 1.15275796, 
    1.169021733, 1.172707492, 1.178666441, 1.203634882, 1.220348482, 
    1.223890323, 1.229770019, 1.255791539, 1.273560554, 1.278236959, 
    1.285508086), index = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
    11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24), 
    counter = 1:25, BaseQoQ = c(0, 0.033852765, 0.00758749917354051, 
    -0.00270784947028013, 0.00208564760655761, 0.0190749923163842, 
    0.0120915582298895, 0.00200284535874973, 0.00466546139717505, 
    0.0210843166587877, 0.0140908661646175, 0.00320461762840418, 
    0.00517639483536669, 0.0213692260175751, 0.0141085757499344, 
    0.00315285755256367, 0.00508136004984272, 0.0211836361259394, 
    0.0138859385432799, 0.00290231933930496, 0.00480410367620832, 
    0.021159663675294, 0.0141496533844698, 0.00367191413499146, 
    0.00568840303732765), fdate = structure(c(16116, 16205, 16297, 
    16389, 16481, 16570, 16662, 16754, 16846, 16936, 17028, 17120, 
    17212, 17301, 17393, 17485, 17577, 17666, 17758, 17850, 17942, 
    18031, 18123, 18215, 18307), class = "Date"), StressC = c(0.99749, 
    1.031342765, 1.039187122, 1.036366363, 1.038533093, 1.058390982, 
    1.071218928, 1.073369441, 1.078388915, 1.10117893, 1.116730863, 
    1.120317602, 1.126129801, 1.15024796, 1.166511733, 1.170197492, 
    1.176156441, 1.201124882, 1.217838482, 1.221380323, 1.229770019, 
    1.255791539, 1.273560554, 1.278236959, 1.285508086), StressQoQ = c(0, 
    0.0339379492526242, 0.00760596502560418, -0.0027143898728953, 
    0.00209069888540969, 0.0191210941026796, 0.0121202336548254, 
    0.00200753827606026, 0.00467637125510434, 0.0211333913794913, 
    0.0141229845362187, 0.00321182042946733, 0.00518799221722843, 
    0.021416855302633, 0.0141393626118667, 0.00315964160130755, 
    0.00509225924746737, 0.021228843485116, 0.0139149560969629, 
    0.00290830110260876, 0.0068690282969297, 0.021159663675294, 
    0.0141496533844698, 0.00367191413499146, 0.00568840303732765
    )), .Names = c("region", "path", "date", "index_value", "index", 
"counter", "BaseQoQ", "fdate", "StressC", "StressQoQ"), row.names = c(NA, 
-25L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars = "region", drop = TRUE, indices = list(
    0:24), group_sizes = 25L, biggest_group_size = 25L, labels = structure(list(
    region = 1), row.names = c(NA, -1L), class = "data.frame", vars = "region", drop = TRUE, .Names = "region"))
 str(mstress_index)
 num [1:75] NaN NA NA NaN NA NA NaN NA NA NaN ...
class(monthly_HPF)
[1] "data.frame"

class(mstress_index)
[1] "numeric"
monthly_HPF <- data.frame(col1 = mstress_index)