learning r by exampple chotu notes

4
R accepts strings in single and double quotes. C() creates a column in a file creates a vector Variable name = Table( vector name). Table is used for finding frequency. Freq appears in column format. To get this in a more readable format use var2 = data.frame.(var1). Var1.frame() aligns it in a more readable and a list format. Barplot(var1) – this will give the bar charts. The tallest is the mode value. Col = “red” “A”,”B”,”C” Grades=c(‘A’, ‘A’ , ‘B’ , ‘C’ , ‘A’ , ‘B’ , ‘C’ , ‘A’ , ‘B’ , ‘C’ , ‘A’ , ‘B’ , ‘C’ , ‘A’ , ‘A’ , ‘A’ ,’B’ ) Fre2=table(as.vector(Grades)); Mode=names(Fre2)[Fre2=max(Fre2)];

Upload: vikramaditya-rattan

Post on 26-Sep-2015

213 views

Category:

Documents


0 download

DESCRIPTION

R programming

TRANSCRIPT

R accepts strings in single and double quotes.C() creates a column in a file creates a vector Variable name = Table( vector name). Table is used for finding frequency. Freq appears in column format. To get this in a more readable format use var2 = data.frame.(var1). Var1.frame() aligns it in a more readable and a list format.

Barplot(var1) this will give the bar charts. The tallest is the mode value. Col = redA,B,C

Grades=c(A, A , B , C , A , B , C , A , B , C , A , B , C , A , A , A ,B )Fre2=table(as.vector(Grades)); Mode=names(Fre2)[Fre2=max(Fre2)];

#data entry > > var1=c(8,7,8,3,2,1,45,65,78,43,4,2,54,1,2323,4,56,78,98,9,65,4,88,123,234);> range(var1);[1] 1 2323> Freq=table(as.vector(var1));> Freq;

1 2 3 4 7 8 9 43 45 54 56 65 78 88 98 123 234 2323 2 2 1 3 1 2 1 1 1 1 1 2 2 1 1 1 1 1 > var1=c(8,7,8,13,13,6,24,13,7,43,4,24,54,1,24,4,56,7,8,9,65,4,8,13,24);> range(var1);[1] 1 65> Freq=table(as.vector(var1));> Freq;

1 4 6 7 8 9 13 24 43 54 56 65 1 3 1 3 4 1 4 4 1 1 1 1

var2=cut(var1,breaks,right=FALSE);> plot(var2);> # cut function cuts the data in specified intervals.> > range(var2);Error in Summary.factor(c(2L, 2L, 2L, 4L, 4L, 2L, 6L, 4L, 2L, 11L, 1L, : range not meaningful for factors> range(var1);[1] 1 65

Median may nit be in center only in case of

Setwd is used to set the default directory for files and folders for RMydata=read.csv(file name.csv,header=TRUE) --- to be used only if default directory is setMydata=read.csv(file.choose(),header=TRUE) will give option of search box for you to chose

Descriptive Statistics :- Pillars of Stats :-Description :- what has happenedDiagnosis :PredictionPrescription :-

Risk is measure by Standard deviation.Methods chosen to elucidate the quantitative data. By statistics we mean quantitative data affected to a marked extent by multiplicity of causes. By Statistics we mean aggregates of facts affected to a marked extent by multiplicity of causes, numerically expressed, enumerated or estimated according to reasonable of accuracy, collected in a systematic manner for a predetermined purpose and placed in relation to each other.

Stats deal with numbers and try to find patternsMarket basket analysis ??Why six sigma :- 3.4 defects per million opportunities .Defects may not only be physical but it could be psychological as well.AOQL :- Average outgoing quality level.