similar to: aggregating columns in a data frame in different ways

Displaying 20 results from an estimated 5000 matches similar to: "aggregating columns in a data frame in different ways"

2010 Dec 07
3
understanding output of tapply/by cumsum
Dear R-users, I have a dataset with categories and numbers. I would like to compute and add cumulative numbers to the dataset. I do not understand the structure of by(...) or tapply(...) output enough to handle it. Here a small example -------------- d<-expand.grid(a=1:5,b=1:3,c=1:2) d$n = 10 * d$a + d$b +0.1* d$c Sn<-by(d$n,list(d$a,d$c),cumsum) str(Sn) --------- List of 10 $ : num
2011 Mar 16
1
Aggregating dataset to means/day
Hi, I have a dataset with many observations some days while only one others. I would like to calculate a mean value per day and then do regression analysis on the means. This is what I have: Year Day Time herring.density 2007 47 10.36 2.2 2007 47 11.50 1.1 2007 47 14.24 1.4 2007 66 9.35 2.5 This is what I want:
2006 Oct 25
1
cloud() works but wireframe() is blank
Per the message from Alexander Nervedi, 29 April 2006: > I have to be making a riddiculously silly ommission. > when I run the fillowing i get the cloud plot ok. But I cant figure > out what I am missing out when I call wireframe. > Any help would be appreciated. > x<-runif(100) > y<-rnorm(100) > z<-runif(100) > temp <-data.frame(x,y,z) >
2006 Apr 27
1
plotting multiple graphs in a single plot
Hi, I would like to plot multiple graphs in a single plot frame. Something like this: plot(X, Y1, type='l', col='red') lines(X, Y2, col='green') lines(X, Y3, col='blue') etc. The problem with this approach is, however, that the range of the y-axis will be set according to the minimum and maximum values of Y1 only. I would like to generate a plot that shows all
2010 Jan 04
4
function in aggregate applied to specific columns only
I want to use aggregate with the mean function on specific columns gender <- factor(c("m", "m", "f", "f", "m")) student <- c(0001, 0002, 0003, 0003, 0001) score <- c(50, 60, 70, 65, 60) basicSub <- data.frame(student, gender, score) basicSubMean <- aggregate(basicSub, by=list(basicSub$student), FUN=mean, na.rm=TRUE) This
2007 Nov 07
1
Aggregate with non-scalar function
R-Helpers, I'm sorry to have to ask this -- I've not used R very much in the last 8 or 10 months, and I've gotten rusty. I have the following (ff2 is a subset of a much, much larger dataset): > ff2 hostName user sys idle obsTime 10142 fred 0.4 0.5 98.0 2007-11-01 02:02:18 16886 barney 0.5 0.2 94.6 2007-10-25 19:12:12 8795 fred 0.0 0.1 99.8
2011 Mar 11
5
How to calculate means for multiple variables in samples with different sizes
Hello R-helpers: I have data like this: sample replicate height weight age A 1.00 12.0 0.64 6.00 A 2.00 12.2 0.38 6.00 A 3.00 12.4 0.49 6.00 B 1.00 12.7 0.65 4.00 B 2.00 12.8 0.78 5.00 C 1.00 11.9 0.45 6.00 C 2.00 11.84 0.44 2.00 C 3.00 11.43 0.32 3.00 C 4.00 10.24 0.84 4.00 D
2009 Jul 28
2
aggregating strings
I am currently summarising a data set by collapsing data based on common identifiers in a column. I am using the 'aggregate' function to summarise numeric columns, i.e. "aggregate(dat[,3], list(dat$gene), mean)". I also wish to summarise text columns e.g. by concatenating values in a comma separated list, but the aggregate function can only return scalar values and so something
2009 Jul 19
1
transform(_data,...) using strptime gives an error
I have timstamped data like this: > sd[1:10,] Tstamp Density Mesh50 Mesh70 Mesh100 Mesh150 Mesh200 2 2009/02/27 07:00 30.5 0.7 10.7 21.4 32.8 41.6 3 2009/02/27 08:00 32.2 1.6 12.4 23.3 34.5 43.0 4 2009/02/27 09:00 32.7 4.8 13.0 24.0 35.1 43.5 5 2009/02/27 10:00 26.7 0.3 6.5 17.6 28.1 36.9 6 2009/02/27 11:00
2010 Aug 01
1
aggregating a daily zoo object to a weekly zoo object
Dear R People: I'm trying to convert a daily zoo object to a weekly zoo object: xdate <- seq(as.Date("2002-01-01"),as.Date("2010-07-10"),by="day") library(zoo) length(xdate) xt <- zoo(rnorm(3113),order=xdate) xdat2 <- seq(index(xt)[1],index(xt)[3113],by="week") xt.w <- aggregate(xt,by=xdat2,mean) Error: length(time(x)) ==
2013 Jul 17
2
error message in gev
  Hi r-users,   I would like to use gev and my data (annual rainfall ) is as follows:   > head(dat,20) A B C D E F G H I J 1 45.1 41.5 58.5 50.1 46.0 49.1 37.7 49.1 59.8 54.0 2 50.3 39.8 49.4 56.4 49.4 48.8 42.1 49.8 49.4 58.3 3 41.7 39.3 44.6 39.1 35.7 41.5 40.8 40.8 38.5 45.6 4 50.7 33.9 48.4 28.2 35.5 39.1 61.4 17.0 30.7 38.3 5 39.3 30.6 46.9 23.8 25.8
2010 Aug 18
2
Different way of aggregating
Hi Usually "aggregate" is used to calculate things such as the sum of all data on the first day, the sum next day, and so on. But how can I calculate the mean of the first hour of all days, the mean of the second hour of all days, and so on. ??? That's Most examples: today at 1am + today at 2am + today at 3am +.... -> sum today tomorrow at 1am + tomorrow at
2002 Nov 06
1
Aggregating a List
Hi all, There must be a really obvious R solution to this, but I can't figure out how to aggregate a list. For instance, if I read.table the following from a file: Val1 Val2 A 3 4 A 5 6 B 4 4 I would like to take the mean (or median) across any/all rows of type "A" to end up with the structure: Val1 Val2 A 4 5 B 4 4 in this case. How would I go about doign that w/o doing a
2011 Oct 26
1
Plot complete dataset
Hello, I am a new user of R, so I still have some basic difficulties. I'm trying to create a bar graph completely from reading a file. The idea was on the x axis have the columns of the table Married ,Single,Divorced, widower the legend Ages 18-34 35-45 46-64 65-69 70-74 the dataset dataset Ages Married Single Divorced widower 1 18-34 10.5 35.7 8.5 3.2 2 35-45
2007 Mar 28
2
aggregating data with Zoo
Is there a way of aggregating 'zoo' daily data according to day of week? eg all Thursdays I came across the 'nextfri' function in the documentation but am unsure how to change this so any day of week can be aggregated. I have used POSIX to arrange the data (not as 'zoo' series) according to day of week, but am curious if I've missed if a similar option available
2008 Sep 08
2
How to preserve date format while aggregating
Hi I have a dataframe in which some subjects appear in more than one row. I want to extract the subject-rows which have the minimum date per subject. I tried the following aggregate function. attach(dataframe.xy) aggregate(Date,list(SubjectID),min) Unfortunately, the format of the Date-column changes to numeric, when I'm applying this function. How can I preserve the date format? Thanks
2006 Apr 07
1
Aggregating an its series
I'm using a very long irregular time-series of air temperature and relative humidity of this kind (this is an extract only) its.format("% Y%d%m %X) > base T H 20020601 12.00.00 27.1 47 20020601 15.00.00 29.1 39 20020601 18.00.00 27.4 39 20020601 21.00.00 24.0 40 20020602 0.00.00 22.0 73 20020602 3.00.00 19.2 49 20020602 6.00.00 19.5 74 20020602
2006 Nov 29
3
Aggregating data
[This email is either empty or too large to be displayed at this time]
2007 Apr 13
2
Two basic data manipulation questions (counting and aggregating)
Dear R users, I hav two basic data manipulations questions that I can't resolve. My data is a data frame which look like the following : id type 10002 "7" 10061 "1" 10061 "1" 10061 "4" 10065 "7" 10114 "1" 10114 "1" 10114 "4" 10136 "7" 10136 "2" 10136 "2" First, I
2004 Jun 16
3
Aggregating on Water Year Rather Than Calendar Year
The US water year extends from 01 October yyyy-1 through 30 September yyyy and is referenced by the year starting on the included 01 January yyyy. I'd like to be able to find the annual means for the water year. To do so I've taken the input date-time, which is in the usual format "1991-10-07 10:35:00" changed it by: w$d<-as.POSIXct(w$date.time) Now I can add an