title: R in Power BI: Error in plot.window(...) : need finite 'xlim' values
body: <p><strong>Using R visualization in Power BI</strong></p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Stack Trace:
  Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: R script error.
  Error in plot.window(...) : need finite 'xlim' values
  Calls: plot -&gt; plot.default -&gt; localWindow -&gt; 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
   ---&gt; Microsoft.PowerBI.Radio.RScriptRuntimeException: R script error.
  Error in plot.window(...) : need finite 'xlim' values
  Calls: plot -&gt; plot.default -&gt; localWindow -&gt; 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
  </code></pre>
  
  <p>I'm getting the above error only when I try to subset my data.</p>
  
  <p>From reading other similar questions I have checked my data types and they were Integer and Double respectively.</p>
  
  <p>I have also checked for NA values in the data using <code>any(is.na(dataset))</code> and it showed that there are no NA values.</p>
  
  <p>When I put in <code>xlim</code> and <code>ylim</code> values, my plot becomes blank.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>dataset &lt;- dataset[dataset$Column1=="T1",] #Subset of data I want. All rows where Column1 is equal to T1.
  
  x &lt;- as.numeric(dataset$`Height`) # Integer
  y &lt;- as.numeric(dataset$`Pct Pop`)  # Double
  plot(x, y,
  xlim = c(0, 45000),
  ylim = c(0, 1.5)
  )
  </code></pre>