# how to find the mean and sd :(

4 messages
Open this post in threaded view
|

## how to find the mean and sd :(

 I need help on 4b please :( 4.) ‘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 (This is done)b.) For the ‘AM.warpbreaks’ dataset, compute for the mean and the standard deviation of the breaks variable for those observations with breaks value not exceeding 30. data(warpbreaks) warpbreaks <- data.frame(warpbreaks) AM.warpbreaks <- subset(warpbreaks, wool=="A" & tension=="M") > mean(AM.warpbreaks<=30) >sd(AM.warpbreaks<=30)This is what I understood this problem and typed the code as in the last two lines. However, I wasn't able to run the last two lines while the first 3 lines ran successfully. Can anybody tell me what is the error here? Thanks! :)
Open this post in threaded view
|

## Re: how to find the mean and sd :(

 On Fri, 2015-09-11 at 07:48 -0700, massmatics wrote: > AM.warpbreaks<=30 The above command is not returning what you expected, what part of the AM.warpbreaks dataframe is expected to be <= 30? Effectively you are using a two stage process. 1) Create a logical vector identifying rows in the dataframe with a breaks value <= 30 2) use the vector in 1. to extract just the rows you are interested in and use that to calculate the mean of the breaks column. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.