Posts

Showing posts from February, 2023

Qualitative and Quantitative Data

 Qualitative Data / Categorical shirts <- c('S','M','L','XL','XXL','M','L','XL','XXL','S','M') shirts shirt_sizes <- factor(shirts) shirt_sizes str(shirt_sizes) #Doesnt list all the levels, gives numeric representation #as an integer vector, and integer values corresponding to levels summary(shirt_sizes) shirts[2] shirt_sizes[2] levels(shirts) levels(shirt_sizes)#gives the listing of the levels table(shirt_sizes) baloons<-c('Blue','Blue','Red','Red','Blue','Yellow','Green') baloons baloon_colors<-factor(baloons) baloon_colors str(baloon_colors) summary(baloon_colors) baloons[1] baloon_colors[1] levels(baloon_colors) table(baloon_colors) Visualizing Qualitative Data shirts <- c('S','M','L','XL','XXL','M','M','L','L','XXL','M') shirt_sizes <-...

Data Visualization using R - Assignment 5 using MatPlot

Dataset:   https://drive.google.com/drive/folders/1gWs6FC6o2FxUDFL-sFAIxokjtYPZ2Ynz?usp=sharing BAR GRAPHS library(dplyr) mydata <- read.csv('murders.csv') myseldata <- select(mydata,state,population,murders)  barplot(myseldata$population) barplot(myseldata$population,         xlab='States',         ylab = 'population',         main='States Vs population',         names.arg = myseldata$state,         col ='blue',         border='red') myseldata <- select(mydata,state,population,murders)  barplot(myseldata$murders,         xlab='States',         ylab = 'murders',         main='States Vs murders',         names.arg = myseldata$state,         col ='blue',         border='red') myseldata <- select(mydata,state,population,murders...

dplyr - Assignment 1

Install DPLYR  install.packages('dplyr') The dplyr package offers functionality that is easy to understand when working with data tables. Offer a package of functions that has been well optimised. R does not gain any additional capabilities as a result of this. The functionality is really effective. Carries out the data processing tasks that are most frequently used Dataset:  https://drive.google.com/file/d/1KVMo0BhkIQkgO_YU7QjVLJ4BLie5VoJK/view?usp=sharing Code #select library(dplyr) mydata <- read.csv('murders.csv') mydata dim(mydata) str(mydata) summary(mydata) apply(X=mydata[,c(4,6)], MARGIN = 2, FUN = mean,na.rm=T) mydata[c(1,4,5)] #mydata[c(mydata, state,population,total)]#cannot use names(mydata) names(mydata)[c(1,4,5)] subset <- select(mydata, state:population)  subset subset <- select(mydata, state,population,total)  subset subset <- select(mydata, -(abb:region))  subset #filter library(dplyr) mydata <- read.csv('murders.csv') mydata dim(...

Import and Export DataSet

DataSet: https://drive.google.com/drive/folders/1VZ-p-_OjaMVDgMwSncwKkpFKK9Q7XiPR?usp=share_link Code  #import Data Table from txt mydata <- read.table('data.txt') mydata mydata <- read.table('data.txt',header=TRUE) mydata mydata <- read.table('dataspace.txt',header=TRUE) mydata mydata <- read.table('datadollar.txt',header=TRUE) mydata mydata <- read.table('datadollar.txt',header=TRUE,sep='$') mydata mydata <- read.table('data.txt',header=TRUE,nrows=5) mydata mydata <- read.table('data.txt',header=TRUE,skip=3) mydata mydata <- read.table('data.txt',nrows=5) mydata class(mydata) #import from csv file mydatacsv <- read.csv('data.csv') mydatacsv #import from rds file mydata <- readRDS('chicago.rds') mydata #import from internet url.show('http://assets.datacamp.com/course/compfin/sbuxPrices.csv') mydata <- read.table('http://assets.datacamp.com/course/compfin...