@@ -148,7 +148,7 @@ Don't worry if you can't imagine when that would be useful because you'll see an
148
148
149
149
Now, let's create a subset of the data frame that shows us just the 25th day for Andy and David.
150
150
``` {r}
151
- day_25 <- andy_david[andy_david$Day == 25, ]
151
+ day_25 <- andy_david[which( andy_david$Day == 25) , ]
152
152
day_25
153
153
```
154
154
@@ -206,7 +206,7 @@ median(dat$Weight, na.rm=TRUE)
206
206
207
207
So 190 is the median weight. We can find the median weight of day 30 by taking the median of a subset of the data where Day=30.
208
208
``` {r}
209
- dat_30 <- dat[dat[, "Day"] == 30,]
209
+ dat_30 <- dat[which( dat[, "Day"] == 30) ,]
210
210
dat_30
211
211
median(dat_30$Weight)
212
212
```
@@ -236,7 +236,7 @@ weightmedian <- function(directory, day) {
236
236
for (i in 1:5) { #loops through the files, rbinding them together
237
237
dat <- rbind(dat, read.csv(files_list[i]))
238
238
}
239
- dat_subset <- dat[dat[, "Day"] == day,] #subsets the rows that match the 'day' argument
239
+ dat_subset <- dat[which( dat[, "Day"] == day) ,] #subsets the rows that match the 'day' argument
240
240
median(dat_subset$Weight, na.rm=TRUE) #identifies the median of the subset
241
241
#while stripping out the NAs
242
242
}
0 commit comments