Rstudio

From 太極
Revision as of 19:52, 20 May 2018 by Brb (talk | contribs) (→‎Theme)
Jump to navigation Jump to search

Build from source

See https://github.com/rstudio/rstudio/blob/master/INSTALL for installation instruction.

To build Rstudio from source in Ubuntu:

  • Install R.
  • Install Qt 4.
  • Download a release version tarball of source code. Do not grab from github master branch. Sometimes the preview version works but the release version cannot be compiled. For example, the release version 0.98.507 would give a build error from /opt/QRstudio-QtSDK/Desktop/4.8.0/gcc/include/QtCore/gstring.h, but the preview version 0.98.836 (May 11th, 2014) works fine.
  • Make sure git is installed/available.
  • Install dependencies (note that installing boost will take a few minutes. Make sure there are 2GB memory or will get a memory related error when running make install)
cd rstudio-rstudio-dbf531d  # the number at the end depending on the source
cd dependencies/linux
./install-dependencies-debian
  • Create build directory
mkdir build
cd build
  • Configure by running cmake
cmake .. -DRSTUDIO_TARGET=Desktop -DCMAKE_BUILD_TYPE=Release

If something is wrong related to boost library, go back to step 1. Then type (installing boost library takes a while)

cd dependencies/linux 
run ./install-boost

And for some reason, when I try to run cmake (OS is 32-bit LXLE running on VM), I get the following error

CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find Qt4 (missing: QT_QTWEBKIT_INCLUDE_DIR QT_QTWEBKIT_LIBRARY
  QT_QTDBUS_INCLUDE DIR QT_QTDBUS_LIBRARY) (found suitable version "4.8.6", minimum required
  is "4.8.0")
  • Build and Install
sudo make install

For RStudio Desktop on Linux, make install automatically creates an entry in the Applications -> Programming menu for RStudio. The rstudio can be launched by /usr/local/lib/rstudio/bin/rstudio.

Preferences

RStudio Theme

Background color

  • Classic: Code and Console/Terminal are dark, Environment/history/connections and Files/Plots/Packages/Help/Viewer are white (good when doing finding)
  • Modern: 4 panels are all dark
  • Sky: 4 panels are all dark

Change repository

Use chooseCRANmirror().

In my case, stringr package source code in cloud.r-project.org (default in RStudio or 0-Cloud from chooseCRANmirror()) is 1 week old. That version of source code is now archived and the URL shown from the output of install.packages() cannot be found. When I switch to USA-IA mirror, it has the latest version.

Use options("repos") to see its effect.

Get help on firefox/chrome browser

(The help panel is kind of small)

No, it can't. But alternatively, if we click "Show in a new window" icon, it will bring the help on an independent window.

> getOption("browser")
function (url) 
{
    .Call("rs_browseURL", url)
}
<environment: 0x1121bda60>

Install on Crouton

Test on my Asus Chromebox/Crouton with Ubuntu 14.04.

(trusty)brb@localhost:~$ sudo dpkg -i '/tmp/mozilla_brb0/rstudio-1.0.44-amd64.deb' 
Selecting previously unselected package rstudio.
(Reading database ... 133157 files and directories currently installed.)
Preparing to unpack .../rstudio-1.0.44-amd64.deb ...
Unpacking rstudio (1.0.44) ...
dpkg: dependency problems prevent configuration of rstudio:
 rstudio depends on libjpeg62; however:
  Package libjpeg62 is not installed.

dpkg: error processing package rstudio (--install):
 dependency problems - leaving unconfigured
Processing triggers for shared-mime-info (1.2-0ubuntu3) ...
Processing triggers for hicolor-icon-theme (0.13-1) ...
Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...
Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.54ubuntu1.1) ...
Errors were encountered while processing:
 rstudio

After I run sudo apt-get install libjpeg62, RStudio can be installed successfully.

Switch R version for RStudio desktop

https://support.rstudio.com/hc/en-us/articles/200486138-Changing-R-versions-for-RStudio-desktop

Keyboard shortcut

RStudio Server Installation on Ubuntu

https://rviews.rstudio.com/2017/06/21/analytics-administration-for-r/

RStudio Server on Amazon EC2

Rstudio and Github

http://www.datasurg.net/2015/07/13/rstudio-and-github/

Plots window

Project

Running A Data Project In R

https://kkulma.github.io/2018-03-18-Prime-Hints-for-Running-a-data-project-in-R/

  • Use R projects. Always
  • Describe the purpose of your code / project.
  • Load all necessary packages in the beginning of your script & consider calling functions in a package via ::
  • Name your code sections and use them for quick navigation
  • Make your life easier and mark your code when you need to
  • Write your code as if someone was going to use it without communicating with you. From. Day. One
  • Name your files like a Pro: Machine readable, human readable & play well with ordering
    • Put something numeric in your file name first.
    • use the YYYY-MM-DD format for dates
    • regular expression and globbing friendly
    • easy to compute on using delimiters
    • left pad other numbers with zeroes
  • With big, complex data projects use project pipeline
    • load.R
    • clean.R
    • func.R
    • do.R
  • Never save your workspace
  • Before publishing/sharing your code, run it in the fresh workspace

Navigation

You create a new code section by writing #### or ---- at the end of any comment that is to become a new code section.

Addins

https://support.rstudio.com/hc/en-us/articles/215605467