 Home •Search •Dr. Hain •Clinic website •Information for Dizzy Patients •Music •FLW • Various and Sundry

### Dr. Hain's various/sundry has helpful information about things that Dr. Hain has discovered by trial and error.

This is part of our documentation how one can use the "open source" statistics program "R" to display testing data relevant to medicine.

# Rotatory chair values according to decade.

## Compared to other tasks discussed with R, this is fairly easy.

The code for doing this is below.

```setwd("../rchair")

library(ggplot2)
library(dplyr)
getwd()
rchair = rchair[!duplicated(rchair\$SSN),]	## toss out duplicates.
rchair\$Gain_TC[rchair\$Gain_TC >= 999]<-NA    # recode missing Gain_TCs
#rchair\$Gain_TC[rchair\$Gain_TC>50]<-NA    	# recode crazy Gain_TCs
rchair\$Gain_TC[rchair\$Gain_TC <0]<-NA    	# recode crazy Gain_TCs
rchair\$DOS1 = as.Date(rchair\$DOS, format="%Y-%m-%d")
rchair\$DOB1 = as.Date(rchair\$DOB, format="%Y-%m-%d")
rchair\$Age = as.numeric(format(rchair\$DOS1, "%Y")) - as.numeric(format(rchair\$DOB1, "%Y"))

# simplify the dataframe names.
Gain_TC=rchair\$Gain_TC
rchair2 = na.omit(rchair2)			# Get rid of the NAs.
#str(rchair2)

#plot(rchair\$Age,rchair\$Gain_TC, main="Rchair Gain-TC vs Age")
total <- sprintf("Gain*TC product vs. Decade for %d CDH dizzy patients", nrow(rchair2))
p <- ggplot(rchair2, aes(x=Decade, y=Gain_TC)) +
geom_boxplot( fill="#69b3a2") + theme_linedraw() #c9b3a2 is a nice green

p + stat_summary(fun.y=mean, geom="point", shape=23, size=4)
p+ggtitle(total) + xlab("Decade") + theme(plot.title = element_text(hjust = 0.5))

# collect the statistics.
f1 <- function(x) c(Mean = mean(x),  SD = sd(x), n=length(x))