Building Statistical Calculator using R.
#********************************************* Assignment-3 *********************************************
MyStatsCalci.r
Dividing the functionality of the program into separate modules.
a. R pdfs. b. R from Tutorials Point. c. R Documentation for specific functions descriptions. d. John E. Freund's Mathematical Statistics with Applications by Irwin Miller.
a. R-Studio (3.4.1) b. R Console (3.4.1) c. Sublime Text
a. sqrt(...) : Computes the square root of the specified value. b. sort(...) : Sort a vector or factor into ascending or descending order. c. cat(...) : Outputs the objects, concatenating the representations. d. readline(...) : Reads a line from the terminal (in interactive use). e. install.packages(...) : To install packages. f. library(...) : To load packages. g. as.numeric(...) : Creates or coerces objects of type "numeric". h. length(...) : Get or set length of vectors (including lists) and factors. i. fread(...) : To read the file. j. as.integer(...) : Converts to an integer value. k. exp(...) : Computes the exponential of the given value. l. formatC(...) : Formatting numbers individually and flexibly. m. qchisq(...) : Density, distribution function, quantile function and random generation for chi-squared distribution. n. qt(...) : Density, distribution function, quantile function and random generation for the t distribution. o. qnorm(...) : Density, distribution function, quantile function and random generation for the normal distribution. p. pnorm(...) : Density, distribution function, quantile function and random generation for the normal distribution. q. hist(...) : Computes a histogram of the given data values. r. plot(...) : Generic function for plotting of R objects. s. barplot(...) : Creates a bar plot with vertical or horizontal bars. t. pie(...) : Draw a pie chart. u. boxplot(...) : Produce box-and-whisker plot(s) of the given (grouped) values. v. qqplot(...) : QQ plot of observed P-values vs expected P-values. w. qqnorm(...) : Produces a normal QQ plot of the values in y. x. qqline(...) : Adds a line to a “theoretical” quantile-quantile plot which passes through the probs quantiles. y. stem(...) : Produces a stem-and-leaf plot of the values in x. z. pareto.chart(...) : Plot a Pareto chart.
*(...) depicts number of arguments.
- MAIN : Executing function.
- USERINPUT : For takeing command line user input.
- READFROMCSV : For taking input from file.
- INPUT : For selecting data entry method (either by USERINPUT or READFROMCSV).
- MEAN : For computation of arithmetic mean.
- VARIANCE2 : For computation of population variance.
- VARIANCE2 : For computation of sample variance.
- SD : For computation of standard deviation.
- MEDIAN : For computation of median.
- MODE : For finding number with maximum frequency.
- MEANABSDEV : For computation of mean absolute deviation.
- MINIMUM : For finding number with minimum value.
- MAXIMUM : For finding number with maximum value.
- RANGE : For finding range (difference of maximum and minmum value).
- QUARTILES : For finding the quartiles (q1, q2, q3).
- IQR : For finding the Inter quartile range.
- SKEWNESS : For finding skewness(g1).
- KURTOSIS : For finding kurtosis(g2).
- MOMENTS : For finding central moments.
- DESCRIPTIVEANALYSIS : Executing function for Descriptive Analysis.
- CORRELATION : For finding Karl Pearson Coefficient of correlation.
- MULTREG : For finding line of multiple linear regression for three variables.
- PREDANALYSIS : Executing function for Predictive Analysis.
- FACTORIAL : For finding factorial of a number.
- PERMUTATION : For finding nPr.
- COMBINATION : For finding nCr.
- BASICPROBABILITY : For finding Basic probability.
- BAYESTHEOREM : For finding P(Ai|B) using P(B|Ai) and P(Ai).
- PROBABILITYANALYSIS : Executing function for Probability Analysis.
- UNIFORMDISTRIBUTION : For finding probability of a random variable following uniform distribution.
- BERNOULLI : For finding probability of a random variable following bernoulli distribution.
- BINOMIALDISTRIBUTION : For finding probability of a random variable following binomial distribution.
- GEOMETRIC : For finding probability of a random variable following geometric distribution.
- HYPERGEOMETRIC : For finding probability of a random variable following hypergeometric distribution.
- NEGATIVEBIN : For finding probability of a random variable following negative binomial distribution.
- POISSON : For finding probability of a random variable following poisson distribution.
- MULTINOMIAL : For finding probability of a random variable following multinomial distribution.
- MULTIHYPGEO : For finding probability of a random variable following multi hypergeometric distribution.
- DISCRETEDISTRIBUTION : Executing function for Discrete Distribution Functions.
- UNICONTINOUS : For finding probability of a random variable following uniform continuous distribution.
- NORMALDIST : For finding probability of a random variable following normal distribution.
- GAMMADIST : For finding probability of a random variable following gamma distribution.
- CONTINOUSDISTRIBUTION : Executing function for Continuous Distribution Functions.
- CHISQDIST : Density, distribution function, quantile function and random generation for the chi-squared (chi^2) distribution.
- TDIST : Density, distribution function, quantile function and random generation for the t distribution.
- FDIST : Density, distribution function, quantile function and random generation for the f distribution.
- ZDIST : Density, distribution function, quantile function and random generation for the z distribution.
- SAMPLEDISTTEST : Executing function for Sample Distribution Test Statistic.
- INTERVALESTIMATION : Executing function for Interval Estimation.
- SIGNTEST : For testing hypothesis on basis of sign given by null hypothesis.
- NONPARAMANALYSIS : Executing function for Non-Parametric Analysis.
-
HISTOGRAM : Computes a histogram of the given data values.
-
LINEGRAPH : Computes a line graph of the given data values.
-
BARGRAPH : Computes a bar graph of the given data values.
-
PIECHART : Computes a pie chart of the given data values.
-
SCATTERPLOT : Computes a scatter plot of the given data values.
-
BOXPLOT : Computes a box plot of the given data values.
-
QQPLOT : Computes a q-q plot of the given data values.
-
STEMLEAFPLOT : Computes a stem leaf plot of the given data values.
-
PARETOCHART : Computes a pareto chart of the given data values.
-
VISUALIZATIONS : Executing function for Visualizations.
-
VISUALIZATIONS : Executing function for Visualizations.
-
readline Description: It reads a line from the terminal (in interactive use). The prompt string will be truncated to a maximum allowed length, normally 256 chars (but can be changed in the source code). Syntax: readline(prompt = "") prompt : The string printed when prompting the user for input. Should usually end with a space " ".
-
install.packages Download and install packages from CRAN-like repositories or from local files. Syntax : install.packages(package) package : character vector of the names of packages whose current versions should be downloaded from the repositories.
-
library For Loading/Attaching And Listing Of Packages. Syntax : library(package) package : the name of a package to be loaded
-
as.numeric Converts the argument column into a numeric value column Syntax : as.numeric(x) x : a column from a data set to be converted into numeric.
-
length Length Of An Object. Get or set the length of vectors (including lists) and factors, and of any other R object for which a method has been defined. Syntax : length(x) length(x) <- value x : an R object. For replacement, a vector or factor. value : a non-negative integer or double (which will be rounded down).
-
fread Similar to read.table but faster and more convenient. All controls such as sep, colClasses and nrows are automatically detected. Syntax : fread(input, sep="auto", sep2="auto", skip=0L, na.strings="NA", blank.lines.skip=TRUE) Input : Either the file name to read (containing no \n character), a shell command that preprocesses the file (e.g. fread("grep blah filename")) or the input itself as a string (containing at least one \n).
-
sqrt Computes the square root of the specified float value. Syntax : sqrt(x) x : an R object. For replacement, a vector or factor.
-
sort Sort a vector or factor into ascending or descending order. Syntax : sort(x, decreasing = FALSE, …) x : an R object. For replacement, a vector or factor. decreasing : logical. Should the sort be increasing or decreasing?
-
cat Outputs the objects, concatenating the representations. Syntax : cat(… , file = "", sep = " ", fill = FALSE, labels = NULL, append = FALSE) … : R objects (see ‘Details’ for the types of objects allowed). file : A connection, or a character string naming the file to print to. sep : a character vector of strings to append after each element. fill : a logical or (positive) numeric controlling how the output is broken into successive lines. labels : character vector of labels for the lines printed. Ignored if fill is FALSE. append : logical. Only used if the argument file is the name of file
-
exp Computes the exponential of the given value. Syntax : exp(x) x : Column to compute on.
-
as.integer Converts to an integer value. Syntax : as.integer(x) x : an R object.
-
formatC Formatting numbers individually and flexibly. Syntax : formatC(x, digits = NULL, format = NULL) x : an atomic numerical or character object. digits : the desired number of digits after the decimal point. format : equal to "d" (for integers), "f", "e", "E", "g", "G", "fg" (for reals), or "s" (for strings).
-
qchisq Density, distribution function, quantile function and random generation for the chi-squared distribution with df degrees of freedom and optional non-centrality parameter ncp Syntax : qchisq(p, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) p : vector of probabilities. n : number of observations. If length(n) > 1, the length is taken to be the number required. df : degrees of freedom (non-negative, but can be non-integer). ncp : non-centrality parameter (non-negative). log, log.p : logical; if TRUE, probabilities p are given as log(p). lower.tail : logical; if TRUE (default), probabilities are P[X≤x], otherwise, P[X>x].
-
qt Density, distribution function, quantile function and random generation for the t distribution with df degrees of freedom (and optional non-centrality parameter ncp. Syntax : qt(p, df, ncp, lower.tail = TRUE, log.p = FALSE) p : vector of probabilities. n : number of observations. If length(n) > 1, the length is taken to be the number required. df : degrees of freedom (>0, maybe non-integer). df = Inf is allowed. ncp : non-centrality parameter δ; currently except for rt(), only for abs(ncp) <= 37.62. If omitted, use the central t distribution. log, log.p : logical; if TRUE, probabilities p are given as log(p). lower.tail : logical; if TRUE (default), probabilities are P[X≤x], otherwise, P[X>x].
-
qnorm Density, distribution function, quantile function and random generation for the normal distribution with mean equal to mean and standard deviation equal to sd. Syntax : qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) p : vector of probabilities. n : number of observations. If length(n) > 1, the length is taken to be the number required. mean : vector of means. sd : vector of standard deviations. log, log.p : logical; if TRUE, probabilities p are given as log(p). lower.tail : logical; if TRUE (default), probabilities are P[X≤x] otherwise, P[X>x].
-
pnorm Density, distribution function, quantile function and random generation for the normal distribution with mean equal to mean and standard deviation equal to sd. Syntax : pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) q : vector of quantiles. n : number of observations. If length(n) > 1, the length is taken to be the number required. mean : vector of means. sd : vector of standard deviations. log, log.p : logical; if TRUE, probabilities p are given as log(p). lower.tail : logical; if TRUE (default), probabilities are P[X≤x] otherwise, P[X>x].
-
hist The generic function hist computes a histogram of the given data values. If plot = TRUE, the resulting object of class "histogram" is plotted by plot.histogram, before it is returned. Syntax : hist(x, main = paste("Histogram of" , xname), xlab = xname, ylab, labels = FALSE, col = color, …) x : a vector of values for which the histogram is desired. main, xlab, ylab : these arguments to title have useful defaults here. col : to fill specified color … : further arguments and graphical parameters passed to plot.histogram and thence to title and axis (if plot = TRUE).
-
plot Generic function for plotting of R objects. Syntax : plot(x, y, …) x : the coordinates of points in the plot. Alternatively, a single plotting structure, function or any R object with a plot method can be provided. y : the y coordinates of points in the plot, optional if x is an appropriate structure. … : Arguments to be passed to methods, such as graphical parameters. Many methods will accept the following arguments: main, xlab, ylab : these arguments to title have useful defaults here. col : to fill specified color type : what type of plot should be drawn. Possible types are "p" for points, "l" for lines, "b" for both, and more.
-
barplot Creates a bar plot with vertical or horizontal bars. Syntax : barplot(height, …) height : either a vector or matrix of values describing the bars which make up the plot. … : arguments to be passed to/from other methods. For the default method these can include further arguments main, xlab, ylab : these arguments to title have useful defaults here. col : to fill specified color
-
pie Draw a pie chart. Syntax : pie(x, …) x : a vector of non-negative numerical quantities. The values in x are displayed as the areas of pie slices. … : graphical parameters can be given as arguments to pie. They will affect the main title and labels only. main, xlab, ylab : these arguments to title have useful defaults here. col : to fill specified color col=rainbow(length(x))
-
boxplot Produce box-and-whisker plot(s) of the given (grouped) values. Syntax : boxplot(x, …) x : for specifying data from which the boxplots are to be produced. Either a numeric vector, or a single list containing such vectors. Additional unnamed arguments specify further data as separate vectors (each corresponding to a component boxplot). NAs are allowed in the data. … : For the formula method, named arguments to be passed to the default method. main, xlab, ylab : these arguments to title have useful defaults here. col : to fill specified color
-
qqplot QQ plot of observed P-values vs expected P-values, using the empirical (permutation-based) expected p-value distribution. Syntax : qqplot(P.perm, P.observed, …) P.perm : Expected P-values from NULL distribution, which is generated through permutation in our example. P.observed : Observed P-values from true case/control assignment. … : For the formula method, named arguments to be passed to the default method. main : these arguments to title have useful defaults here. col : to fill specified color
-
qqnorm qqnorm is a generic function the default method of which produces a normal QQ plot of the values in y. Syntax : qqnorm(y, …) y : The only data sample. … : graphical parameters.
-
qqline Adds a line to a “theoretical”, by default normal, quantile-quantile plot which passes through the probs quantiles, by default the first and third quartiles. Syntax : qqline(y, …) y : The only data sample. … : graphical parameters.
-
stem Produces a stem-and-leaf plot of the values in x. Syntax : stem(x) x : a numeric vector.
-
pareto.chart Plot a Pareto chart. Syntax : pareto.chart(x, ylab = "Frequency", ylab2 = "Cumulative Percentage", xlab, main, col = heat.colors(length(x)), ...) x : a vector of values. names(x) are used for labelling the bars. ylab : a string specifying the label for the y-axis. ylab2 : a string specifying the label for the second y-axis on the right side. xlab : a string specifying the label for the x-axis. main : a string specifying the main title to appear on the plot. col : a value for the color, a vector of colors, or a palette for the bars. See the help for colors and palette. ... : other graphical arguments to be passed to the barplot function.