[R] Call R program from C++ code
Hi All: I'm developing an application program using C++. From my C++ code, I would call some R program I have written. I' wondering if R provide some compiler that can compile R program into executable program. I searched R-help, there are a lot of posts talking about writing C++ code in R program, but few about calling R from C++. I might be wrong that R doesn't have complier. What I'm trying to do is to call R program from C++ code. Any help is highly appreciated! Best regards, Feng __ R-help@stat.math.ethz.ch 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.
Re: [R] Call R program from C++ code
Hi Dirk: Thanks a lot. That does not exist to the best of my knowledge. That's sad :( using the system() call -- but it is also the most tedious way as you When using System() to call R program, do I need to call some R script program or my R function directly? A more advanced method would to use Rserve to run a 'headless' R Here you mean Com? I don't know much about this com frame, so In any event, you may also want to consider the RcppTemplate package I'll read this package, hope I can find a simple way that works in my case. Thanks again! Best, Feng -Original Message- From: Dirk Eddelbuettel [mailto:[EMAIL PROTECTED] On Behalf Of Dirk Eddelbuettel Sent: 2007年7月29日 18:17 To: Feng Qiu Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Call R program from C++ code On Sun, Jul 29, 2007 at 04:35:51PM -0400, Feng Qiu wrote: I'm developing an application program using C++. From my C++ code, I would call some R program I have written. I' wondering if R provide some compiler that can compile R program into executable program. I searched That does not exist to the best of my knowledge. I might be wrong that R doesn't have complier. What I'm trying to do is to call R program from C++ code. Any help is highly appreciated! As you probably know, C++ can 'call' other object code that is linked to it. As for 'calling R', the easiest way is to call an R script using the system() call -- but it is also the most tedious way as you to write the inout data to file, and then read the result data back in. But it is a start, and it may be easiest to debug. A more advanced method would to use Rserve to run a 'headless' R service to which your C++ program can connect over the network. But there you need to be already somewhat familiar with the underlying C/C++ representation of R object. Rserve has simple examples. Next, you can actually embed R inside your C++ application, but that is more advanced. In any event, you may also want to consider the RcppTemplate package which has a host of examples about how to get R and C++ to work better together (without forcing you to use C). The 'Extending R' manual from your R installation is a good starting point for most of this. Hope this helps, Dirk -- Three out of two people have difficulties with fractions. __ R-help@stat.math.ethz.ch 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.
[R] how to preserve trained model in LDA?
Hi all: I'm developing an application in which I use standard data to train the model in LDA and use the trained model to predict on test data. I can't train the model every time when I do prediction. So I need to save the trained model onto disk after the first training. Does anybody have idea about this? You help is highly appreciated. Best Regards Feng [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
[R] anyone konw Polyclass package in R?
Hi everyone: Polyclass is a polytomous logistic regression model using linear splines and their tensor products. It provides estimates for conditional class probabilities which can then be used to predict class labels. I know there is Polyclass package in S-plus. So I'm wondering if there is a corresponding package in R? I have been searching for it for quite a while, but still haven't found it. You help is appreciated very much! Best regards Feng [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
Re: [R] how to get the index of entry with max value in an array?
Thank you guys! I got it. Best, Feng - Original Message - From: Benilton Carvalho [EMAIL PROTECTED] To: Feng Qiu [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Thursday, January 18, 2007 12:20 AM Subject: Re: [R] how to get the index of entry with max value in an array? which.max() b On Jan 17, 2007, at 11:20 PM, Feng Qiu wrote: Hi all: A short question: For example, a=[3,4,6,2,3], obviously the 3rd entry of the array has the maxium value, what I want is index of the maxium value: 3. is there a neat expression to get this index? Thank you! Best, Feng __ R-help@stat.math.ethz.ch 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.
[R] how to get the index of entry with max value in an array?
Hi all: A short question: For example, a=[3,4,6,2,3], obviously the 3rd entry of the array has the maxium value, what I want is index of the maxium value: 3. is there a neat expression to get this index? Thank you! Best, Feng [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
[R] How to use RBF nueral network to predict
Hi all: I'm trying to use RBF neural network for predicting. The package I'm using now is neural. The type of network that I have to use is RBF. But I didn't find predict function in this package. Does anyone have such an experience? Any advice is appreciated! Thank you! Best, Feng __ R-help@stat.math.ethz.ch 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.
[R] logistic regression packages
Hi All: I'm testing a set of data classification algorithms in this paper (www.stat.wisc.edu/~loh/treeprogs/quest1.7/mach1317.pdf ) I couldn't find such algorithms in R packages: 1. LOG: polytomous logistic regression (there was one in MASS library: multinom. But after I update MASS library, multinom was lost.) 2. POL: POLYCLASS algorithm. There is a S-Plus package(polyclass library) for this algorithm, so there should be a corresponding package in R, but I haven't found it so far. Any advice is appreciated. Best, Feng __ R-help@stat.math.ethz.ch 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.
Re: [R] logistic regression packages
Hi David: Thanks for you information. 2 further questions: 1. I found out that multinom is not doing politomous logistic regression, do you know which function does this? 2. the polyclass in polspline does polychotomous regression, while I'm looking for polytomous regression. Do you think these two are similar int erms of prediction? Best, Feng - Original Message - From: David Barron [EMAIL PROTECTED] To: r-help r-help@stat.math.ethz.ch Sent: Wednesday, January 10, 2007 12:14 PM Subject: Re: [R] logistic regression packages 1. multinom is is the nnet package 2. There is a polyclass function in package polspline On 10/01/07, Feng Qiu [EMAIL PROTECTED] wrote: Hi All: I'm testing a set of data classification algorithms in this paper (www.stat.wisc.edu/~loh/treeprogs/quest1.7/mach1317.pdf ) I couldn't find such algorithms in R packages: 1. LOG: polytomous logistic regression (there was one in MASS library: multinom. But after I update MASS library, multinom was lost.) 2. POL: POLYCLASS algorithm. There is a S-Plus package(polyclass library) for this algorithm, so there should be a corresponding package in R, but I haven't found it so far. Any advice is appreciated. Best, Feng __ R-help@stat.math.ethz.ch 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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
[R] Is there a function for this?
Hi everybody, I'm trying to do a statistic on the error rate of a prediction algorithm. suppose this is the real category [good, good, bad, bad, good, good, bad, bad] this is the predicted category [good, bad, bad, bad, good, good, good, bad] I'm trying to do a statistic on the error rate for each group(good,bad): what percentage of instances are predicted incorrectly for each group ? Of course I can write a loop to do that, but is there a easy way to do that? Thank you! Best, Feng __ R-help@stat.math.ethz.ch 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.
Re: [R] Any container in R?
Hi Thomas: Thanks for your explanation. You are right that in C++, we try to use the same piece of codes on different type of objects. While in R, most operations are done in a vector way automatically, which reduced the need for containers. Best, Feng - Original Message - From: Thomas Lumley [EMAIL PROTECTED] To: Feng Qiu [EMAIL PROTECTED] Cc: Duncan Murdoch [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Monday, January 01, 2007 3:21 PM Subject: Re: [R] Any container in R? On Mon, 1 Jan 2007, Feng Qiu wrote: Hi Duncan: Thank you very much! I checked out unique(), it does exactly what I want. But I'm still curious about if R provides STL(standard template library). No. Some things the STL does aren't needed in R, others are implemented differently, and others aren't implemented. One particularly important example is iterators, which will often either happen invisibly due to vectorized operations or will be done with the *apply family of functions. Your example could have been done either way. Using duplicated() is the vectorized approach; the apply approach would use tapply(). C++ is not terribly similar to R. A lot of the effort in STL is expended on allowing a piece of code to be used on different types (where appropriate). In R you have to expend effort on stopping a piece of code being used on different types (where inappropriate). -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch 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.
[R] Any container in R?
R has list and array to contain elements. But does R have more powerful container, such as map as in C++ STL? or is there such a package? Thanks and Happy 2007! Best, Feng __ R-help@stat.math.ethz.ch 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.
Re: [R] Any container in R?
Hi Duncan: Thanks for your hints. I'm trying to collect distinct elements in one column in a matrix. If there is a map, I can easily build up such a collection. While if using list, I have to check by myself if this element already exists in the collection every time I examine a new entry in the column. Best, Feng - Original Message - From: Duncan Murdoch [EMAIL PROTECTED] To: Feng Qiu [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Monday, January 01, 2007 10:37 AM Subject: Re: [R] Any container in R? On 1/1/2007 10:17 AM, Feng Qiu wrote: R has list and array to contain elements. But does R have more powerful container, such as map as in C++ STL? or is there such a package? In what way are maps more powerful than lists? You can use names to index lists. The other container in R is the environment; they have fairly strange semantics, though. Duncan Murdoch __ R-help@stat.math.ethz.ch 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.
Re: [R] Any container in R?
Hi Duncan: Thank you very much! I checked out unique(), it does exactly what I want. But I'm still curious about if R provides STL(standard template library). Best, Feng - Original Message - From: Duncan Murdoch [EMAIL PROTECTED] To: Feng Qiu [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Monday, January 01, 2007 12:36 PM Subject: Re: [R] Any container in R? On 1/1/2007 11:22 AM, Feng Qiu wrote: Hi Duncan: Thanks for your hints. I'm trying to collect distinct elements in one column in a matrix. If there is a map, I can easily build up such a collection. While if using list, I have to check by myself if this element already exists in the collection every time I examine a new entry in the column. You might want to use the unique() function, or duplicated(), rather than doing this yourself. Duncan Murdoch Best, Feng - Original Message - From: Duncan Murdoch [EMAIL PROTECTED] To: Feng Qiu [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Monday, January 01, 2007 10:37 AM Subject: Re: [R] Any container in R? On 1/1/2007 10:17 AM, Feng Qiu wrote: R has list and array to contain elements. But does R have more powerful container, such as map as in C++ STL? or is there such a package? In what way are maps more powerful than lists? You can use names to index lists. The other container in R is the environment; they have fairly strange semantics, though. Duncan Murdoch __ R-help@stat.math.ethz.ch 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.
Re: [R] Problems with R
You got to supply the absolute path of your files and the seperating symbol in your csv file. Please read the help file by typing help(read.csv), you will have no problem. - Original Message - From: Obinna Duru [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, January 01, 2007 4:09 AM Subject: [R] Problems with R Hello, Please I have problems with R. I downloaded R from UC Berkeley CRAN mirror, but each time I try to read a data file using the command 'moi.data - read.csv(choose.files())' or 'my.data - choose.files() #' , the program becomes unstable and exits itself. However, I just noticed from my Windows Task manager that the R-program process tree is still active and using up about 30% of the processor activity. Is this a problem with my download? I have tried reinstalling from UC Los Angeles, but still have the same issues. Any help will be appreciated. I need to use the acepack package in R. Thank you Best Regards Obinna Duru Energy Resources Engineering Department, Green Earth Sciences Building, 367 Panama Street, Stanford, CA 94305-2220 cell: (650) 814 6079 fax:(659) 725 2099 email: [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] How to write string dynamicly?
Hi Gabor: Thank you! But it didn't work. Since lda() takes the variable name as the input parameter. So what I was trying to do is make the name dynamically. I used sprintf() to generate a variable name, such as V16. But it seems that the function doesn't recognize the generated name. For example, lda(V16,data=mydata) works, But, lda(sprintf(V%d,k),data=mydata) does not work, where k=16. So I guess the name generated by sprintf is not the parameter wanted. But I have no idea about it. Best, Feng - Original Message - From: Gabor Grothendieck [EMAIL PROTECTED] To: Feng Qiu [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Wednesday, December 27, 2006 1:56 PM Subject: Re: [R] How to write string dynamicly? Try: lda(iris[-5], iris[,5]) On 12/26/06, Feng Qiu [EMAIL PROTECTED] wrote: Hi everyone: I'm trying to compose a string dynamicly for the parameter input of some function. For example: In package MASS, function lda() require to input the name of predictor variable. Let's say the 16th column is the predictor variable. Then we call the function like this: lda(V16~., data=mydata). I don't want to hard-code the call, instead, I would like to use a dynamic expression for this parameter so that I can use my program on different set of data. I guess there,- are some function that can do this, but I didn't find it in Introduction to R so far, could someone please tell me this kind of function? Thank you! Best, Feng __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
[R] How to write string dynamicly?
Hi everyone: I'm trying to compose a string dynamicly for the parameter input of some function. For example: In package MASS, function lda() require to input the name of predictor variable. Let's say the 16th column is the predictor variable. Then we call the function like this: lda(V16~., data=mydata). I don't want to hard-code the call, instead, I would like to use a dynamic expression for this parameter so that I can use my program on different set of data. I guess there are some function that can do this, but I didn't find it in Introduction to R so far, could someone please tell me this kind of function? Thank you! Best, Feng __ R-help@stat.math.ethz.ch 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.
[R] How to debug R program?
Hi everyone: I wrote a R program which has loops. When I run the program, it crashed. I would like to identify in which loop the pragram crashed, how can I debug ? I'm new to R, could somebody please give me a general idea about debugging in R.(I'm a C/C++ programmer and have general knowledge about program debugging.) Thank you! Best, Feng __ R-help@stat.math.ethz.ch 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.
[R] packages about discriminant analysis
Hi guys: I'm testing some statistic discriminant analysis methods in R. But I couldn't find the package for these methods: 1. Discriminant analysis implemented with nearest neighbor method, 2. logistic discriminant analysis 3. POLYCLASS algorithm( there is such a function in S-Plus, namely poly.fit from polyclass library. Is there a corresponding library in R? ) Any kind of help is highly appreciated! Best, Feng __ R-help@stat.math.ethz.ch 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.
[R] Help concerning Lasso::l1ce
Hi, First, when I try the example Prostate with bound 0.44 (as in the manual), I got a different result: l1c.P - l1ce(lpsa ~ ., Prostate, bound=0.44) l1c.P Coefficients: (Intercept) lcavol lweight age lbph svi 1.0435803 0.4740831 0.1953156 0.000 0.000 0.3758199 lcp gleason pgg45 0.000 0.000 0.000 The relative L1 bound was : 0.44 The absolute L1 bound was : 0.8113534 The Lagrangian for the bound is: 17.89198 And the sum of the absolute values of the coefficients are larger than the bound!! Why? Second, the manual says that if I set sweep.out to NULL, the constant term (which is the intercept, right?) will be included in the bound, but when I do so, I get an error Matrix build from transformed variables has a constant column. Why? And how can I constrain the constant term? Finally, could anyone explain to me the difference between relative bound and absolute bound? Which is the actually bound adopted? Im new to R and the lasso2 package, please help me out, thank you very much. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html