title: R Interp functions returns 0s/one value for z variable
body: <p>I am trying to replicate Cesar's solution from here in order to create an interpolation of two CTD transects:
  <a href="https://stackoverflow.com/questions/54726853/how-to-interpolate-data-between-sparse-points-to-make-a-contour-plot-in-r-plot">How to interpolate data between sparse points to make a contour plot in R &amp; plotly</a></p>
  <p>However, after running the interpolation, the z values of my list objects consist almost exclusively of the value -230 and my resulting plot does not contain any 'color' values and cuts away most of my depths.</p>
  <p>My data is as follows:</p>
  <p>I have two data frames (df1 &amp; df2) with a subset from df for each transect which look like this</p>
  <pre><code>&gt; str(df1)
  'data.frame':   120 obs. of  5 variables:
   $ Station : int  13 13 13 13 13 13 13 13 13 13 ...
   $ x       : num  35.5 35.5 35.5 35.5 35.5 ...
   $ y       : num  -39.5 -39.5 -39.5 -39.5 -39.5 ...
   $ z       : num  -758 -758 -595 -595 -506 ...
   $ Salinity: num  34.4 34.4 34.5 34.5 34.6 ...
  </code></pre>
  <p>When running the interpolation as suggested by Cesar like this</p>
  <pre><code>z1 &lt;- interp(df1$x, df1$y, df1$z, extrap = TRUE, duplicate = &quot;mean&quot;) #interp z layer 1 with spline interp
  ifelse(anyNA(z1$z) == TRUE, z1$z[is.na(z1$z)] &lt;- mean(z1$z, na.rm = TRUE), NA) #fill na cells with mean value
  </code></pre>
  <p>and the interpolation of my Salinity 'color' like this</p>
  <pre><code>c1 &lt;- interp(df1$x, df1$y, df1$Salinity, extrap = F, linear = F, duplicate = &quot;mean&quot;) #interp co2 layer 1 with spline interp
  ifelse(anyNA(c1$z) == TRUE, c1$z[is.na(c1$z)] &lt;- mean(c1$z, na.rm = TRUE), NA) #fill na cells with mean value
  </code></pre>
  <p>my resulting z1$z looks like this (only around -230 value)</p>
  <pre><code>z1$z
             [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]      [,8]      [,9]     [,10]     [,11]     [,12]     [,13]     [,14]
   [1,] -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318
   [2,] -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318
   [3,] -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318 -230.7318
  </code></pre>
  <p>and the resulting c1$z like this (only 0s)</p>
  <pre><code>c1$z
        [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
   [1,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
   [2,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
   [3,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
  </code></pre>
  <p>My resulting plot (same code as Cesar from link above) then looks like this without any Salinity data and everything clustered around -230 depth:
  <a href="https://i.stack.imgur.com/FvdBj.png" rel="nofollow noreferrer">Plot_ly interpolated plot</a></p>
  <p>Any help to work out where I have gone wrong would be appreciated. I hope I added enough detail as I am completely new to stackoverflow. Thanks in advance!</p>