Skip to content

Question about expand.grid function in R

9 messages · Peter Dalgaard, Kelly Cool, R. Michael Weylandt +3 more

#
I don't think you can do it within expand.grid() but something like
this might work:

rownames(x) <- apply(x, 1, paste, collapse = "")

Michael
On Tue, May 1, 2012 at 5:05 AM, Kelly Cool <kellycool79 at yahoo.com> wrote:
#
On May 1, 2012, at 15:36 , R. Michael Weylandt wrote:

            
Also

rownames(x) <- do.call(paste, c(x, sep=""))

or, in recent versions,

rownames(x) <- do.call(paste0, x)

  
    
27 days later
#
On Mon, May 28, 2012 at 3:16 PM, Kelly Cool <kellycool79 at yahoo.com> wrote:
I think you're looking for negative indexing (which is, in my opinion,
pretty much the best thing ever)

E.g.,

x <- letters[1:10]

x[1:3] # First three letters

x[-(1:3)] # Without the first three letters

x[-4] # Leave out "d"

etc.

Of course, for this case, you might also want the subset function:

subset(LOG, sample_data_tx %in% c("Noy","PLO"))
No, almost always these sorts of conversions will be taken care of you
automatically

Best,
Michael
#
This is a well-known limitation. You have to group categorical attributes together to work around.

--------------------------------------------------------------------------------------
Weifeng (aaron) liu ?|??retail systems pricing? | ?sr research scientist


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Kelly Cool
Sent: Tuesday, May 29, 2012 7:47 AM
To: r-help at r-project.org
Subject: [R] Question about random Forest function in R



Hello,?

I am trying to run the random Forest function on a data.frame using the following code..

myrf <- randomForest (y=sample_data_metal, x=Train, importance=TRUE, proximity=TRUE)


However, an error occurs saying, "can not handle categorical predictors with more than 32 categories".?

My "x=Train" data.frame is quite large and my "y=sample_data_metal" is one column.?

I'm not sure how to go about fixing this error or if there is even a way to get around this error. Thanks in advance for any help.?
#
Hi Kelly,

The function has a limitation that it cannot handle any column in your "x" that is a categorical variable with more than 32 categories.  One possibility is to see if you can "bin" some of the categories into one to get below 32 categories.

Andy 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Kelly Cool
Sent: Tuesday, May 29, 2012 10:47 AM
To: r-help at r-project.org
Subject: [R] Question about random Forest function in R



Hello,?

I am trying to run the random Forest function on a data.frame using the following code..

myrf <- randomForest (y=sample_data_metal, x=Train, importance=TRUE, proximity=TRUE)


However, an error occurs saying, "can not handle categorical predictors with more than 32 categories".?

My "x=Train" data.frame is quite large and my "y=sample_data_metal" is one column.?

I'm not sure how to go about fixing this error or if there is even a way to get around this error. Thanks in advance for any help.?


Notice:  This e-mail message, together with any attachme...{{dropped:11}}