similar to: Optimize for loop / find last record for each person

Displaying 20 results from an estimated 2000 matches similar to: "Optimize for loop / find last record for each person"

2009 Feb 07
2
Time Series Graphics - "cannot plot more than 10 series"
Hi Experts, I would like to present time series data in meaningful way in building some graphics. I've tried: (1) plot(ts(mbaye3)) and (2) plot(ts(mbaye3), start=1990) But I always get this error-message: Fehler [error] in plotts(x = x, y = y, plot.type = plot.type, xy.labels = xy.labels, : cannot plot more than 10 series as "multiple" my data: mbaye3
2009 Feb 25
4
Have a function like the "_n_" in R ? (Automatic count function )
Have the counter function in R ? if we use the software SAS /*** SAS Code **************************/ data tmp(drop= i); retain seed x 0; do i = 1 to 5; call ranuni(seed,x); output; end; run; data new; counter=_n_; ***** this keyword _n_ ****; set tmp; run; /* _n_ (Automatic variables) are created automatically by the DATA step or by DATA step statements. */ /*** Output
2009 Jan 12
3
merge table rows (\multirow)
Hi: I need help merging rows. I am trying to merge the 'Month' column using \multirow. For example for the column 'Week' I want July to be merged into one row(weeks 27,28,29,30) and so on for the following weeks. Below, I am creating a PDF using Sweave, MikTex,R-2.8.1 and windows XP to show an example. \documentclass[11pt]{article} \usepackage{longtable,verbatim} \title{How to
2009 Feb 09
2
Problem in appending a row to *.csv file
Hi all, I am new to R-project I have a problem when when ever I am going to append a row in a *.csv file that is in R-project I created one dataframe and I saved it in "res.csv" and again I got some results in dataframe with same column names and i tried to append in a new row of same "res.csv" file but its appending again with columnnaes like first time when i created
2010 Feb 23
1
installing ROCR/gplots packages blows up memory
When I try to install the ROCR package (which requires gplots) on Ubuntu 9.10 (Xubuntu Karmic Koala) 64-bit on R version 2.9.2 (2009-08-24), it eats up all my RAM (2GB) and swap (4GB) and keeps allocating more memory until Linux's out of memory (OOM) killer kills the perl process. This problem is special to Ubuntu because I can install other packages (such as party) on this Ubuntu system, and
2009 Feb 09
2
Dataframes: conditional calculations per row .
Dear Sirs: I've been working with several variables in a dataframe that serve as part of a calculation that I need to perform in a different way depending on its value. Let me explain: The main dataframe is called llmcc llmcc : 'data.frame': 283 obs. of 11 variables: $ Area : num 308.8 105.6 51.4 51.4 52.9 ... $ mFondo : num 30.1 10 10.2 10.2 40.4 ... $ mFachada :
2006 May 26
3
Breakdowns in has_many abstraction
I discovered an interesting aspect of has_many behavior that I''m struggling to work around. I''m not sure if I''m doing something wrong, or if it''s a legitimate bug, or if it''s an inherent part of Rails that I just have to learn to deal with. It boils down to these two problems: - changes in collection objects (i.e. models that belong_to a container
2006 Mar 13
3
HABTM: two habtm''s between the same two tables
Imagine I want to track people, and the clubs that they belong to. table people with columns person_id, person_name table clubs with columns club_id, club_name And I have the association table: table clubs_people with columns person_id, club_id Now I know how to do this habtm between the two, in order to associate people with clubs that they belong to. However my application also needs a
2006 Oct 02
2
when to use find_by_sql
I have a bunch of queries to compute some counters, like find_by_sql(<<-SQL SELECT p.*, c.nfavourites FROM people p, ( SELECT fp.person_id, COUNT(fp.user_id) as nfavourites FROM favourite_people fp, users u WHERE fp.user_id = u.id AND u.cluster = ''#{in_cluster_of_user.cluster}'' GROUP BY fp.person_id ) as c WHERE
2006 May 16
1
:conditions on has_one realationship
Hi there, I''m currently building a membership application and I want to be able to select, not just all the memberships, but the most current membership from the database on a per user basis. I have linked the tables as shown:- class Membership < ActiveRecord::Base belongs_to :payment belongs_to :person end class Person < ActiveRecord::Base has_many :memberships
2006 Jul 13
2
having a problem with acts_as_state_machine
Hi all: Below is s a dump from script/console in development env. Am I not supposed to be able to find the record later and use the state machine functionality, or have I missed something? Thanks Forrest ---------------------------- >> ts2 = TalkSession.create( :person_id => 2, :pattern_id => 2) => #<TalkSession:0x35811f0 @attributes={"pattern_id"=>2,
2006 Jan 09
3
Design Question
I am sure some of you can give me an insight into this. This is more towards the database design for the scenario below: Say for example, I have a person table and this person can have different address types. One could be Home and the other could be say Office. Should be model this Table people id fname lname Table addresses id person_id addr1 addr2 .... or Table people id fname lname
2008 May 02
1
names of select elements inside a fields_for block not generated as expected
Hey All, I''m trying to play along w/the ''complex forms 1'' railscast (http://railscasts.com/episodes/73) and having trouble. The view is projects/new. I''m trying to add some project_people to the form w/code like so: <% form_for(@project) do |f| %> [project stuff here] <% for pp in @project.project_person %> <% fields_for
2006 Jun 06
1
Please Help with single table inheritance relationships
I''ve been searching the web, wikis, and more, and I haven''t turned up examples of how to have multiple entities in a single-table inheritance related to anything. I have an addresses table, but multiple entities can have Addresses: both Person (which has 2 addresses) and Retailer. I''ve been told that I need to use single-table inheritance, and this was my attempt:
2007 Feb 26
4
update_attributes and validations
I have a Person model. Person has_many lab_urls. The LabUrl model has a title and a url, which are both required. Now, I want to update a LabUrl object and stick some invalid data in there. And I want the person that has that invalid LabUrl to now be invalid, too. That doesn''t seem like too much to ask for. How can I do that? Right now, this is happening: >> me = Person.find(1)
2006 Mar 09
4
sort-weirdness - active record issue?
I''m selecting data into a controller and sorting it. The code (in the controller) looks like this: def index @assignments = [] tasks = Task.find(:all, :conditions => ["person_id = ? and actual_end_date is null", session[:user].id.to_s ]) issues = Issue.find(:all, :conditions => ["person_id = ? and status <>
2010 Nov 02
7
Testing attr_accessible (and/or attr_protected)
I''ve been puzzling over how to test that attr_accessible has been set for the correct columns; but the tests I''ve come up with so far seem to fail to fail when I expect. I came across this old message from this list: http://www.mail-archive.com/rspec-users at rubyforge.org/msg01570.html Which seemed like a plausible example, but my attempt (modeled on the example)
2013 Nov 19
1
Does function read.sas7bdat() have some memory limitations?
Dear R-ers, I was trying to read in a large sas7bdat file (size 148094976 bytes) using 'read.sas7bdat()', but it did not read in the data correctly. E.g., the first 5 rows will come out like this (I'm omitting other columns to keep it readable): PERSON_ID age 1 5.399114e-315 5.329436e-315 2 5.399114e-315 5.328302e-315 3 5.399114e-315 5.332026e-315 4
2006 Aug 02
2
Self-Referential has_many :through
Hello all. I am trying to create a self-referential has_many :through. I used the following site as a guide http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through but it still doesn''t appear to be working. I have two models. Person and Relationship. A person has many contacts (Which is another person) through relationships class Person < ActiveRecord::Base
2007 Mar 19
1
HOWTO: Multiple file upload with file_column
Lots of requests but not many answers on this topic. Here is how you do it: FORM: <table> <% for i in 1..6 %> <tr> <td class=''Label''><label>Title</label></td> <td><input id="<%= "picture_#{i}_title" %>" name="<%= "picture[#{i}][title]" %>" size="30"