title: Update R on debian-- Correct form of /etc/apt/sources.list
body: <ul>
  <li><p>I am unable to install some of the r packages I need. Here is an error message:</p>
  
  <pre><code>Warning in install.packages : package 'fivethirtyeight' is not available (for R version 3.2.3)
  </code></pre></li>
  </ul>
  
  <p>My R version is the same that came with my fairly recent OS install. </p>
  
  <ul>
  <li><p>I tried to update R per directions <a href="https://cran.r-project.org/" rel="nofollow noreferrer">on cran</a> for debian (I'm running Linux Mint 18.2 Sonya).</p>
  
  <pre><code> apt-get update
   apt-get install r-base r-base-dev
  </code></pre>
  
  <p>with the error message </p>
  
  <pre><code>r-base is already the newest version (3.2.3-4). 
  r-base-dev is already the newest version (3.2.3-4).
  </code></pre></li>
  </ul>
  
  <p>This should not be true-- I'm fairly certain the newest version is 3.5. Around this time Rstudio stopped opening, and I was unable to test the package installation, I anticipate needing to reinstall Rstudio after I have a good version of R. </p>
  
  <p>I noticed that cran predicates their instructions with </p>
  
  <blockquote>
    <p>With an appropriate entry in /etc/apt/sources.list ... the newest R release including recommended packages can be installed ...</p>
  </blockquote>
  
  <p>Some other trouble shooting steps I had tried before this (I think it was <a href="https://stackoverflow.com/questions/10476713/how-to-upgrade-r-in-ubuntu#10476798">this question</a>) had also involved editing this, so... </p>
  
  <ul>
  <li><p>I tried modifying /etc/apt/sources.list The file I have now looks like: </p>
  
  <pre><code> #deb cdrom:[Linux Mint 18.2 _Sonya_ - Release amd64 20170628]/ xenial contrib m$
   deb http://cran.cnr.berkeley.edu/bin/linux/debian stretch-cran35/
   deb http://us.archive.ubuntu.com/ubuntu/ sonya main restricted
  </code></pre></li>
  <li><p>I am still unable to update  I'll include the output of apt-get commands below, but it's verbose and I'm hoping no one will need to read through it. </p></li>
  <li><p><strong>What should /etc/apt/sources.list look like?</strong> </p></li>
  <li><p><strong>What else am I doing wrong?</strong> </p>
  
  <pre><code>sudo apt-get update
  
  Ign:1 http://packages.linuxmint.com sonya InRelease
  Get:2 http://cran.cnr.berkeley.edu/bin/linux/debian stretch-cran35/ 
  [ommited for lack of reputation to post links]...
  Ign:22 http://us.archive.ubuntu.com/ubuntu sonya/restricted Translation-en_US
  Ign:23 http://us.archive.ubuntu.com/ubuntu sonya/restricted Translation-en
  Fetched 4,371 B in 6s (710 B/s)
  Reading package lists... Done
  W: GPG error: http://cran.cnr.berkeley.edu/bin/linux/debian stretch-cran35/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY FCAE2A0E115C3D8A
  W: The repository 'http://cran.cnr.berkeley.edu/bin/linux/debian stretch-cran35/ InRelease' is not signed.
  N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  N: See apt-secure(8) manpage for repository creation and user configuration details.
  W: The repository 'http://us.archive.ubuntu.com/ubuntu sonya Release' does not have a Release file.
  N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  N: See apt-secure(8) manpage for repository creation and user configuration details.
  E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/sonya/main/binary-amd64/Packages  404  Not Found [IP: 91.189.91.26 80]
  E: Some index files failed to download. They have been ignored, or old ones used instead.
  
  
  sudo apt-get install r-base r-base-dev
  
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  Some packages could not be installed. This may mean that you have
  requested an impossible situation or if you are using the unstable
  distribution that some required packages have not yet been created
  or been moved out of Incoming.
  The following information may help to resolve the situation:
  
  The following packages have unmet dependencies:
   r-base : Depends: r-base-core (&gt;= 3.5.0-1~stretchcran.0) but it is not going to be installed
        Depends: r-recommended (= 3.5.0-1~stretchcran.0) but it is not going to be installed
   r-base-dev : Depends: r-base-core (&gt;= 3.5.0-1~stretchcran.0) but it is not going to be installed
  E: Unable to correct problems, you have held broken packages.
  </code></pre></li>
  </ul>
  
  <p>P.S. This is my first stackoverflow post. Suggestions for how I could have improved the post are welcome. </p>
  
  <p>Edit at 1:05 Pacific: 
  Neither of the keys in the first two comments work. New error messages below: </p>
  
  <pre><code>kchalk@kchalk-Cin ~ $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
  Executing: /tmp/tmp.n3xDeOodv5/gpg.1.sh --keyserver
  keyserver.ubuntu.com
  --recv-keys
  E298A3A825C0D65DFD57CBB651716619E084DAB9
  gpg: requesting key E084DAB9 from hkp server keyserver.ubuntu.com
  gpg: key E084DAB9: "Michael Rutter &lt;marutter@gmail.com&gt;" not changed
  gpg: Total number processed: 1
  gpg:              unchanged: 1
  kchalk@kchalk-Cin ~ $ sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
  kchalk@kchalk-Cin ~ $ sudo apt-get update
  ...Ign:25 http://us.archive.ubuntu.com/ubuntu sonya/restricted Translation-en     
  Fetched 190 kB in 6s (30.1 kB/s)                                               
  Reading package lists... Done
  W: GPG error: http://cran.cnr.berkeley.edu/bin/linux/debian stretch-cran35/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY FCAE2A0E115C3D8A
  W: The repository 'http://cran.cnr.berkeley.edu/bin/linux/debian stretch-cran35/ InRelease' is not signed.
  N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  N: See apt-secure(8) manpage for repository creation and user configuration details.
  W: The repository 'http://us.archive.ubuntu.com/ubuntu sonya Release' does not have a Release file.
  N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  N: See apt-secure(8) manpage for repository creation and user configuration details.
  E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/sonya/main/binary-amd64/Packages  404  Not Found [IP: 91.189.91.26 80]
  E: Some index files failed to download. They have been ignored, or old ones used instead.
  kchalk@kchalk-Cin ~ $ sudo apt-get install r-base
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  Some packages could not be installed. This may mean that you have
  requested an impossible situation or if you are using the unstable
  distribution that some required packages have not yet been created
  or been moved out of Incoming.
  The following information may help to resolve the situation:
  
  The following packages have unmet dependencies:
   r-base : Depends: r-base-core (&gt;= 3.5.0-1~stretchcran.0) but it is not going to be installed
            Depends: r-recommended (= 3.5.0-1~stretchcran.0) but it is not going to be installed
  E: Unable to correct problems, you have held broken packages.
  </code></pre>
  
  <h1>Solution!</h1>
  
  <p>The answer I'll mark correct (by Carlos Santillan) said to run: </p>
  
  <pre><code>sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
  sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
  sudo apt-get update
  sudo apt-get install r-base
  </code></pre>
  
  <p>This did not quite solve my problem-- I'll leave my edit with the errors that gave me above in case it happed to anyone else. What did work was commenting out everything in /etc/apt/sources.list and including <em>only</em> the following </p>
  
  <pre><code>deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/
  </code></pre>
  
  <p>I could then run apt-get update and apt-get install and finally have a sufficiently new verion of R. (the line of Carlos Santillan's answer that adds a key was probably also pretty important here.) In the spirit of citation, 
  varun palekar's answer <a href="https://stackoverflow.com/questions/27137230/failed-to-fetch-update-on-ubuntu-14-04-lts-trusty-tahr#29080666">here</a> is what finally made me realize that having a malformed entry in my sources list would prevent even well formed ones from functioning. </p>