similar to: grouping function

Displaying 20 results from an estimated 2000 matches similar to: "grouping function"

2010 Jul 30
2
Summing by index
# build a sample data frame illustrating the problem ids<-c(rep(1234,5),rep(5436,3),rep(7864,4)) years<-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1)) data<-seq(14,25,by=1) data[6]<-NA DF<-data.frame(Id=ids,Year=years,Data=data) DF Id Year Data 1 1234 1990 14 2 1234 1991 15 3 1234 1992 16 4 1234 1993 17 5 1234 1994 18 6 5436 1991 NA 7
2010 Aug 07
1
Data frame reordering to time series
Given a data frame, or it could be a matrix if I choose to. The data consists of an ID, a year, and data for all 12 months. Missing values are a factor AND missing years. Id<-c(rep(67543,4),rep(12345,3),rep(89765,5)) Years<-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1)) Values2<-c(12,NA,34,21,NA,65,23,NA,13,NA,13,14) Values<-c(12,14,34,21,54,65,23,12,13,13,13,14)
2009 Oct 07
1
Formatting outputs:(chronological object)
Hello everyone, I have a data generated in a way similar to the following library(chron);library(zoo) date<- seq(as.Date("1990-01-01"),, as.Date("2000-12-31"), by = 1) obs<- zoo(rnorm(length(date), mean = 10, sd = 2.5), order.by = date) monthly<- function(date) as.Date(as.yearmon(Date)) result<- data.frame ( Date = obs = aggregate(obs, monthly, sum)) Now, I want
2008 Mar 30
2
convert weekly time series data to monthly
I have weekly time series data with year, month, day, and price variables. The input data set for the weekly series takes the following form: Year month day price 1990 8 20 119.1 1990 8 27 124.5 1990 9 3 124.2 1990 9 10 125.2 1990 9 17 126.6 1990 9 24 127.2 1990 10 1 132.1 1990 10 8 133.3 1990 10 15 133.9 1990 10 22 134.5 1990 10 29 133.9 .. ... ... ... ... ... .... .... 2008 3 3 313.7 2008
2006 Nov 23
1
how to loop this?
Hi, I have the next procedure: t1<-data.frame(table(substr(names(subset(lasker[[1]], lasker[[1]] >= 4)), 1, 7))) t1[1:5,] Var1 Freq 1 1988-02 3 2 1988-03 1 3 1988-04 1 4 1988-05 2 5 1988-06 3 How to make a new list?, dataframe? having 189 elements in the 'lasker' list: > str(lasker[[1]]) 'table' int [, 1:1274] 1 1 3 2 1 5 4 1 1 4 ... -
2017 Jun 07
4
Determining which.max() within groups
Using the dataset below, I got close to what I'm after, but not quite all the way there. Any suggestions appreciated: Daily <- read.table(textConnection(" Date wyr Q 1911-04-01 1990 4.530695 1911-04-02 1990 4.700596 1911-04-03 1990 4.898814 1911-04-04 1990 5.097032 1911-04-05 1991 5.295250 1911-04-06 1991 6.569508 1911-04-07 1991 5.861587 1911-04-08 1991 5.153666
2006 Nov 22
3
dataframe manipulation
Hi, Having a dataframe 'l1' (dput output is below): >dim(l1) 1274 2 >l1[1:12,] Var1 Freq 1 1988-01-13 1 2 1988-01-16 1 3 1988-01-20 3 4 1988-01-25 2 5 1988-01-30 1 6 1988-02-01 5 7 1988-02-08 4 8 1988-02-14 1 9 1988-02-16 1 10 1988-02-18 4 11 1988-02-24 2 12 1988-03-04 1 I want to extract the times
2005 May 10
1
Aggregate lag
hello, Does anybody know how to aggregate a lag series ? when I try to use aggregate I get the following message > try<-ts(1:100,start=c(1985,1),freq=12) > aggregate(try,4,mean,na.rm=T) Qtr1 Qtr2 Qtr3 Qtr4 1985 2 5 8 11 1986 14 17 20 23 1987 26 29 32 35 1988 38 41 44 47 1989 50 53 56 59 1990 62 65 68 71 1991 74 77 80 83 1992
2017 Jun 07
0
Determining which.max() within groups
cumsum() seems to be what you need. This can probably be done more elegantly, but ... out <- aggregate(Q ~ wyr, data = Daily, which.max) tbl <- table(Daily$wyr) out$Q <- out$Q + cumsum(c(0,tbl[-length(tbl)])) out ## yields wyr Q 1 1990 4 2 1991 6 3 1992 9 4 1993 15 5 1994 18 I leave the matter of Julian dates to you or others. Cheers, Bert Bert Gunter "The trouble
2012 Aug 02
4
Subseting
Hi everyone I have banking data set in long format with 4 columns.One of these columns is bank name which consist of 49 banks and I want the data for only 40 banks out of these 49 so can anyone help me on how to get this 40 banks data My data looks like Year Name totalliabilties assets 1990 a 90 10 1991 a 89 48 1992 a 87
2010 Mar 10
2
function to create multiple matrices
Hi All, If given a dataframe (long form) with Year, Species, and Location, How would I write a function that would create a unique matrix of Species & Location for each Year? What I've tried doing is the following: data #dataframe dataT<-table(data$Species,data$Location,data$Year) #creates tables of Species vs Location for each Year But I'm encountering issues individually
2007 Dec 19
3
plot cummulative sum from calendar time
I have the following list of observations of calendar time: [1] 03-Nov-1997 09-Oct-1991 27-Aug-1992 01-Jul-1994 19-Jan-1990 12-Nov-1993 [7] 08-Oct-1993 10-Nov-1982 08-Dec-1986 23-Dec-1987 02-Aug-1995 20-Oct-1998 [13] 29-Apr-1991 16-Mar-1994 20-May-1991 28-Dec-1987 14-Jul-1999 27-Nov-1998 [19] 09-Sep-1999 26-Aug-1999 20-Jun-1997 05-May-1995 26-Mar-1998 15-Aug-1994 [25] 24-Jun-1996 02-Oct-1996
2012 Sep 15
4
how to view only readings of a selected data from a column while the other columns remain
Hi Friends I am new here and have a problem Year Market Winner BID 1 1990 ABC Apple 0.1260 2 1990 ABC Apple 0.1395 3 1990 EFG Pear 0.1350 4 1991 EFG Apple 0.1113 5 1991 EFG Orange 0.1094 For each year and separately for the two
2006 Nov 26
1
adding elemens to a list
Hi, I have a list of 20 elements, each of them of variable length and with a structure like this: lasker[[1]][1:10,] Var1 Freq 1 1988-02 3 2 1988-03 1 3 1988-04 1 4 1988-05 2 5 1988-06 3 6 1988-07 1 7 1988-08 1 8 1988-09 1 9 1989-03 1 10 1989-04 1 How do I can insert in this list: 1988-01 0 1988-10 0 1988-11 0 1988-12 0 1989-01 0
2010 Apr 08
1
reshape panel data
I have a data set with observations on 549 cities spanning an 18 year period. However, some of cities did not report in one or more of the 18 years. I would like to implement the procedure suggested by Wooldridge section 17.1.3 in his "Econometric analysis of cross section and panel data" to correct for attrition. For example the table below indicates that the 3rd and the 7th cities in
2005 Nov 17
1
Help with read.csv2
Hello, I am importing the following file ;aa;bb;cc 1988;12;12;12 1989;78;78;12 1990;78;78;12 1991;78;78;12 1992;78;78;12 1993;78;78;12 1994;78;78;12 ------------------------------------------------ data<-read.csv2("test.csv",header=T) ------------------------------------------ it gives X aa bb cc 1 1988 12 12 12 2 1989 78 78 12 3 1990 78 78 12 4 1991 78 78 12 5 1992 78 78 12 6
2008 Jun 18
4
inverse cumsum
I've a matrix like this: 1985 1.38 1.27 1.84 2.10 0.59 3.47 1986 1.05 1.13 1.21 1.54 0.21 2.14 1987 1.33 1.21 1.77 1.44 0.27 2.85 1988 1.86 1.06 2.33 2.14 0.55 1.40 1989 2.10 0.65 2.74 2.43 1.19 1.45 1990 1.55 0.00 1.59 1.94 0.99 2.14 1991 0.92
2009 Jun 04
3
Understanding R Hist() Results...
Think I'm missing something to understand what is going on with hist(...) http://n2.nabble.com/What-is-going-on-with-Histogram-Plots-td3022645.html For my example I count 7 unique years, however, on the histogram there only 6. It looks like the bin to the left of the tic mark on the x-axis represents the number of entries for that year, i.e. Frequency. I guess it looks like the bin for
2009 Sep 11
1
format (?) problems with data imported from postgres
Good day, I read some data from a PostgreSQL database by a following script: library(Rdbi) library(RdbiPgSQL) # conn becomes an object which contains the DB connection: conn <- dbConnect(PgSQL(), host="localhost", dbname="BVS", user="postgres", password = "*******") query_duj_kal <- dbSendQuery(conn, "select zdroj as well, cas as date, fe2,
2009 May 09
4
Generating a "conditional time" variable
Hi everyone, Please forgive me if my question is simple and my code terrible, I'm new to R. I am not looking for a ready-made answer, but I would really appreciate it if someone could share conceptual hints for programming, or point me toward an R function/package that could speed up my processing time. Thanks a lot for your help! ## My dataframe includes the variables 'year',