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.
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
> 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
> 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
> left of the == and compares it successively with each element on the
> of the expression (with recycling):
>> c("no", "yes", "no", "yes") == c("yes", "no")
>  FALSE FALSE FALSE FALSE
>> c("no", "yes", "yes", "no") == c("yes", "no")
>  FALSE FALSE TRUE TRUE
> You probably need to use %in% instead
>> c("no", "yes", "yes", "no") %in% c("yes", "no")
>  TRUE TRUE TRUE TRUE
> -- François
> On Sat, Jun 28, 2014 at 4:24 AM, Bhattacharya,Souvik <[log in to unmask]>
>> 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
>> hence I have introduced "NA" to equate all dataframes to have 1000
>> I keep adding each dataframes to a 3dim "Clean" dataframe using the
>> 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
>> 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
>> change all these columns in the Clean 3 dim dataframe to numeric
>> is there any elegant way to achieve this.
>> My next question is, if I want to subset a smaller cube from this 3
>> 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
>> 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 list strives to be beginner friendly. However, we still ask
>> that you
>> PLEASE do read the posting guide
>> 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
> 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.