Professional Documents
Culture Documents
Module0 - Part1 - Intro To R Functions
Module0 - Part1 - Intro To R Functions
###Introduction to R
#practicising common functions
#doubt??
concrete$rowMeans(concrete[c(1,3,7,9,150), ])
#systematic samples
rowMeans(concrete[c(1,1030,5)])
seq(1,100,4)
seq(8,92,5)
names(conc)[1:9]<-c() #doubt??
#renaming columns/variables
concrete<-Concrete_Data
names(concrete)[1:9] <- c("cement_comp","slag_comp","flyash_comp",
"water_ratio","plastic_comp","cagg_comp",
"fagg_comp","duration","comp_strength") #renaming headers
set.seed(123)
mysample_index <- sample(1:nrow(concrete), 50,
replace=FALSE) #doubt??
##ADding rows/columns
#the variables should be same for rbind while same #observations for cbind
conc_6_M<-colMeans(conc_6) #mean of all elements in the rows
conc_6<-rbind(conc_6,conc_6_M) #adding mean row to original file
conc_comb<-rbind(conc_4,conc_5) #combining data of two files
#####freeing up memory
# remove(conc)
# remove(conc_01)
# remove(conc_02)
# remove(conc_03)
# remove(conc_1)
# remove(conc_2)
# remove(conc_3)
# remove(conc_3_2)
# remove(conc_4)
# remove(conc_5)
# remove(conc_6)
# remove(conc_6_M)
# remove(Concrete_Data)
# remove(concrete)
# remove(Concrete_Data)
# remove(conc_comb)
# remove(mysample)
# remove(mysample_index)