title: Convert lat long to utm NAD83 zone 20
body: <p>I have 2 similar data sets, where I want to convert my latitude and longitude to UTM (NAD83 Zone 20N). One of my data sets has the raw data <a href="https://i.stack.imgur.com/Nt9Jc.png" rel="nofollow noreferrer">Data set 1</a>, and for the other one I have calculated the average position based on a given time interval <a href="https://i.stack.imgur.com/ZRTn6.png" rel="nofollow noreferrer">Data set 2</a>.</p>
  <p>The second data set does have a few NAs in the mean lat and long sections, yet I would need to find a way in the code to accept the NAs and convert all the other lat/longs.</p>
  <p>I have tried using different codes that I have found on the Internet, but they are giving me errors or won't convert lat/long to UTM.</p>
  <p><strong>Code 1</strong></p>
  <pre><code>setwd(&quot;~/Documents/UVI/Thesis/Data/Analyses/Practice/MCP_Lsynagris&quot;)
  
  tagdata&lt;-read.csv(&quot;Data/allcombinedMAforSA.csv&quot;, header=T, sep=&quot;,&quot;, strip.white=T)
  tagdata$detection_time_ast&lt;-as.POSIXct(tagdata$detection_time_ast, format=&quot;%Y-%m-%d %H:%M:%S&quot;,tz=&quot;UTC&quot;)
  
  tagdata&lt;-tagdata[order(tagdata$detection_time_ast),]
  
  cord.dec = SpatialPoints(cbind(tagdata$long_nad83, -tagdata$lat_nad83), proj4string = CRS(&quot;+proj=longlat&quot;))
  #Transfoming coordinate to UTM using ESPG 26920 for NAD83 Zone 20N.
  cord_UTM&lt;-spTransform(cord.dec, CRS(&quot;+init=esp:26290&quot;))
  cord_UTM
  </code></pre>
  <p>For the first set of codes I received the following error</p>
  <pre><code>&gt; cord_UTM&lt;-spTransform(cord.dec, CRS(&quot;+init=esp:26290&quot;))
  Error in spTransform(cord.dec, CRS(&quot;+init=esp:26290&quot;)) : 
    error in evaluating the argument 'CRSobj' in selecting a method for function 'spTransform': Error in CRS(&quot;+init=esp:26290&quot;) : no system list, errno: 2
  &gt; cord_UTM
  Error: object 'cord_UTM' not found
  </code></pre>
  <p><strong>Code 2</strong></p>
  <pre><code>tagdata&lt;-read.csv(&quot;Data/allcombinedMAforSA.csv&quot;, header=T, sep=&quot;,&quot;, strip.white=T)
  
  tagdata$detection_time_ast&lt;-as.POSIXct(tagdata$detection_time_ast, format=&quot;%Y-%m-%d %H:%M:%S&quot;,tz=&quot;UTC&quot;)
  
  tagdata&lt;-tagdata[order(tagdata$detection_time_ast),]
  
  coordinates(tagdata) &lt;- c(&quot;long_nad83&quot;, &quot;lat_83&quot;)
  proj4string(tagdata) &lt;- CRS(&quot;+proj=longlat +datum=NAD83&quot;)  
  
  res &lt;- spTransform(tagdata, CRS(&quot;+proj=utm +zone=20 ellps=NAD83&quot;))
  res
  as(res, &quot;SpatialPoints&quot;) 
  </code></pre>
  <p>Here are the following errors I received in the second code</p>
  <pre><code>Error in `[.data.frame`(object, , value) : undefined columns selected
  &gt; proj4string(tagdata) &lt;- CRS(&quot;+proj=longlat +datum=NAD83&quot;)  
  Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘proj4string&lt;-’ for signature ‘&quot;data.frame&quot;, &quot;CRS&quot;’
  &gt; 
  &gt; res &lt;- spTransform(tagdata, CRS(&quot;+proj=utm +zone=20 ellps=NAD83&quot;))
  Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘spTransform’ for signature ‘&quot;data.frame&quot;, &quot;CRS&quot;’
  &gt; res
  Error: object 'res' not found
  
  &gt; as(res, &quot;SpatialPoints&quot;)
  Error in .class1(object) : object 'res' not found
  </code></pre>
  <p>Is there a better way to go about converting my lat/long to UTM NAD83 Zone 20 for either dat set? As well as, for the code to accept that there are NA's in the average lat/long columns for my second data set.</p>