search for: warpbreaks

Displaying 20 results from an estimated 119 matches for "warpbreaks".

2009 Nov 23
3
FUN argument to return a vector in aggregate function
Hi All, I am currently doing the following to compute summary statistics of aggregated data: a = aggregate(warpbreaks$breaks, warpbreaks[,-1], mean) b = aggregate(warpbreaks$breaks, warpbreaks[,-1], sum) c = aggregate(warpbreaks$breaks, warpbreaks[,-1], length) ans = cbind(a, b[,3], c[,3]) This seems unnecessarily complex to me so I tried > aggregate(warpbreaks$breaks, warpbreaks[,-1], function(z) c(mean(z),...
2020 May 02
1
issues with environment handling in model.frame()
Dear all, model.frame behaves in a way I don't expect when both its formula and subset argument are passed through a function call. This works as expected: model.frame(~wool, warpbreaks, breaks < 15) #> wool #> 14 A #> 23 A #> 29 B #> 50 B fun1 <- function(y) model.frame(~wool, warpbreaks, y) fun1(with(warpbreaks, breaks < 15)) #> wool #> 14 A #> 23 A #> 29 B #> 50 B but this doesn't: fun2 <- function(x,...
2018 Jan 07
2
SpreadLevelPlot for more than one factor
Dear All, I want a transformation which will make the spread of the response at all combinations of 2 factors the same. See for example : boxplot(breaks ~ tension * wool, warpbreaks) The closest I can do is : spreadLevelPlot(breaks ~tension , warpbreaks) spreadLevelPlot(breaks ~ wool , warpbreaks) I want to do : spreadLevelPlot(breaks ~tension * wool, warpbreaks) But I get : > spreadLevelPlot(breaks ~tension * wool , warpbreaks) Error in spreadLevelPlot.formula(break...
2012 Nov 29
2
Deleting certain observations (and their imprint?)
...need to eliminate some observations based on specific identifiers. This isn't a problem in and of itself (using which.. or subset..) but an imprint of the deleted observations seem to remain, even though they have 0 observations. This is causing me problems later on. I'll use the dataset warpbreaks to illustrate, I apologize if this isn't in the best format ##Summary of warpbreaks suggests three tension levels (H, M, L) > summary(warpbreaks) breaks wool tension Min. :10.00 A:27 L:18 1st Qu.:18.25 B:27 M:18 Median :26.00 H:18 Mean :28.15...
2018 Jan 07
2
SpreadLevelPlot for more than one factor
Dear Ashim, Try spreadLevelPlot(breaks ~ interaction(tension, wool), data=warpbreaks) . I hope this helps, John ----------------------------- John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: socialsciences.mcmaster.ca/jfox/ > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ashim > Kapoor &...
2005 Mar 26
1
Function Arguments
Hello, I am trying to wrap some code that I repeatedly use into a function for efficiency. The following is a toy example simply to illustrate the problem. foobar.fun<-function(data,idvar,dv){ id.list<-unique(idvar) result<-numeric(0) for (i in id.list){ tmp1<-subset(data, idvar == i) result[i]<-mean(get("tmp1")[[dv]]) } return(result) } The
2018 Jan 09
0
SpreadLevelPlot for more than one factor
Dear Sir, Many thanks for your reply. I have a query. I have a whole set of distributions which should be made normal / homoscedastic. Take for instance the warpbreaks data set. We have the following boxplots for the warpbreaks dataset: a. boxplot(breaks ~ wool) b. boxplot(breaks ~ tension) c. boxplot(breaks ~ interaction(wool,tension)) d. boxplot(breaks ~ wool @ each level of tension) e. boxplot(breaks ~ tension @ each level of wool) Now should we not be maki...
2009 Jan 14
3
Casting lists to data.frames, analog to SAS
I have a specific question and a general question. Specific Question: I want to do an analysis on a data frame by 2 or more class variables (i.e., use 2 or more columns in a dataframe to do statistical classing). Coming from SAS, I'm used to being able to take a data set and have the output of the analysis in a dataset for further manipulation. I have a data set with vote totals, with one
2018 Jan 14
1
SpreadLevelPlot for more than one factor
...for this list, which is for questions about using R, not general statistical questions. (1) The relevant distribution is within cells of the wool x tension cross-classification because it?s the deviations from the cell means that are supposed to be normally distributed with equal variance. In the warpbreaks data there are only 9 cases per cell. If you examine all of these deviations simultaneously, that?s equivalent to examining the residuals from the two-way ANOVA model fit to the data. (2) Yes, (d) and (e) visualize simple effects, and (a) and (b) visualize main effects, the latter only because the...
2012 Oct 23
1
How Rcmdr or na.exclude blocks TukeyHSD
...d previously turned on R Commander (Rcmdr). John Fox knew that Rcmdr sets na.action to na.exclude, which causes the problem. If you have this problem, you can either exit Rcmdr before calling TukeyHSD or you can set na.action to na.omit. The code below demonstrates the situation. Cheers, Bob data(warpbreaks) head(warpbreaks) # Introduce a missing value: warpbreaks$breaks[1] <- NA head(warpbreaks) # Do a model: fm1 <- aov(breaks ~ tension, data = warpbreaks) TukeyHSD(fm1, "tension", ordered = TRUE) # Setting na.exclude or starting Rcmdr will kill the confidence intervals: options(na....
2018 Jan 07
0
SpreadLevelPlot for more than one factor
...n, Jan 7, 2018 at 10:37 AM, Ashim Kapoor <ashimkapoor at gmail.com> wrote: > Dear All, > > I want a transformation which will make the spread of the response at all > combinations > of 2 factors the same. > > See for example : > > boxplot(breaks ~ tension * wool, warpbreaks) > > The closest I can do is : > > spreadLevelPlot(breaks ~tension , warpbreaks) > spreadLevelPlot(breaks ~ wool , warpbreaks) > > I want to do : > > spreadLevelPlot(breaks ~tension * wool, warpbreaks) > > But I get : > > > spreadLevelPlot(breaks ~tension...
2012 Jul 27
1
Understanding the intercept value in a multiple linear regression with categorical values
Hi! I'm failing to understand the value of the intercept value in a multiple linear regression with categorical values. Taking the "warpbreaks" data set as an example, when I do: > lm(breaks ~ wool, data=warpbreaks) Call: lm(formula = breaks ~ wool, data = warpbreaks) Coefficients: (Intercept) woolB 31.037 -5.778 I'm able to understand that the value of intercept is the mean value of breaks when wool equa...
2007 Aug 14
4
Problem with "by": does not work with ttest (but with lme)
...set(The same happens with Wilcoxon test). However, the by-function works fine with the lme function. Did I just miss something or is it really not working? If not, is there any other possibility to avoid loops? Thanks Daniel Here is the R help example for "by" require(stats) attach(warpbreaks) by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x)) *->works great by(warpbreaks,tension,function(x)t.test(breaks ~ wool,data=warpbreaks,paired = TRUE)) *Same output for each level of tension: tension: L Paired t-test data: breaks by wool t = 1.9956, df = 26, p-value = 0.0565...
2006 Apr 25
1
by() and CrossTable()
...am attempting to produce crosstabulations between two variables for subgroups defined by a third factor variable. I'm using by() and CrossTable() in package gmodels. I get the printing of the tables first and then a printing of each level of the INDICES. For example: library(gmodels) by(warpbreaks, warpbreaks$tension, function(x){CrossTable(x$wool, x$breaks > 30, format="SPSS", fisher=TRUE)}) Is there a way to change this so that the CrossTable() output is labeled by the levels of the INDICES variable? I think this has to do with how CrossTable returns output, because th...
2007 Sep 06
3
Warning message with aggregate function
Dear all, When I use aggregate function as: attach(warpbreaks) aggregate(warpbreaks[, 1], list(wool = wool, tension = tension), sum) The results are right but I get a warning message: "number of items to replace is not a multiple of replacement length." BTW: I use R version 2.4.1 in Ubuntu 7.04. Your kind solutions will be great appreciated. Bes...
2010 May 18
2
how to select rows per subset in a data frame that are max. w.r.t. a column
...mal values per subset using "aggregate", but I can't really figure out how to select the rows in the original data frame that are associated with these maximal values. library(stats) # this returns the list with maximal values for breaks per wool/tension subset maxValues = aggregate(warpbreaks$breaks, list(wool = wool, tension = tension), max) # now i'd like the subset of the rows in warpbreaks that are associated with these maximal values Thank you in advance! Tim. [[alternative HTML version deleted]]
2010 Dec 19
1
Random selection from a subsample
Dear Mailing List I have a data set (data4) consisting of a number of factors and a response variable. I wish to randomly sample from a combination of two of those factors (GIS_station and Distance_code2) and return a new dataframe containing the original data structure (i.e. all the columns) but only containing the randomly selected rows. The number of rows in each combination of GIS_station
2005 May 15
3
adjusted p-values with TukeyHSD?
hi list, i have to ask you again, having tried and searched for several days... i want to do a TukeyHSD after an Anova, and want to get the adjusted p-values after the Tukey Correction. i found the p.adjust function, but it can only correct for "holm", "hochberg", bonferroni", but not "Tukey". Is it not possbile to get adjusted p-values after
2003 Dec 08
0
TukeyHSD changes if I create interaction term
...s that summarize the model are identical. However, if two different parameterizations give rise to two different sets of multiple comparisons, how ought we choose between them? The following snippet illustrates. ======================================================================= data(warpbreaks) warpbreaks$WT <- interaction(warpbreaks$wool, warpbreaks$tension) summary(fm1 <- aov(breaks ~ wool * tension, data = warpbreaks)) summary(fm2 <- aov(breaks ~ wool + tension + WT, data = warpbreaks)) summary(fm1) # Identical summary(fm2) # Identical coefficients(fm1) # Different coef...
2010 Sep 13
2
value returned by by()
Hi, I noticed that by() returns an object of class 'by', regardless of what its argument 'simplify' is. ?by says that it always returns a list if simplify=FALSE, yet by.data.frame shows: ---<--------------------cut here---------------start------------------->--- function (data, INDICES, FUN, ..., simplify = TRUE) { if (!is.list(INDICES)) { IND <-