# R

## Simple Power Analysis

Scenario Assume the following: I will be running a workshop called “Stats is fun” for a small number of participants. Before the workshop I will ask the participants “How enthusiastic are you about statistics?” and give them a scale from 1 to 5. Afterwards, I will ask the same people the same question and compare the responses. Question The primary research question is whether the workshop had an impact on the enthusiasm of the participants for statistics.

## Miscellaneous useful code

Survey Analysis Template While every survey is different; they generally share some common features. Thus, I start each survey analysis the same way: First I ensure that I have the data in neat flat sheet form, and then I create a second sheet of metadata that describes the data in useful ways. See this fake survey data spreadsheet example to better understand the idea. Second I use a Quarto script or an R Markdown script that processes the data and metadata in a generic way and includes all the tables and plots needed for most survey analyses, as well as notes and links explaining key topics.

Introduction This example is from the Random Effects Models notes of Prof. Robert Schall, UFS. Students at a specific faculty normally undergo a 4-year degree programme. However, applicants who do not have the required minimum Admission Point are enrolled in a 5-year programme; that is, they join the regular 4-year programme after an initial year of preparatory classes. In order to evaluate the effectiveness of the preparatory year, academic results (module marks) of students in the two programs were compared.

## Read and write files from R, starting with Excel files

Introduction The purpose of this guide is to highlight the many ways to read and write Excel files from R, and discuss alternatives along the way. Bad (but easy) approaches Import Dataset button In RStudio’s Environment pane there is an ‘Import Dataset’ button. Use this button if you are only ever going to read in the data once and are going to write less than 10 lines of code. It requires the TidyVerse to be installed.

## Increasing probability of success

Problem You run a series of trials. Trials are independent of each other and any other results. The probability of success on a trial starts at 2% and increases linearly / additively by 3% after each failure. The probability of success resets to 2% after a success; but this is irrelevant as you only run trials until you obtain a single success. Should you be interested in multiple successes then merely repeat the entire experiment exactly.

## The power of markdown for teaching, research, and consultation

Introduction Why? Do you ever work through an analysis example in class with code and then never get around to typing it up nicely? Do you ever get students copy-pasting assignments from their classmates? Do you ever type up a piece of analysis by copy-pasting graph after graph or table after table, only to realise there’s a problem with the data and you have to redo everything? Do you ever need to include code from one or more languages and struggle to get the syntax highlighted nicely?