Solved – Subsetting a data set by condition

‘Warpbreaks’ is a built-in dataset in R. Load it using the function data(warpbreaks). It consists of the number of warp breaks per loom, where a loom corresponds to a fixed length of yarn. It has three variables namely, breaks, wool, and tension.

a.) Write a code (Hint: a logical expression) that extracts the observations with wool type A and tension level M. Assign it to the object AM.warpbreaks.

b.) For the AM.warpbreaks data set, compute for the mean and the standard deviation of the breaks variable for those observations with breaks value not exceeding 30.

My code for 4a) (However, it didn't work. Can somebody help me how to solve this problem?)

warpbreak <- data(warpbreaks("breaks", "wool", "tension"))  AM.warpbreaks <- c('','type A','level M')  

Here you go:

data(warpbreaks) warpbreaks <- data.frame(warpbreaks) AM.warpbreaks <- subset(warpbreaks, wool=="A" & tension=="M") 

Similar Posts:

Rate this post

Leave a Comment