search for: quantity

Displaying 20 results from an estimated 1218 matches for "quantity".

2008 Nov 17
5
how to calculate another vector based on the data from a combination of two factors
Hi, I have a data set similar to the following State Gender Quantity TX Male 1 NY Female 2 TX Male 3 NY Female 4 I need to calculate cumulative sum of the quantity by State and Gender. The expected output is State Gender Quantity CumQuantity TX Male 1 1 TX Male 3 4 NY Female 2 2 NY Female 4 6 I highly appreciate if someone can give me some hints on solving that...
2010 Apr 28
3
data frame move columns
...e 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, -25)), .Names = c("DESCRIPTION", "prix", "quantity", "fees"), row.names = c(NA, -6L), class = "data.frame") I want to group together all the rows with quantity=0. This follow...
2011 Jan 26
2
hwo to speed up "aggregate"
I have > df quantity branch client date name 1 10 1 1 2010-01-01 one 2 20 2 1 2010-01-01 one 3 30 3 2 2010-01-01 two 4 15 4 1 2010-01-01 one 5 10 5 2 2010-01-01 two 6 20 6 3 2010-01-01 three 7 100...
2005 Dec 14
9
Passing quantity in a shopping cart
I am using this line on my index.rhtml page to capture the quantity required of a particular item for a basic shopping cart app: <%= text_field ''line_item'', ''quantity'', {:size=>3} %> </td> but my next screen (a cart screen) doesn''t reflect what was entered in that text field when the item is added to t...
2008 Jun 04
2
Mock with an attributes that has state
...rder 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 function should do is increment the quantity of the merged OrderItems. Below @order_item1 and @order_item4 would be merged into one item with a quantity of 2. Here are my OrderItems mocks: @order_item1 = mock_model(OrderItem, :valid? => true, :product_id => 1, :cost => 1, :null_object => true) @order_item2 = mock_model...
2007 Jan 05
4
How To Spec Controllers with Finders
...h renders rjs), I''m faced with the fixture- driven way of spec-ing or mocking. How the heck to you mock this so the code at line (2) and (4) work right? I''m still struggling with mocks but it seems like this can be done. Forgive the naivety of this question. 1. def change_quantity 2. @line_item = LineItem.find_by_id(params[:id]) 3. unless @line_item.nil? 4. @line_item.update_attribute(:quantity, params[:quantity]) 5. @extension_id = "extension#{params[:id]}" 6. end 7. end Thanks
2006 Apr 24
3
Form with multiple rows of content
...provide the user the option to update quantities. Here''s the rhtml code: <%= start_form_tag :action => ''update_cart'' %> <% for @item in @items %> <%= @item.product.title %> <%= text_field "item[]",''quantity'' %> <%= number_to_currency(@item.unit_price) %> $<%= @item.quantity * @item.unit_price %> <%= link_to ''Remove item'', {:action => ''remove_from_cart'', :id => @item.product} %> <% end %> Total...
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 advance for your...
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", &q...
2007 Jan 20
2
find_by_sql with named parameterized sql
I tried to use named parameters in my SQL query , using find_by_sql Order.find_by_sql ([select * from orders where amount > ? and quantity > ?", [ @amount, @quantity ] works;.. but Order.find_by_sql ([select * from orders where amount > :amount and quantity > :quantity ", [ :amount => @amt, :quantity => @qty ] is not working a I wrong or should I use a plain select string ? tfyl kad -- Posted via http:/...
2006 Mar 13
4
undefined method `validates_presence_of'' for #<ProductsContr
Hi, I am trying to use method `validates_presence_of'' for validating my input fields on form . I m using it in my action class as follows:- ======================= validates_presence_of(params[:product][:quantity]) ====================== But when I am running my application i m getting error like:- ========================= undefined method `validates_presence_of'' for #<ProductsContr ========================= What is problem here?? Also I want to validate the field on my form (quantity) for i...
2008 Oct 24
4
Railscast 75, Observe_field and Shopping Cart
Hi all, I have the shopping cart page where a user can add items dynamically through ajax as explained in Railscast episode 75. I am using observe_field to observe the ''quantity'' and ''cost'' fields to update the total field for each item. This does not work however, for records that are added through the Ajax. How can i name the fields and observe them as i have explained? is observing the best way to go? Really appreciate any help. --~--~------...
2006 Jul 24
1
Newbie error: undefined local variable or method
When I add an item to the shopping cart, I get an error: undefined local variable or method `cart_item'' for #<#<Class:0x3715a78>:0x3715a48> Session info says the cart being updated properly. I''m just not able to output two variables: <%= cart_item.quantity %> &times; <%= h(cart_item.title) %> I did some research, and I can grasp that local variables aren''t accessible here, but I''m not sure how to troubleshoot and find where the problem occurs. (I''m coming from php and coldfusion, so maybe my head is warped in...
2009 Feb 18
3
wrong number of arguments (1 for 0)
...ntrollers/customer_controller.rb:36:in `session'' app/controllers/customer_controller.rb:36:in `add_to_cart'' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ My controller is ... def add_to_cart if request.post? product_id = params[:product_id] quantity = params[:quantity] account = get_account() error)---> session[:cart] = SessionCart.new(account) if session(:cart).nil? session[:cart].add_product( product_id) if quantity >= 2 and quantity <= 50 for i in 1..quantity-1 session[:cart].add_product(product_...
2008 Aug 27
1
Updating a list.
...om 1:365 but there are not necessarily that many rows in the list. What I want to do is make every row in the list of lenght 365 and have the values correspond to the sum of the DayOfYear in the list if present and 0 if not. For example the first item in the list looks like: $`100026` DayOfYear Quantity 1 3 1 2 30 1 3 149 1 4 156 1 5 3 1 Notice that there are not entires for each 'DayOfYear'. I would like to replace list list maintaining the same data structure with something like: $`100026` DayOfYear Quantity...
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...
2006 Jan 20
5
Instance variable?
...my view and then pass along that value to my model My view code is this: <td width="40" align="center"><%= text_field ''product'', ''qty_added'', {:size=>3} And I''m trying to pass the qty_added variable to my model. item.quantity = qty_added It doesn''t seem to be working.. I''m sure I''m missing many fundamental things but if somebody could start me down the correct path.. Thx.. -- Posted via http://www.ruby-forum.com/.
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, by=as.list(setdiff(names(x),"Quantity")), sum) Error in FUN(X[[1L]], ...) : arguments must have same length The way I understand it is that 'aggegat...
2013 Aug 26
2
Partial correlation test
Dear all, I'm writing my manuscript to publish after analysis my final data with ANOVA, ANCOVA, MANCOVA. In a section of my result, I did correlation of my data (2 categirical factors with 2 levels: Quantity & Quality; 2 dependent var: Irid.area & Casa.PC1, and 1 co-var: SL). But as some traits (here Irid.area) are significantly influenced by the covariate (standard length, SL), I need to use the partial correlation. I know how to calculate it with JMP, but as I used R to analyse all of my data...
2006 Jan 15
6
Saving one-many associations (elegant solution please)
What is the most elegant way to save new one-many associations? order = Order.new(:name => "My Order") order.line_items << LineItem.new(:product_id => 1, :quantity => 2) order.line_items << LineItem.new(:product_id => 2, :quantity => 5) order.save The above - which is by far the most elegant way of putting it - doesn''t work for me - the line_items don''t get saved. Presumably because the order does not have an id yet, so th...