[R] iterating over a data frame the R way?
donahchoo at me.com
donahchoo at me.com
Thu Dec 31 23:52:26 CET 2009
In this specific case I'm going to do another select, from a different
table with the where clause being based on the start_time and end_time.
select * from table_name where time >= start_time and time <= end_time;
On Dec 31, 2009, at 3:57 PM, John Kane wrote:
> Uh what do you want to do to it/them?
>
> Here are a couple of R-type commands on a data.frame.
>
> mydata <- data.frame(vec1 = seq(19,109, by=10),
> vec2 =seq(30,120, by=10))
>
> mydata[,1]+mydata[,2]
> apply(mydata, 2, mean)
>
>
>
> --- On Thu, 12/31/09, donahchoo at me.com <donahchoo at me.com> wrote:
>
>> From: donahchoo at me.com <donahchoo at me.com>
>> Subject: [R] iterating over a data frame the R way?
>> To: r-help at r-project.org
>> Received: Thursday, December 31, 2009, 2:44 PM
>> Hi,
>>
>> I have a data frame that was create by issuing a select
>> against my sqlite database. I want to get each row
>> from the data frame and use the each of the column
>> values. The data frame looks like this:
>>
>> start_time end_time
>> 09:30:00 10:00:00
>> 10:00:01 10:30:00
>> etc
>>
>> Can a point me to a tutorial/example of doing this? I
>> the other programming languages I'm familiar with I would
>> just loop over the frame and access the elements, but I
>> believe that's not the R way and can't find examples of
>> doing this.
>>
>> Thanks!
>>
>> ______________________________________________
>> R-help at r-project.org
>> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained,
>> reproducible code.
>>
>
>
>
> __________________________________________________________________
> Make your browsing faster, safer, and easier with the new Internet
> Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/
More information about the R-help
mailing list