【发布时间】:2017-11-13 18:37:33
【问题描述】:
我在使用 reactiveValues 转换响应式 data.frame 时遇到问题并进行观察。我更熟悉使用常规反应()并且不能完全掌握反应值。我想在名为 tmp3 的 data.frame 中添加一个名为“Biomass”的列。我能够转换 tmp2 并添加一个名为“Class”的列和一个名为“Common”的列,这没有问题。下面是服务器的一个小片段。如果我尝试使用转换来添加“生物质”列,则应用程序将无法运行。我希望有人可以快速浏览它并理顺我。让我知道是否需要提供完整的代码。
globals <- reactiveValues()
observe({
dat=read_lake_survey(SiteID())
surveys <- dat$result$surveys
tmp2 <- map2(surveys$fishCatchSummaries, surveys$surveyDate, ~{
.x$survey_date <- .y ; .x })
tmp2 <- map2(tmp2, surveys$surveyType, ~{ .x$survey_type <- .y ; .x })
tmp2 <- map2(tmp2, surveys$surveySubType, ~{ .x$survey_subtype <- .y ; .x })
tmp2 <- map2_df(tmp2, surveys$surveyID, ~{ .$survey_id <- .y ; .x })
tmp2[tmp2 == "N/A" ] <- NA
tmp3=transform(tmp2,Class= abv$Coding[match(tmp2$species, abv$Abv)],
FullName=abv$Common[match(tmp2$species, abv$Abv)])
### No luck adding this to the transform code ######
### Biomass=tmp2$averageWeight*tmp2$totalCatch ###
globals$ScrapedData=tmp3
})
【问题讨论】:
-
“应用程序无法运行”是什么意思?你得到什么样的错误信息?我没有从这个 sn-p 中看到任何闪亮的特定问题。
-
错误是'sourceUTF8 错误(serverR, envir = new.env(parent = globalenv())) :'。当我尝试使用转换添加生物质列时会发生这种情况。
tmp3=transform(tmp2,Biomass=tmp2$averageWeight*tmp2$totalCatch,Class= abv$Coding[match(tmp2$species, abv$Abv)], FullName=abv$Common[match(tmp2$species, abv$Abv)]) -
删除
totalCatch中第三个t之后的零宽度非连接符(U+200C)。这个我不熟悉,把它放到一个Unicode字符标识符里就行了。