Anuj Varma Software • Cloud • Security • AI

Quick Intro to R

Also see, The BigData Landscape

 

x <- “Hello World”;
print(x)
#vector
v <- c(1, 2, 3)
print(v)
#sequence
s <- 1:5
print(s)
#matrix
m <- matrix(data = 1:6, nrow = 2, ncol = 3)
#array
a <- array(data = 1:8, dim = c(2, 2, 2))
print(a)
#list heterogenous
l <- list(TRUE, 123L, 2.3, “abc”)
#creating a factor
categories <- c(“Male”, “Female”, “Male”, “Male”)
factor <- factor(categories)
print(factor)
print(levels(factor))
print(unclass(factor))

#Creating Data Frame – for working with tabular data
df <- data.frame(Name = c(“Cat”, “Dog”, “Cow”, “Pig”), HowMany = c(5, 10, 15, 20), IsPet = c(TRUE, TRUE, FALSE, FALSE))
print(df)
print(2:4,)
print(df$IsPet == TRUE,)
print(df$Name %in% c(“Cat”, “Cow”))

#Vectorized language
print(c(1, 2, 3) + c(3, 4, 5))

#Installing packages
install.packages(“dplyr”)

#Loading Packages
library(“dplyr”)

#Help ?
? data.frame

#Named versus Ordered Args
m <- matrix(data = 1:6, nrow = 2, ncol = 3)
n <- matrix(1:6, 2, 3)
m == n

identical(m, n)

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.