Professional Documents
Culture Documents
>data entry
bt=c(1,2,3,4,5,5,4,2,3,1)
>length(nameofdata)
>nrow(nameofdatatable)
>ncol(nameofdatatable)
>dataname[,-1]
>dataname[c(2,17,8),]
>dataname[,c(6,4,12)]
>dataname[1:10,]
>dataname[,1:10]
>data.frame(nameofdata,variables)
>nameofdata[,1]
>mean(nameofdata)
>mean(nameofdatatable[,2])
>mean(nameofdatatable[,2][1:50])
>aggregate(datatablename[,5]~datatablename[,3],data=datatablename,FUN=mean)
>aggregate(datatablename[,5]~datatablename[,3],data=datatablename,FUN=sd)
>aggregate(datatablename[,5]~datatablename[,3],data=datatablename,FUN=summary)
>sort(dataname)
>unique(dataname)
>plot(dataname)
>plot(dataname,col="green")
>plot(dataname,col="red",xlab="bodytemperature",ylab="weights")
>boxplot(dataname,col="red",xlab="bt",ylab="weights",main="graph")
>summary(nameofdataordatatable)
>data()
>head(nameofdata)
>tail(nameofdata)
>str(nameofdata)
>getwd()
>namethedata=read.table("D:/Nabeela/mphil 2 semester/stat/data
sets/quail_partial_data.txt",header=T)
>windows()
>par(mfrow=c(2,5))
-this command is used to get any column from given data table
-after applying this command just type name of column you want to work
>nameofdata[,1]
-same as above
>nameofdata$nameofcolumn
-same as above
>cbind(nameofcolumn,nameofothercolumn)
>rbind(nameofcolumn,nameofothercolumn)
-this command is used to bind two coloumns and represent in row format
>table(dataname[,2])
> plot(iris[,1],col="black",ylim=c(0,8))
> points(iris[,2],col="red")
> points(iris[,3],col="blue")
> points(iris[,4],col="green")
>givename=which(variablename=="valueofvariable")
-f=which(Maternal=="F1") OR p=Maternal[-f]
-> f
[1] 1 2 3 4 22 23 24 25 26 27 28 29 30 31 32 47 48 67 68
[39] 123 124 125 126 127 128 129 130 144 145 146 147 148 169 170 171 172 173 174
-> Maternal[f]
[1] "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1"
[16] "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1"
[31] "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1"
[46] "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1" "F1"
STEPS:
1-TO CHECK LINEARITY PLOT SCATTER PLOT BETWEEN DEPENDENT VARIABLE (Y) AND INDEPENDENT
VARIABEL (X)
>lm(dependentvariable~independentvariable)
>plot(independentvar,dependentvar)
>points(independentvar,yhat,col="anycolor")
>lines(independentvar,yhat,col="anycolor")
>abline(lm(dependentvar~independentvar),col="red")
>pred=predict(fit,newdata=nameofnewdata)
-to get prediction of new data set based on previous data lm results
>cor(nameofdata)
>givename=which(nameofcolumn=="nameofcategory")
>givename
-for example:
Gender
1 3 7 9 13 16 17 18 19 20 21 23 24
25 27 30 31 32 33 34 40 41 42 43 48 49 50 51 52 58
>nameofcolumn[namegiven]
"M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M"
"M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M" "M"
>cor(nameofdata[,-c(1:3)])
> library(nameofpackage)
-for example
library(ppcor)
>pcor(nameofdata)
>cor(variableone,variable2,method="spearmen")
>cor(variableone,variabletwo,method="kendal")
>cor.test(variableone,variabletwo,method="kendal")
>cor(nameofdatatabel,method="spearman")
>ad.test(nameofdata)
>shapiro.test(nameofdata)
>
testing of hypothesis:
TESTING OF HYPOTHESIS:
STEPS:
1:Normality
2:Homogenity
3:tests
>dataname=rep(1:4,each=5)
>txmean=tapply(name of data $ treatment output name , name of data $ treatment name ,mean)
>duncanTest(fitt)
>tukeyHSD(fitt)