Power BI 中的 R:plot.window(...) 中的错误:需要有限的 'xlim' 值

R in Power BI: Error in plot.window(...) : need finite 'xlim' values

在 Power BI 中使用 R 可视化

错误:

Stack Trace:
Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: R script error.
Error in plot.window(...) : need finite 'xlim' values
Calls: plot -> plot.default -> localWindow -> plot.window
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
Execution halted
 ---> Microsoft.PowerBI.Radio.RScriptRuntimeException: R script error.
Error in plot.window(...) : need finite 'xlim' values
Calls: plot -> plot.default -> localWindow -> plot.window
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
Execution halted

仅当我尝试对数据进行子集化时才会出现上述错误。

通过阅读其他类似的问题,我检查了我的数据类型,它们分别是 Integer 和 Double。

我还使用 any(is.na(dataset)) 检查了数据中的 NA 值,结果表明没有 NA 值。

当我输入 xlimylim 值时,我的图变成空白。

代码:

dataset <- dataset[dataset$Column1=="T1",] #Subset of data I want. All rows where Column1 is equal to T1.

x <- as.numeric(dataset$`Height`) # Integer
y <- as.numeric(dataset$`Pct Pop`)  # Double
plot(x, y,
xlim = c(0, 45000),
ylim = c(0, 1.5)
)

我通过使用强力双向过滤方法添加我想要的过滤器来修复此错误,而不是像通常在 R 中那样尝试创建我的数据子集。要完成此操作,请单击图表并在底部在右侧,您会看到一个名为 "Filters" 的部分,您可以在其中添加列和约束。