LISTSERV mailing list manager LISTSERV 16.0

Help for R-USERS-L Archives


R-USERS-L Archives

R-USERS-L Archives


R-USERS-L@LISTS.UFL.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

R-USERS-L Home

R-USERS-L Home

R-USERS-L  2014

R-USERS-L 2014

Subject:

Re: working on 3d dataframe

From:

"Bhattacharya,Souvik" <[log in to unmask]>

Reply-To:

UF R Users List <[log in to unmask]>

Date:

Sat, 28 Jun 2014 13:06:23 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (102 lines)

Thanks François. I was using the 2d dataframe with date as the last 
column. Just wondering to see if there is some elegant way to achieve 
this. But thanks for your suggestion.

Regards
Souvik


On Sat, 28 Jun 2014 09:44:50 -0400, François Michonneau wrote:
> Hi Souvik,
>
>    By definition, objects of class data.frame are 2D objects. If you 
> are
> using more dimensions, you are using objects of class "array". These
> objects don't allow to mix different types that's why there are all
> characters. To me it seems that a list might be more appropriate for 
> your
> case. You may also want to reconsider the structure of your data, and 
> use a
> data.frame with date as an additional column.
>
>   Regarding your second question, "==" goes through each element on 
> the
> left of the == and compares it successively with each element on the 
> right
> of the expression (with recycling):
>
>> c("no", "yes", "no", "yes") == c("yes", "no")
> [1] FALSE FALSE FALSE FALSE
>> c("no", "yes", "yes", "no") == c("yes", "no")
> [1] FALSE FALSE  TRUE  TRUE
>
>   You probably need to use %in% instead
>
>> c("no", "yes", "yes", "no") %in% c("yes", "no")
> [1] TRUE TRUE TRUE TRUE
>
>   cheers,
>   -- François
>
>
> On Sat, Jun 28, 2014 at 4:24 AM, Bhattacharya,Souvik <[log in to unmask]> 
> wrote:
>
>> Hello all,
>>
>> I am working on a 3 dimensional dataframe where the 3rd dimension is
>> date. I used abind function to join different dataframes to give a 3
>> dimensional structure. The dataframes donot have same number of rows 
>> and
>> hence I have introduced "NA" to equate all dataframes to have 1000 
>> rows
>> each.
>> I keep adding each dataframes to a 3dim "Clean" dataframe using the
>> code
>>
>> Clean <- abind(Clean,totalm,along=3)
>>
>> After the 3d dataframe is created, all elements seems to be of
>> character type.
>>
>>   My first question , is there a way to change the numeric columns 
>> to
>> numeric type. For instance, there is a list of vector say vec =
>> c(1:5,9:25, 55:89) which are of numeric type for each date. I want 
>> to
>> change all these columns in the Clean 3 dim dataframe to numeric 
>> type.
>> is there any elegant way to achieve this.
>>
>> My next question is, if I want to subset a smaller cube from this 3 
>> dim
>> dataframe,(say I want to use something like
>> Clean[which(Clean[,"Color" == c("Red","Blue")]),], i.e. I want to
>> extract all those rows from every date where Clean[,"Color", ] is 
>> either
>> red or Blue  ) is there any way to do this in R. Whenever I tried to
>> subset, it gives me a one dimensional array.
>>
>> I shall be glad to receive any suggestions from the community in 
>> this
>> regard.
>>
>> Thanks
>> Souvik
>>
>> This list strives to be beginner friendly.  However, we still ask 
>> that you
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> This list strives to be beginner friendly.  However, we still ask 
> that you
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

This list strives to be beginner friendly.  However, we still ask that you
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008

ATOM RSS1 RSS2



LISTS.UFL.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager