R is an open-source (free), and highly flexible programming language. It offers advantages over many other programming languages in that it can be leveraged to perform a wide range of tasks beyond solely data management/analysis (e.g., websites can be created with R via shinyapps, you can scrape data directly from websites, it offers flexible data visualizations including mapping)
The base R can be downloaded here (a version for mac is available here)
It's strongly recommended to also download R Studio, which is available here.
It provides a more effective, user-friendly way to run R - including containing the dialogue box, plots, files, and other important features all within a single platform. For example, when outputting plots in base R the plots will appear as a new window, which will need to be relocated / can obscure the screen - whereas in R studio plots are contained within a viewer that has a fixed, dedicated location in the platform.
Important code
#Clear existing data and graphics
rm(list=ls())
graphics.off()
#Download one or multiple packages
install.packages("tidyverse")
install.packages(c("tidyverse", "ggplot2"))
#Load a downloaded package
library(tidyverse)
#check version of R
version()
#check location of working directory
getwd()
#Set the type of a field
dataset$Group = factor(dataset$Group)
#subset a dataset
newdata <- subset(olddata, age >= 18 | age < 65, select=c(patient, height))
newdata <- subset(olddata, age >= 18, select = -c(geography))
#create simple mock dataset
patient = c("1001", "1002", "1003", "1004", "1005")
category = c(1,2,3,4,2)
DEMENTIA = c(0,1,1,0,0)
timev1 = c(5,10,16,2,7)
sex = c(1,1,1,0,0)
dataset1 <- data.frame(patient, category, DEMENTIA, timev1, sex)
#create new field based on conditions
mydata$agecategory[age > 18 & age <= 65] <- "Adults"
#rename field
mydata <- rename(mydata, c(oldname="newname"))