R is a powerful open-source language for statistical computing and data analysis. It offers a wide range of tools for data manipulation, modeling, and visualization, making it popular in academia, research, and industry across various domains. Getting started with R involves downloading and installing it from CRAN, setting up an IDE like RStudio, and learning basic syntax. R supports various data types and structures, allowing users to perform complex analyses and create high-quality visualizations efficiently.
setwd() function to specify the default location for reading and writing filesinstall.packages() function to extend R's functionality
update.packages() function to ensure compatibility and access to the latest features<- or = operator
c() function or by using the : operator for sequencesfactor() functionmatrix() function# for single-line comments and /* */ for multi-line comments[] for indexing and selecting elements+, -, *, /)==, !=, <, >, <=, >=) to create logical vectors for subsetting or filtering dataapply() family of functions (apply(), lapply(), sapply(), tapply())
dplyr or data.table
reshape(), melt(), and cast() to convert between wide and long formatsNA) using functions like is.na(), na.omit(), and complete.cases()function() keyword followed by the function bodyreturn() statement or by explicitly printing the resultif and else statements for conditional execution based on logical conditions
&, |, !)for loops to iterate over a sequence of values or elements in a data structure
while loops to repeatedly execute a code block as long as a condition remains truebreak and next statements to control loop execution
break terminates the loop prematurelynext skips the rest of the current iteration and moves to the next iterationtry() and tryCatch() to catch and handle runtime errors gracefullyread.table() or read.csv() to import tabular data from text files
readxl package to import data from Excel files (read_excel())DBI package and the appropriate database driver
read.table() with a URL or the httr package for more advanced web scrapingwrite.table() or write.csv()
save() and load them back using load()saveRDS(), readRDS()) or feather (write_feather(), read_feather()) for efficient storage and retrieval of R objectsplot() function to create basic scatter plots, line plots, and bar plots
col, pch, lty, and mainhist() function to visualize the distribution of a variableboxplot() function to display the distribution and summary statistics of a variable across different categoriesbarplot() function to create bar charts for categorical datatitle(), xlabel(), ylabel(), and legend()par(mfrow=c(nrow, ncol)) or layout()ggplot2 for more advanced and customizable visualizations
png(), pdf(), or svg() for saving and sharing visualizationstm packageBioconductor packagessf and leaflet packagesrvest package for market analysis