M

@mjclave123

JOIN in MYSQL

MySQL
3 years ago
-- create a table CREATE TABLE students ( id INTEGER PRIMARY KEY, name VARCHAR(30) NOT NULL, gender CHAR(1) NOT NULL ); -- insert some values INSERT INTO students VALUES (1, 'Ryan', 'M'); INSERT INTO students VALUES (2, 'Joanna', 'F'); insert

plotting

R
3 years ago
students = c(10,15,20,15,17,24,27,19,32,61,5,10,12,14,12,6,18,21,66,4) length(students) sorted_students = students[order(students)] #Histogram chart hist(students) # line chart plot(sorted_students, type = 'o')

Section 16

R
3 years ago
# Write you function here! square_it <- function(n_vector){ if(class(n_vector) !='numeric'){ return('Not a numeric vector!') }else{ return(n_vector**2) } } square_it(c(3,4,5,6,7))

grepl function

R
3 years ago
#It is used to find out which column contains the string provide in grepl function data(mtcars) colnames(mtcars) #rownames(mtcars) #data with those columns which has string 'a' mtcars[,grepl('a',colnames(mtcars))] # data with those column which do

Section 12-Exercise

R
3 years ago
#1 data(longley) #2 head(longley,5) #3 str(longley) #4

section 12

R
3 years ago
# Load the swiss dataset from R - don't forget # that you don't need to assign it to a variable # as it is an internal dataset from R data(swiss) # Extract dimensions of the dataframe and store # it in a variable called dim_swiss dim_swiss =

plotting the graphs using the inbuild functions of R

R
3 years ago
# plotting charts data(mtcars) mtcars$model = rownames(mtcars) #plotting a scatterplot plot(x=mtcars$hp, y=mtcars$wt, main ='Scatter plot with horse-power vs weight', xlab='Horse Power', ylab='Weight of car')

merging or joins in R

R
3 years ago
#joins in R data(mtcars) mtcars$Model=rownames(mtcars) mtcars$Brand = sapply(strsplit(mtcars$Model," "),FUN='[',n=1) mtcars$Model = NULL hp_mean = aggregate( mtcars$hp, by=list(mtcars$Brand),

Aggregate and sort function

R
3 years ago
data(mtcars) #mtcars mtcars$Model = rownames(mtcars) rownames(mtcars) = NULL mtcars$Brand = sapply(strsplit(mtcars$Model," "), FUN='[',n=1) hp_brands = aggregate( mtcars$hp, by = list(mtcars$Brand),

sapply function & strsplit function

R
3 years ago
data(mtcars) mtcars$Model = rownames(mtcars) rownames(mtcars) = NULL dim(mtcars) hp_max = max(mtcars$hp) mtcars[mtcars$hp == hp_max,] # to split the data list_model = strsplit(mtcars$Model," ")

Apply Family in R

R
3 years ago
# Apply Family in R data(mtcars) data(iris) #iris #dim(iris) #head(iris,5) #apply(iris[,(1:4)], MARGIN=2, FUN=max) # lapply always returns a list l = lapply(iris[,(1:4)],FUN = mean)

creating new column in Data frame

R
3 years ago
# loading data externally data(mtcars) # creating a new column #1 mtcars[,length(mtcars)+1] = (mtcars[,'hp']/mtcars[,'wt']) #dim(mtcars) colnames(mtcars)[length(mtcars)] = "torque" #mtcars[,c('hp','wt','torque')] mtcars = mtcars[,-12] #or mtcars[,

loading data externally & apply filters operations

R
3 years ago
data(mtcars) #dim(mtcars) #nrow(mtcars) #ncol(mtcars) #names(mtcars) #head(mtcars,5) #class(mtcars) #str(mtcars) #summary(mtcars)

Section 9

R
3 years ago
#1 math_list <- list( array((1:2),dim=c(1,2,3)), c(3,9,81), matrix(c(9,0,9,0),nrow=2,ncol=2) ) #2 names(math_list) = c("ThreeDArray", "Vector", "Matrix")

exercise on list

R
3 years ago
# Create a list with 3 elements: # - a character with the element "John" # - a vector with the values 100, 250, 300, 25 # - a matrix with the values (1,1,0,0) with # two rows and two cols # store the returning object in an object # called custom

list in R section 9

R
3 years ago
vector = c(1,2,'3') typeof(vector) list_1 = list(1,2,'3') class(list_1) length(list_1) list_2 = list('Manish',25,'Male')

Exercise 5- Date frame in R

R
3 years ago
# Create a new data frame with 3 columns (name, # minutes and type) # called sports with the following data: # name should have the rows Football, Hockey, Rugby # minutes should have the rows: 90, 70 and 80 # type: outdoor, indoor, outdoor

data frame exercise 1

R
3 years ago
Country_data_1 = data.frame( country = c('India', 'US', 'UK'), population = c(1420000000, 50000000, 45000000), EU = c(FALSE,TRUE,TRUE)) Country_data_1 str(Country_data_1) Country_data_1[1

List in R

R
3 years ago
# List is a type of storing the data in R which can hold everything vector, array, matrix, dataframe, or multi type data. list_1 <- list("Manish", 25, TRUE) class(list_1) # defining another list_1 list_2 = list(c(1,2,3), matrix(c(5,6,7,8), nrow =

Data frame in R

R
3 years ago
# These are the methode which can store multi type not like vector array or matrix. Country_data_1 = data.frame(country = c('India', 'US', 'UK'), population = c(1420000000, 50000000, 45000000), EU = c(FALSE,TRUE,TRUE)) Country_data_1 class(Countr