[R] Date frame

jim holtman jholtman at gmail.com
Thu Mar 12 02:39:44 CET 2009


It all depends on what you are going to do with the data.  What you
want to do can be accomplished with 'list', but probably not
dataframes.  So what is the problem you are trying to solve?  Here is
an example of how you can create a list with the information you want:

> x <- read.table(textConnection("                 starting_time        Ending_time
+ session_1:     14:36:10            14:40:44
+ session_2:     14:40:47           14:41:47
+ session_3:     14:36:10            14:40:44
+ session_4:     14:40:47           14:41:47
+ session_5:     14:36:10            14:40:44
+ session_6:     14:40:47           14:41:47"), header=TRUE)
> closeAllConnections()
> x.l <- as.list(x)
> x.l$seq[1] <- list(c(4 ,3, 0 ,3 ,4 ,1, 0 ,1 ,4 ,3 ,4 ,3 ,4))
> x.l$seq[2] <- list(c(3,4,1,2))
> x.l$seq[3] <- NULL
> x.l$seq[4] <- list(matrix(0,4,4))
> x.l
$starting_time
[1] 14:36:10 14:40:47 14:36:10 14:40:47 14:36:10 14:40:47
Levels: 14:36:10 14:40:47

$Ending_time
[1] 14:40:44 14:41:47 14:40:44 14:41:47 14:40:44 14:41:47
Levels: 14:40:44 14:41:47

$seq
$seq[[1]]
 [1] 4 3 0 3 4 1 0 1 4 3 4 3 4

$seq[[2]]
[1] 3 4 1 2

$seq[[3]]
NULL

$seq[[4]]
     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0


On Wed, Mar 11, 2009 at 8:49 AM, Tammy Ma <metal_licaling at live.com> wrote:
> I have produced the data frame(1) as:
>                  starting_time        Ending_time
> session_1:     14:36:10            14:40:44
> session_2:     14:40:47           14:41:47
> ........
>
> for each session, I produced  different sequences as:
> seq_1<-c(4 ,3, 0 ,3 ,4 ,1, 0 ,1 ,4 ,3 ,4 ,3 ,4)
> seq_2<-c(3,4,1,2)
> seq_3<-Null
> ....
>
> I want to put those to the 3rd column of data frame (1) corresponding the
> individual session.
> How could I do so?
>
> Originally, I want to create a data frame with each row contains different
> sequence and then put to 3rd column, which seems
> couldn't be done.
>
> thanks.
>
> Tammy
>
>
>> Date: Wed, 11 Mar 2009 07:50:37 -0400
>> Subject: Re: [R] Date frame
>> From: jholtman at gmail.com
>> To: metal_licaling at live.com
>> CC: r-help at r-project.org
>>
>> It is called a "list".
>>
>> On Wed, Mar 11, 2009 at 6:32 AM, Tammy Ma <metal_licaling at live.com> wrote:
>> >
>> > Hi, All,
>> >
>> > How to make a data frame, each row of data frame store the different
>> > length of vector?
>> >
>> > Thanks.
>> > Tammy
>> >
>> > _________________________________________________________________
>> > Show them the way! Add maps and directions to your party invites.
>> > http://www.microsoft.com/windows/windowslive/products/events.aspx
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > 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.
>> >
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>
> ________________________________
> See all the ways you can stay connected to friends and family



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list