RStudio Server Guide

Accessing RStudio Server

Internal Access (Institute Network):

External Access (From Internet):

Getting Started with RStudio

  1. Login: Use your server credentials
  2. Interface: Familiarize yourself with the 4-panel layout
    • Source: Script editor
    • Console: R command line
    • Environment: Variables and data
    • Files/Plots: File browser and output display

RStudio Features

  • Integrated IDE: Complete R development environment
  • Package Management: Easy installation and loading of R packages
  • Version Control: Built-in Git support
  • Publishing: Share analysis and reports
  • Project Management: Organize work into projects

Example: R Data Analysis

# Load libraries
library(tidyverse)
library(ggplot2)

# Load and explore data
data <- read.csv("/data/sample_data.csv")
head(data)
summary(data)

# Data visualization
ggplot(data, aes(x = date, y = value)) +
  geom_line() +
  theme_minimal() +
  labs(title = "Data Trends Over Time",
       x = "Date",
       y = "Value")

File Management in RStudio

Accessing Files

Via RStudio Interface:

  • Use the Files panel (bottom-right by default)
  • Navigate directories using the file browser
  • Upload files using the “Upload” button

Via R Console:

# List files
list.files()

# Get current directory
getwd()

# Set working directory
setwd("/data/projects/my_project")

# Create directory
dir.create("new_folder")

Data Storage Locations

See the File Storage Guide for detailed information about data storage locations and file management.

Working with R Projects

Creating Projects

  1. New Project: File → New Project
  2. Choose Type:
    • New Directory (fresh start)
    • Existing Directory (use existing folder)
    • Version Control (clone from Git)

Project Benefits

  • Organization: Keep related files together
  • Working Directory: Automatic path management
  • Environment: Separate workspace for each project
  • Version Control: Easy Git integration

Package Management

Installing Packages

# Install from CRAN
install.packages("package_name")

# Install multiple packages
install.packages(c("dplyr", "ggplot2", "readr"))

# Install from Bioconductor
if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("package_name")

Loading Packages

# Load single package
library(dplyr)

# Load multiple packages
library(tidyverse)  # Loads multiple packages

# Check if package is installed
if (!require("package_name")) {
    install.packages("package_name")
    library(package_name)
}

Best Practices for RStudio

Code Organization

  1. Script Structure: Start with library loading, then functions, then main code
  2. Comments: Use # for comments, #' for function documentation
  3. Naming Conventions: Use snake_case for variables and functions
  4. Project Structure: Organize files in logical folders

Performance Optimization

  1. Memory Management: Use rm() to remove large objects
  2. Vectorization: Use vectorized operations instead of loops
  3. Data Types: Choose appropriate data types (factors, numerics)
  4. Parallel Processing: Use packages like parallel or foreach

Data Security

  1. Regular Saves: Save scripts and workspaces frequently
  2. Version Control: Use Git for code versioning
  3. Data Privacy: Follow institutional data handling guidelines
  4. Backup: Regular backup of important projects

Troubleshooting RStudio

Common Issues

RStudio Connection Issues:

# Check RStudio Server status (contact admin)
sudo systemctl status rstudio-server

# Restart RStudio Server (contact admin)
sudo systemctl restart rstudio-server

R Session Problems:

  • Session Crashed: Restart R session (Session → Restart R)
  • Memory Issues: Clear workspace or restart session
  • Package Errors: Check package installation and compatibility

Performance Issues:

  • Check system resources with htop or top
  • Close unused projects and clear large objects
  • Restart R session to free memory
  • Contact administrator for resource allocation

Error Diagnosis

# Check R version
R.version.string

# Check installed packages
installed.packages()

# Check memory usage
object.size(your_object)
gc()  # Garbage collection

# Session information
sessionInfo()

Advanced Features

Markdown Reports

  • R Markdown: Create dynamic reports mixing R code and text
  • Knit: Generate HTML, PDF, or Word documents
  • Shiny: Create interactive web applications

Version Control

  • Git Integration: Built-in Git support in RStudio
  • Commit: Track changes to your code
  • Push/Pull: Sync with remote repositories

Publishing

  • RPubs: Publish reports to RPubs
  • Shiny Server: Deploy Shiny applications
  • GitHub: Share code and collaborate

Getting Help


Back to: Apps Usage Guide

Need additional help? Contact the SRILS Server administration team for technical support.


Copyright © 2025 SRILS Server Documentation. Distributed under the MIT License.