Hi, Sorry that this is such a basic question, but I am having trouble with the following. I would like to remove all rows where the data is all zeros in a data.frame such as the following> xdate a b c 1 2007.09.25 99.89844 100.0586 100.0840 4 2007.09.26 99.89844 100.0586 100.0801 7 2007.09.27 0.00000 0.0000 0.0000 10 2007.09.28 99.89648 100.0391 100.0664 13 2007.10.01 99.88672 100.0254 100.0566 i.e. in this example remove the 3rd row. There could several, or no row with zeros, and in this example there are only 4 columns, but in general there are several hundred (so hopefully no typing of "a", "b", "c" or "x$a", "x$b" etc.) Many thanks in advance for any help. Regards, D
Rees, David wrote:> Hi, > > Sorry that this is such a basic question, but I am having trouble with > the following. > > I would like to remove all rows where the data is all zeros in a > data.frame such as the following > >> x > date a b c > 1 2007.09.25 99.89844 100.0586 100.0840 > 4 2007.09.26 99.89844 100.0586 100.0801 > 7 2007.09.27 0.00000 0.0000 0.0000 > 10 2007.09.28 99.89648 100.0391 100.0664 > 13 2007.10.01 99.88672 100.0254 100.0566Just one example: x[rowSums(x[,-1]^2) > 0, ] Uwe Ligges> i.e. in this example remove the 3rd row. > > There could several, or no row with zeros, and in this example there are > only 4 columns, but in general there are several hundred (so hopefully > no typing of "a", "b", "c" or "x$a", "x$b" etc.) > > Many thanks in advance for any help. > > Regards, > D > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Dear list, I would like to calculate the trimmed mean for some subsets within a data.frame (data). The list has already been very helpful, and I have managed calculating the standard mean for the "Intensity" column based on the "Name" column using> avgs <-aggregate(data$Intensity, by = list(data$Name), mean)but I cannot include the argument trim to mean()> avgs <-aggregate(data$Intensidad, by = list(data$Name), mean(trim=0.1)) Error in mean.default(trim = 0.1) : argument "x" is missing, with no default> avgs <-aggregate(data$Intensity, by = list(data$Name), mean(data$Intensity, trim=0.1)) Error in FUN(X[[1]], ...) : argument "INDEX" is missing, with no default What is the "INDEX" argument I am missing? Thanks in advance, David
Hi r-help-bounces at r-project.org napsal dne 05.10.2007 13:24:06:> > Dear list, > > I would like to calculate the trimmed mean for some subsets within a > data.frame (data). The list has already been very helpful, and I have > managed calculating the standard mean for the "Intensity" column based > on the "Name" column using > > > avgs <-aggregate(data$Intensity, by = list(data$Name), mean)Arguments to function are set like this avgs <-aggregate(data$Intensity, by = list(data$Name), mean, trim = 0.1) Regards Petr> > > but I cannot include the argument trim to mean() > > > avgs <-aggregate(data$Intensidad, by = list(data$Name), mean > (trim=0.1)) > Error in mean.default(trim = 0.1) : argument "x" is missing, with no > default > > avgs <-aggregate(data$Intensity, by = list(data$Name), mean > (data$Intensity, trim=0.1)) > Error in FUN(X[[1]], ...) : argument "INDEX" is missing, with no > default > > What is the "INDEX" argument I am missing? > > Thanks in advance, > > David > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.