gpt4 book ai didi

r - 不能在类型转换中使用 `fill = NA`

转载 作者:行者123 更新时间:2023-12-04 11:28:28 24 4
gpt4 key购买 nike

我收到以下错误:

dcast(rep.data, country ~ variable, mean, fill=NA)

Error in vapply(indices, fun, .default) : values must be type 'logical',
but FUN(X[[4]]) result is type 'double'

这是 rep.data上面的数据框:
structure(list(id = c("MRT1996", "BFA1982", "LBR1990", "UKR2000", 
"MNG1993", "VEN1992", "OMN1987", "LAO1996", "OMN1982", "SYR1993"
), wbcode = c("MRT", "BFA", "LBR", "UKR", "MNG", "VEN", "OMN",
"LAO", "OMN", "SYR"), polcode = c("MAA", "BFO", "LBR", "UKR",
"MON", "VEN", "OMA", "LAO", "OMA", "SYR"), country = c("Mauritania",
"Burkina Faso", "Liberia", "Ukraine", "Mongolia", "Venezuela, RB",
"Oman", "Lao PDR", "Oman", "Syrian Arab Republic"), cid = c(117L,
14L, 96L, 174L, 115L, 179L, 130L, 94L, 130L, 161L), year = c(1996L,
1982L, 1990L, 2000L, 1993L, 1992L, 1987L, 1996L, 1982L, 1993L
), variable = structure(c(9L, 7L, 22L, 26L, 18L, 24L, 10L, 7L,
16L, 25L), .Label = c("fdi", "gdp", "l.gdp", "gdp.pc", "l.gdp.pc",
"growth", "govex", "deficit", "r.usa", "polity", "polpersist",
"varpol.5", "bonds", "eqty", "net.port.in", "portin.gdp", "external.debt",
"external.debt.gdp", "official.xr.pct", "inflation.deflt", "IIR.annual",
"default", "cum.default.60", "pct.default.60", "cum.default.80",
"pct.default.80", "TOR80s", "TOR90s", "events", "TOR5", "turn"
), class = "factor"), value = c(6.2, 15.56, 1, 14.29, 74.04,
27.27, 0, 7.92, 0, 0)), .Names = c("id", "wbcode", "polcode",
"country", "cid", "year", "variable", "value"), row.names = c(26927L,
18978L, 67240L, 81096L, 55030L, 74901L, 30322L, 20280L, 49085L,
77731L), class = "data.frame")

最佳答案

使用 NA_real_而不是 NA , 自 dcast匹配类型也是如此。

关于r - 不能在类型转换中使用 `fill = NA`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22624878/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com