[R] How to calculate the generalization error of random forests?

2006-02-09 Thread Martin Lam
Hi, Perhaps this is not the proper place to ask this question but I am out of options, therefore I apologize in advance. I want to know how the (upper bound?) generalization error of the random forest is determined using the out-of-bag estimate. I read in Breiman's paper that s and p determine

Re: [R] How to force a vector to be column or row vector?

2006-02-02 Thread Martin Lam
Hi, Perhaps you should try the transpose function t(). It converts a row into a column and vice versa. HTH, Martin Lam --- Michael [EMAIL PROTECTED] wrote: Hi all, I tended to use rbind, or cbind to force a vector be be deemed as a column or row vector. This is very important if I want

Re: [R] How to save R-grafics in eps format

2006-02-01 Thread Martin Lam
Dear Claudia, This is how I save the plots as *.eps. postscript(file=testplot.eps, paper=special, width=10, height=10, horizontal=FALSE) yvalues = runif(100) plot(yvalues) dev.off() HTH, Martin Lam --- [EMAIL PROTECTED] wrote: Hello! I

Re: [R] Data management problem: convert text string to matrix of 0's and 1's

2006-01-27 Thread Martin Lam
(names %in%chars)] = 1 } mymatrix HTH, Martin Lam --- Dale Steele [EMAIL PROTECTED] wrote: I have a data management problem which exceeds my meager R programming skills and would greatly appreciate suggestions on how to proceed? The data consists of a series of observation periods

Re: [R] Can R handle medium and large size data sets?

2006-01-24 Thread Martin Lam
Dear Gueorgui, Is it true that R generally cannot handle medium sized data sets(a couple of hundreds of thousands observations) and threrefore large date set(couple of millions of observations)? It depends on what you want to do with the data sets. Loading the data sets shouldn't be any

[R] How to fit all points into plot?

2005-12-29 Thread Martin Lam
Hi, I have a problem when I want to add new points (or a new line) to the graph. Some points (or parts of the line) are not shown on the graph because they lie beyond the scale of the axis. Is there a way to overcome this so all points (or the entire line) are shown on the graph? Here's an

[R] How to print output during for loops?

2005-10-29 Thread Martin Lam
Hi, I was wondering, if it is possible to print out the values of variables while you are in a for/while loop? Like this for example: for (i in 1:5) { i } So what I want is this as output in the console: 1 2 3 4 5 Thanks in advance, Martin __

[R] How to speed up R code?

2005-10-18 Thread Martin Lam
Hi, I have written a piece of code, which is a variant of the random forest (rf) package algorithm, entirely in R. I know that some of the code in the rf package is written in c or c++. The problem is that the execution of my code in R takes a lot of time. To give you an example, the building and

Re: [R] how to find indices of particular array elements

2005-10-17 Thread Martin Lam
# create a 4x4 matrix with random values smallmatrix = matrix(runif(16)*10, ncol = 4, nrow = 4) # get the row and column number of the item in the matrix with the highest value which(smallmatrix == max(smallmatrix), arr.ind = 1) HTH, Martin --- Jonathan Williams [EMAIL PROTECTED] wrote: Dear

Re: [R] 'mean' function

2005-09-30 Thread Martin Lam
Type ?mean and hit enter in the console to see the description of the function. # randomly draw 5 numbers between 1 and 10 without replacement randomlist = sample(1:10, 5) # calculate the mean of the list meanoflist = mean(randomlist) # show the result meanoflist HTH, Martin --- Lisa Wang

[R] How to get the rowindices without using which?

2005-09-26 Thread Martin Lam
Hi, I was wondering if it is possible to get the rowindices without using the function which because I don't have a restriction criteria. Here's an example of what I mean: # take 10 randomly selected instances iris[sample(1:nrow(iris), 10),] # output Sepal.Length Sepal.Width Petal.Length

[R] How do I get the row indices?

2005-09-16 Thread Martin Lam
Hi, I was wondering if it's possible to get the row numbers from a filtering. Here's an example: # give me the rows with sepal.length == 6.2 iris[(iris[,1]==6.2),] # output Sepal.Length Sepal.Width Petal.Length Petal.Width Species 69 6.2 2.2 4.5 1.5

[R] How to sort data sets?

2005-09-15 Thread Martin Lam
Hi, I was wondering if someone know how to sort a data set by column. I've tried sort() but without luck. I would think there should be a function for it somewhere. An example with the iris data set would be appreciated. Thanks, Martin __

Re: [R] How to erase objects

2005-09-13 Thread Martin Lam
# to see the objects that are currently in memory objects() # to remove everything rm(list = ls()) HTH, Martin --- Luis Ridao Cruz [EMAIL PROTECTED] wrote: ?rm [EMAIL PROTECTED] 13/09/2005 12:08:55 Hi, I admit that I rather carelessly built lots of large objects and therefore ran

Re: [R] Re-evaluating the tree in the random forest

2005-09-10 Thread Martin Lam
-Original Message- From: Martin Lam [mailto:[EMAIL PROTECTED] Sent: Friday, September 09, 2005 9:04 AM To: Liaw, Andy; r-help@stat.math.ethz.ch Subject: RE: [R] Re-evaluating the tree in the random forest Hi, Let me give a simple example, assume a dataset containing 5 instances

Re: [R] Re-evaluating the tree in the random forest

2005-09-09 Thread Martin Lam
was if there was a way to re-evaluate the instances again into: Root node: question: x1 1? Left terminal node: [0.5, A] Leaf classification: A Right terminal node: [3.2, B] [4.5, B] [1.4, C] [1.6, C] [1.9, C] Leaf classification: C Cheers, Martin --- Liaw, Andy [EMAIL PROTECTED] wrote: From: Martin

Re: [R] data manipulation

2005-09-08 Thread Martin Lam
Hi, This may not be the best solution, but at least it's easy to see what i'm doing, assume that your data set is called data: # remove the 4th column data1 = data[,-4] # remove the 3rd column data2 = data[,-3] # use cbind to add an extra column with only X1 #elements data1 = cbind(data1,

[R] Re-evaluating the tree in the random forest

2005-09-08 Thread Martin Lam
Dear mailinglist members, I was wondering if there was a way to re-evaluate the instances of a tree (in the forest) again after I have manually changed a splitpoint (or split variable) of a decision node. Here's an illustration: library(randomForest) forest.rf - randomForest(formula = Species ~

[R] Truncate levels to use randomForest

2005-08-26 Thread Martin Lam
Hi, I will explain my problem with this example: library(randomForest) # load the iris plant data set dataset - iris numberarray - array(1:nrow(dataset), nrow(dataset), 1) # include only instances with Species = setosa or virginica indices - t(numberarray[(dataset$Species == setosa |

[R] problem with certain data sets when using randomForest

2005-08-26 Thread Martin Lam
Hi, Since I've had no replies on my previous post about my problem I am posting it again in the hope someone notice it. The problem is that the randomForest function doesn't take datasets which has instances only containing a subset of all the classes. So the dataset with instances that either

Re: [R] problem with certain data sets when using randomForest

2005-08-26 Thread Martin Lam
Thank you for this and earlier help Mr. Ripley. Martin --- Prof Brian Ripley [EMAIL PROTECTED] wrote: Look at ?[.factor: finaldataset$Species - finaldataset$Species[,drop=TRUE] solves this. On Fri, 26 Aug 2005, Martin Lam wrote: Hi, Since I've had no replies on my

Re: [R] matrix indexing

2005-08-18 Thread Martin Lam
x - array(1:20, dim = c(4, 5)) ind - array(c(1:3, 3:1), dim = c(3, 2)) # instead of using ind (pairs of coordinates) for getting the items in the matrix, you can convert it to a list of single coordinates to point to the item in the matrix: # t = transpose # nrow = get the number of rows indices

Re: [R] R: characters

2005-08-17 Thread Martin Lam
Hmm, it seems that the only difference is the use of as.data.frame(a) instead of a. Hence, the same result can be done with: a - rbind(c(T, T, F), c(F, F, T)) a[a==F]= as.data.frame(a) A possible drawback is that the mode changes from logical to character when using a[a==F]= Instead you could

[R] Copying rows from a matrix using a vector of indices

2005-08-17 Thread Martin Lam
Hi, I am trying to use a vector of indices to select some rows from a matrix. But before I can do that I somehow need to convert 'combinations' into a list, since 'mode(combinations)' says it's 'numerical'. Any idea how I can do that? library(combinat) combinations - t(combn(8,2)) indices -

Re: [R] newbie- how to add a row to a matrix

2005-08-17 Thread Martin Lam
# row bind a - matrix(1:5) a a - rbind(a, 6) a # column bind b - matrix(1:5) b b - cbind(b, 6:12) b b - cbind(b, 13) b Hope this helps, Martin --- Simone Gabbriellini [EMAIL PROTECTED] wrote: dear list, if I have a matrix s-matrix(1:5, ncol=5) how can I add another row with other

[R] How to add decision trees into a list?

2005-08-14 Thread Martin Lam
Hi, I am somewhat new to R so this question may be foolish, but is it possible to add decision trees into a list, array or vector in R? I am trying to build a collection (ensemble) of decision trees. Every time a new instance arrive I need to get the prediction of each decision tree. I have