• Home
  • University of Queensland
  • Analysis Of Scientific Data
  • Statistical Analysis and RStudio Techniques

Statistical Analysis and RStudio Techniques

Statistics Assessment Task Due Date Weighting Learning Objectives Computer-based Assessment Online Quizzes 15:00 Fridays 15% 1, 2, 4, 5 Article Review Statistical Review 16 Aug 21 15:00 5% 1, 2, 3,6 Essay Ethics Review 20 Sep 21 15:00 10% 1, 2, 3, 6 Video Research Project 25 Oct 21 15:00 20% 2, 3, 5, 6 Exam - during Exam Period (School) Final Examination Examination Period 50% 2, 3, 4, 5 RStudio Note: R functions are case sensitive Note: Using help(function) or ?function gives help screen Use up arrow key_to edit previous line Store values in variables using = Store values in lists using c(values) Functions . length(list) gives length of the list · mean(list) gives average of values in list o dmean gives the difference in means between two categories · median(list) gives median · sd(list) gives standard deviation · IQR(list) gives interquartile range Note: Using $column_name specifies the function for a specific column in a data set exp(value) gives exponent log(value) gives logarithm (natural log) - to change to different bases add log(value, base=base) A csv file is a file containing comma separated values Variable = read.csv("data/survey_location.csv") loads the values in the csv into Rstudio · str(quiz2) gives the structure of the data . nrow(quiz2) gives the number of rows in the data · names(quiz2) gives just the variable names . head(quiz2) gives the first 6 rows of the data · Variable gives all the data Begin by loading file using Variable = read.csv("data/survey_location.csv") Load functions using library(lattice) Aggregate splits data values into different categories e.g sex aggregate(value ~ separation_category, data=dataset) Note: values can also be included using dataset$category Note: number:number gives all numbers from the first number to the second number sample(list) shuffles the values stored in the list in random order replicate(number_of_times, function) repeats a function the indicated number of times (for repetition) histogram(replicate) produces a graph of the values from the repeated function Note: true is stored as 1 and false is stored as 0 - to determine the number of trues, sum the replicate function stripplot(values) produces a dot plot jitter=TRUE adds jitter to the dot plot Amount=VALUE determines the amount of jitter produced histogram(values) produces a histogram Nint changes the number of intervals densityplot(values) produces a density plot bwplot(values) produces a box and whisker plot mosaicplot(table(values) produces a mosaic plot xyplot(values, data=variable) produces a plot with two variables cor(values) displays the correlation between two different data sets fivenum(values) produces the 5 figure summary for some data type=c adds plotting options to graph · g shows a grid · p shows data points · I joins the data points together with lines . b shows both data points and lines . r shows a regression line . smooth shows a loess smoothing line table(dataset$value) creates a table of values containing the number of objects under each category prop.table(table(dataset$value) creates a table of values containing the proportion of objects under each category t.test(dataset$value, alternative=") performs a one sample t test - quiz 5 t.test(category~category, data=) performs