similar to: hwo to speed up "aggregate"

Displaying 20 results from an estimated 20000 matches similar to: "hwo to speed up "aggregate""

2011 Jan 11
1
question on aggregate
an example available on the net goes like > df identifier quantity 1 1 10 2 1 20 3 2 30 4 1 15 5 2 10 6 3 20 > aggregate(df$quantity, by=list(df$identifier), sum) Group.1 x 1 1 45 2 2 40 3 3 20 I'd like Group.1 to retain the name "identifier" and would like to
2008 Oct 09
1
Basic aggregate help
>From what I read this should work. So please help my misunderstanding: > x <- data.frame(Name=c("A","A","C"), Category=c("a","a","b"), Quantity=c(1,2,3)) > x Name Category Quantity 1 A a 1 2 A a 2 3 C b 3 > aggregate(x,
2011 Jan 12
2
aggredating date data
I tried a date by date forecast of a time series and it seems to be too wild. How can I aggregate the date into weeks or months as required? Thanks. The input looks like ID datadate("YYYY-MM-DD") value_for_day -- ----- ------- -- ------ -------- and I want to be able to change it to ID dataweek value_for_week or
2010 Dec 02
5
Help summarizing R data frame
I am trying to aggregate data in column 2 to identifiers in col 1 eg.. take this> identifier quantity 1 10 1 20 2 30 1 15 2 10 3 20 and make this> identifier quantity 1 45 2 40 3 20 Thanks in
2010 Jun 01
1
data frame manipulation ddply
Dear group, Here is my data frame: futures <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "LIVE CATTLE Aug/10", "LIVE CATTLE Aug/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11
2010 Feb 16
1
Total and heading of portfoilo table
Dear R helpers, I have two input files as 'quantity.csv' and 'equity_price.csv' as (for example) given below. 'quantity.csv' GOOG     YHOO 1000         100 'equity_price.csv' sr_no   GOOG_price           YHOO_price 1            15.22                 536.40 2            15.07                 532.97 3            15.19                 534.05  4           
2008 Aug 09
1
Reshape set operations?
I have mange to use the library reshape to give me data structures that I want. Specifically: m2008 <- melt(t2008, id.var=c("DayOfYear","Category","SubCategory","Sku"), measure.var=c("Quantity")) m2007 <- melt(t2007, id.var=c("DayOfYear","Category","SubCategory","Sku"),
2008 Jul 26
1
Simple vector question.
I have some data that I read in via read.csv: sales2007 <- read.csv("Total2007.dat", header=TRUE) The data looks like: > sales2007[1:605,] Year DayOfYear Sku Quantity CatId Category SubCategory 1 2007 1 100091 1 10862 HOLIDAY Christmas 2 2007 1 100138 1 11160 PET COSTUMES Famous (Licensed) 3 2007
2010 Dec 25
4
need help with data management
I have a data frame that reads client ID date transcations 323232 11/1/2010 22 323232 11/2/2010 0 323232 11/3/2010 missing 121212 11/10/2010 32 121212 11/11/2010 15 ................................. I want to order the rows by client ID and date and using a black-box forecasting method create the data fcst(client,date of forecast, date for which forecast applies). Assume that I
2012 Jan 01
1
How to pass in a list of variables as an argument to a function?
Hello, I have some code that currently works fine and I am endeavoring to convert the major pieces of it into functions. This involves taking "hard coded" names of variables that are used in various places and figuring out how to abstract them out into functions where the arguments (i.e. a list of variables)?can be passed to the parent function and used within that function for various
2023 May 13
1
aggregate wind direction data with wind speed required
?s 15:51 de 13/05/2023, Stefano Sofia escreveu: > Dear list users, > > I have to aggregate wind direction data (wd) using a function that requires also a second input variable, wind speed (ws). > > This is the function that I need to use: > > > my_fun <- function(wd1, ws1){ > > u_component <- -ws1*sin(2*pi*wd1/360) > v_component <-
2023 May 13
2
aggregate wind direction data with wind speed required
Dear list users, I have to aggregate wind direction data (wd) using a function that requires also a second input variable, wind speed (ws). This is the function that I need to use: my_fun <- function(wd1, ws1){ u_component <- -ws1*sin(2*pi*wd1/360) v_component <- -ws1*cos(2*pi*wd1/360) mean_u <- mean(u_component, na.rm=T) mean_v <- mean(v_component, na.rm=T) mean_wd
2012 Jan 13
4
Averaging within a range of values
Hello all. I have two data frames. Group Start End G1 200 700 G2 500 1000 G3 2000 3000 G4 4000 6000 G5 7000 8000 and Pos C0 C1 200 0.9 0.6 500 0.8 0.8 800 0.9 0.7 1000 0.7 0.6 2000 0.6 0.4 2500 1.2 0.8
2010 Apr 14
6
sum specific rows in a data frame
I have a data frame called "pose": DESCRIPTION QUANITY CLOSING.PRICE 1 WHEAT May/10 1 467.75 2 WHEAT May/10 2 467.75 3 WHEAT May/10 1 467.75 4 WHEAT May/10 1 467.75 5 COTTON NO.2 May/10 1 78.13 6 COTTON NO.2 May/10 3 78.13 7 COTTON NO.2 May/10 1 78.13
2013 Sep 14
2
the problem of buying and selling
I own a lot to the folks on r-help list, especially arun who answered every of my question and was never wrong. I am disinclined to once again ask this question, since it is more arithmatic than technical. But, having worked 2 days on it, I realized my brain is just not juicy enough.... Here is the problem. Trust not for freedom to the Franks--- They have a king who buys and sells. -
2008 Jul 15
4
Iterations
I have a command that reads in some data: x <- read.csv("Sales2007.dat", header=TRUE) Then I try to organize the data: sc <- split(x, list(x$Category, x$SubCategory), drop=TRUE) Then I want to iterate through the data. I was able to get the following to run on the R console: for(i in 1:length(sc)) { sum(sc[[i]]$Quantity) } But notiing is primted on the console. I find
2009 Mar 11
1
Reshape question.
This hopefully is trivial. I am trying to reshape the data using the reshape package. First I read in the data: a2009 <- read.csv("Total2009.dat", header = TRUE) Then I trim it so that it only contains the columns that I have interested in: m2009 <- melt(a2009, id.var=c("DayOfYear","Category","SubCategory","Sku"),
2010 Apr 28
3
data frame move columns
Dear group, Here is my df: avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD", "STANDARD LEAD USD"), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8, 2, -1, 0), fees = c(-8.64, -30.24, -26.4, -25.92, -37.5,
2006 May 25
2
Best way to validate an integer field?
I am trying to validate an integer field called quantity. I don''t know how to chack if it has gone beyond or below the maximum or minimum value allowed by the Firebird RDBMS. I tired adding this code to the validate method in the model: if (quantity > -2147483648) and (quantity < 2147483648) errors.add("quantity", "is out of range (must be between
2008 Jun 04
2
Mock with an attributes that has state
I''m developing a rails application. I have an Order model that has_many OrderItems. I mocked the OrderItem model in my Order specs using mock_model. I thought I should focus my specs on each model and always mock associated models. In my Order model I need a way to merge OrderItems which have the same cost and same product_id. That I can spec. The other thing this merge helper