Example: data file = gastro

setwd(“/Users/schulzp_1/Dropbox/ret/01AI/”) gastro <- read.table(“gastroR.txt”, header = TRUE, sep = ” “, na.strings =”-9999”, stringsAsFactors = FALSE)

head(gastro) ### Check the First Few Rows

tail(gastro) ### Check the Last Few Rows

str(gastro) ### Check the Structure

summary(gastro) ### View a Summary

dim(gastro) ### Check Dimensions

colnames(gastro) #### List column names

sapply(gastro, class) ### Check data types

sum(is.na(gastro)) ### Check for Missing Values

Descriptives

mean(gastro$intent) ### mean value of the variable intent in datafile

sd(gastro$intent) ### sd of the variable intent

Check for missing data

install.packages(“Amelia”) library(Amelia)

missmap(gastro)

RStatix Package

install.packages(“rstatix”) library(rstatix)

get_summary_stats(gastro) View(get_summary_stats(gastro)) ### gives the full view###

cor_mat(gastro)

Plots

Histograms

hist(gastro$intent)

hist( x = gastro$intent, xlab = “Strength of Intention”, ylab = “Frequency”, main = “Histogram of Intention”, col = “lightblue”, breaks = 10 )

Boxplots

boxplot(gastro\(intent ~ gastro\)seniority)

boxplot( formula = gastro\(intent ~ gastro\)seniority, xlab = “Seniority”, ylab = “Intention”, main = “Intention by Seniority”, col = “red” )

Scatterplots

plot(gastro\(intent, gastro\)belief)

plot( x = gastro\(belief, y = gastro\)intent, pch = 19, col = “darkgreen”, cex = 1.5 )

Utility Functions

par(bg = “light blue”)

plot( x = gastro\(belief, y = gastro\)intent, pch = 19, col = “darkgreen”, cex = 1.5 )

dev.off() # deletes everything in plot window

par(mfrow=c(1,3))

hist(gastro\(intent) hist(gastro\)accept) hist(gastro$belief)

par(mfrow=c(1,1)) # use to “reset” window arrangement