eg Obese Lean NA NA NA NA 8.11">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Some R Basics EPP 245/298 Statistical Analysis of Laboratory Data.

Similar presentations


Presentation on theme: "1 Some R Basics EPP 245/298 Statistical Analysis of Laboratory Data."— Presentation transcript:

1 1 Some R Basics EPP 245/298 Statistical Analysis of Laboratory Data

2 October 20, 2004EPP 245 Statistical Analysis of Laboratory Data 2 Getting Data into R Many times the most direct method is to edit the data in Excel, Export as a txt file, then import to R using read.delim We will do this two ways for the energy data from Dalgaard Frequently, the data from studies I am involved in arrives in Excel

3 October 20, 2004EPP 245 Statistical Analysis of Laboratory Data 3 > eg <- read.delim("energy1.txt") > eg Obese Lean NA NA NA NA 8.11

4 October 20, 2004EPP 245 Statistical Analysis of Laboratory Data 4 > class(eg) [1] "data.frame" > t.test(eg$Obese,eg$Lean) Welch Two Sample t-test data: eg$Obese and eg$Lean t = , df = , p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of x mean of y > mean(eg$Obese)-mean(eg$Lean) [1] NA > mean(eg$Obese[1:9])-mean(eg$Lean) [1] >

5 October 20, 2004EPP 245 Statistical Analysis of Laboratory Data 5 > class(eg) [1] "data.frame" > t.test(eg$Obese,eg$Lean) Welch Two Sample t-test data: eg$Obese and eg$Lean t = , df = , p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of x mean of y > mean(eg$Obese)-mean(eg$Lean) [1] NA > mean(eg$Obese[1:9])-mean(eg$Lean) [1] >

6 October 20, 2004EPP 245 Statistical Analysis of Laboratory Data 6 > eg2 <- read.delim("energy2.txt") > eg2 expend stature Obese Obese Obese Obese Obese Obese Obese Obese Obese Lean Lean Lean Lean Lean Lean Lean Lean Lean Lean Lean Lean Lean

7 October 20, 2004EPP 245 Statistical Analysis of Laboratory Data 7 > class(eg2) [1] "data.frame" > t.test(eg2$expend ~ eg2$stature) Welch Two Sample t-test data: eg2$expend by eg2$stature t = , df = , p-value = alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean in group Lean mean in group Obese > mean(eg2[eg2[,2]=="Lean",1])-mean(eg2[eg2[,2]=="Obese",1]) [1]

8 October 20, 2004EPP 245 Statistical Analysis of Laboratory Data 8 > mean(eg2[eg2[,2]=="Lean",1])-mean(eg2[eg2[,2]=="Obese",1]) [1] > tapply(eg2[,1],eg2[,2],mean) Lean Obese > tmp <-tapply(eg2[,1],eg2[,2],mean) > tmp Lean Obese > class(tmp) [1] "array" > dim(tmp) [1] 2 > tmp[1]-tmp[2] Lean


Download ppt "1 Some R Basics EPP 245/298 Statistical Analysis of Laboratory Data."

Similar presentations


Ads by Google