1 Data of Focus Group (question 1)

This is a focus group of people with their listed age, BMI, and smoking habits.

Add a new R code chunk by clicking the Insert Chunk button on the toolbar

dat <- data.frame(
       Name = c("Frank", "Bob", "Sally", "Susan", "Joan"),
       Age = as.numeric(c(34, 28, 19, 28, 30)),
       BMI = as.numeric(c(24.2, 18.3, 15.4, 22.7, 29.2)),
       stringsAsFactors = FALSE)
str(dat)
## 'data.frame':    5 obs. of  3 variables:
##  $ Name: chr  "Frank" "Bob" "Sally" "Susan" ...
##  $ Age : num  34 28 19 28 30
##  $ BMI : num  24.2 18.3 15.4 22.7 29.2
dat$Log.Age <- log(dat$Age)
dat$BMI.Sqrt <- sqrt(dat$BMI)
dat$Smoking <- factor(c("Yes", "No", "No", "Yes", "Yes"))
saveRDS(dat,"BMI.rds")
str(dat)
## 'data.frame':    5 obs. of  6 variables:
##  $ Name    : chr  "Frank" "Bob" "Sally" "Susan" ...
##  $ Age     : num  34 28 19 28 30
##  $ BMI     : num  24.2 18.3 15.4 22.7 29.2
##  $ Log.Age : num  3.53 3.33 2.94 3.33 3.4
##  $ BMI.Sqrt: num  4.92 4.28 3.92 4.76 5.4
##  $ Smoking : Factor w/ 2 levels "No","Yes": 2 1 1 2 2

2 Sampled Parts Diameter (question 2)

dat2 <- read.csv('https://raw.githubusercontent.com/tmatis12/datafiles/main/diameter.csv')
dat2$Log.Diameter <- log(dat2$Diameter)
write.csv(dat2, "diameter_log.csv")

3 Complete R Code

It is a good idea to include this at the end of every RMarkdown document

# Question 1
dat <- data.frame(
       Name = c("Frank", "Bob", "Sally", "Susan", "Joan"),
       Age = as.numeric(c(34, 28, 19, 28, 30)),
       BMI = as.numeric(c(24.2, 18.3, 15.4, 22.7, 29.2)),
       stringsAsFactors = FALSE)
str(dat)
dat$Log.Age <- log(dat$Age)
dat$BMI.Sqrt <- sqrt(dat$BMI)
dat$Smoking <- factor(c("Yes", "No", "No", "Yes", "Yes"))
saveRDS(dat,"BMI.rds")
str(dat)
# Question 2
dat2 <- read.csv('https://raw.githubusercontent.com/tmatis12/datafiles/main/diameter.csv')
dat2$Log.Diameter <- log(dat2$Diameter)
write.csv(dat2, "diameter_log.csv")