Reading In Data and Data Wrangling

setwd() is used to set the work directory for the file location.
read.csv() is used to enter the data from a csv file.
Using brackets past your data table allows for removal of irrelevant rows or columns.
For this example, the fifth row is removed since Judge 5 has an in sufficent number of observations for this test.

setwd("/Users/Matis/Documents/Courses/IE5342")    
dat<-read.csv("KW_Data.csv",header=FALSE)   
dat[-5,]

Install “tidyverse” Package

The “tidyverse” package is installed to utilize the tools provided by “tidyr” and “dplyr”.
The tools are taught into R Studio through the library() command.

install.packages("tidyverse")   
library(tidyr)    
library(dplyr)

Pivot the Data Table

pivot_longer() lengthens data, increasing the number of rows by pivoting the columns.
Since the second column is not relevant, it is removed with the brackets past dat.

dat<-pivot_longer(dat,c(V2,V3,V4,V5,V6,V7,V8,V9,V10)    
dat<-dat[,-2]

Concise and Filtered View of Data Table

The data table is represented with names for the columns with the command colnames().
The “NA” data is filtered out from the data table with the filter() command.
head() allows for a concise view of the data table, showing the first five rows.

colnames(dat)<-c("Judge","Proportion")    
dat<-filter(dat,Proportion!="NA")   
head(dat)

Kruskal-Wallace Test

The notation of response~factor (read as “response by factor”) is the standard for testing.
This test will provide a chi-squared value, degrees of freedom (df), and a p-value.
Kruskal-Wallace test should be used for non-parametric analysis.

kruskal.test(Proportion~Judge,data=dat)