Re: [R] help with "\" in strings

2011-04-23 Thread Joshua Wiley
Hi Rob, On Sat, Apr 23, 2011 at 7:19 PM, viostorm wrote: > > I would like to create a "\%" that can be written to a file as I am writing > a procedure to output to latex. > > I can't create a "\%" and it is driving me crazy. Try the fixed = TRUE argument to gsub. This works for me: x = "This i

[R] help with "\" in strings

2011-04-23 Thread viostorm
I would like to create a "\%" that can be written to a file as I am writing a procedure to output to latex. I can't create a "\%" and it is driving me crazy. -- x = "This is a test % string" gsub ("%", "\\%", x) fileConn<-file("c:/biostats/test.txt") writeLi

Re: [R] replace certain elements in data frame

2011-04-23 Thread sneaffer
Hey, Try the following code: a=c(1,2,3,4,5) b=c(10,20,30,40,50) c=c(100,200,300,400,500) d=c(1000,8210,9000,8310, 7000) e=c(,,9190,,) to.replace=c(8210,8310,9190) df = data.frame(a,b,c,d,e) xdf <- apply(df, 2, function(x) x %in% to.replace) df[xdf] <- "others" -- View this mess

[R] Multi-dimensional non-linear fitting - advice on best method?

2011-04-23 Thread Julian Gilbey
Hello! I have a set of data of the form (x, y1, y2) where x is the independent variable and (y1, y2) is the response pair. The model is some messy non-linear function: (y1, y2) = f(x; param1, param2, ..., paramk) + (y1error, y2error) where the parameters param1, ..., paramk are to be estimate

[R] How to erase (replace) certain elements in the data.frame?

2011-04-23 Thread sneaffer
Hello R-world, Please, help me to get round my little mess I have a data.frame in which I'd rather like some values to be NA for the future imputation process. I've come up with the following piece of code: random.del <- function (x, n.keeprows, del.percent){ n.items <- ncol(x) k <- n.items*(

[R] how to assemble data frame of unknown number of columns in loop

2011-04-23 Thread Nevil Amos
How do I assemble ad data fame, consisting of columns form other data frames identified in a loop? cbind is not working as the initial data fame has 0 columns and rows. > ModList<-dir("./MODEL_DISTS/") > ModList<-ModList[grep(pattern="3COLUMNS",ModList)] > ALL_MODELS<-data.frame() > for (i in

Re: [R] Assigning variables using a loop

2011-04-23 Thread Nick Mosely
Thank you for your help. That works for me. On Sat, Apr 23, 2011 at 1:53 PM, Joshua Wiley wrote: > Hi Nick, > > It is typically not a good idea to write functions that automatically > assign variables to the global environment (makes it easy to overwrite > something valuable without knowing you a

Re: [R] Arguments to order()

2011-04-23 Thread David Neu
On Sat, Apr 23, 2011 at 7:06 PM, Duncan Murdoch wrote: > On 11-04-23 2:00 PM, David Neu wrote: >> >> Hi, >> >> The rows of a data frame can be sorted lexicographically as shown in >> this example, >> >> my.df<- data.frame(x=c(1,1,1,2,2), y=c(1,2,3,2,1)) >> my.df[order(my.df$x,my.df$y, decreasing=T

Re: [R] random typing over text

2011-04-23 Thread Duncan Murdoch
On 11-04-23 6:13 PM, derek wrote: Thank you very much. It was the Insert key. It was very annoying. Actually is this owerwrite function of any use? It's excellent when you want to overwrite text. Duncan Murdoch __ R-help@r-project.org mailing list h

Re: [R] Pass String from R to C

2011-04-23 Thread Duncan Murdoch
On 11-04-23 7:04 PM, Jaimin Dave wrote: Hi, I am using a function which accepts the string from R and prints it. But when I am calling .C("main","hello"); it is printing any random thing. My C function is void main(char *str) See Writing R Extensions. The declaration should be char **str. Dun

Re: [R] Arguments to order()

2011-04-23 Thread Duncan Murdoch
On 11-04-23 2:00 PM, David Neu wrote: Hi, The rows of a data frame can be sorted lexicographically as shown in this example, my.df<- data.frame(x=c(1,1,1,2,2), y=c(1,2,3,2,1)) my.df[order(my.df$x,my.df$y, decreasing=TRUE), ] however, I'm wondering if it's possible to pass a variable in as the

[R] Pass String from R to C

2011-04-23 Thread Jaimin Dave
Hi, I am using a function which accepts the string from R and prints it. But when I am calling .C("main","hello"); it is printing any random thing. My C function is void main(char *str) { Rprintf("%s",str); } Can you help how to achieve this using .C interface? Thanks Jaimin [[alternativ

Re: [R] random typing over text

2011-04-23 Thread derek
Thank you very much. It was the Insert key. It was very annoying. Actually is this owerwrite function of any use? -- View this message in context: http://r.789695.n4.nabble.com/random-typing-over-text-tp3470428p3470749.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] random typing over text

2011-04-23 Thread Ted Harding
One possibility: If you using a laptop with a touchpad, and a text editor in which the point of insertion can be moved by clicking at a position in the text with the mouse, then it is possible that as you type your wrist or the base of your thumb is brushing the touchpad, and causing this to happen

Re: [R] replace certain elements in data frame

2011-04-23 Thread Joshua Wiley
Hi Yosub, if "dat" is your data frame, try something like (untested): dat$code[!dat$code %in% c("8210", "8310", "9190")] <- "others" the general idea being create a logical vector of codes that match the three you want, use "!" to negate this (so you are getting all codes NOT in the ones you wan

Re: [R] random typing over text

2011-04-23 Thread Joshua Wiley
Hi Derek, You have not provided us with any of the relevant (or requested in the posting guide) information which makes it virtually impossible to give you any sort of useful answer (e.g., what is your operating system? what version of R are you using? what are you using to write your script?).

Re: [R] Using Java methods in R

2011-04-23 Thread hill0093
Hi Shekhar, Thank you. Right path. Sounds good. Please help me when you discover Java interface. Firstly, I don't know what the R symbol table is or how to do the checking you suggest. I am really naive about R. I want to be able to get my data in there so I can learn to use it for my purposes.

Re: [R] Assigning variables using a loop

2011-04-23 Thread Joshua Wiley
Hi Nick, It is typically not a good idea to write functions that automatically assign variables to the global environment (makes it easy to overwrite something valuable without knowing you are overwriting it), but if that is really the best choice for your situation, I would do something like (ins

[R] Loop and Solver with Black/Scholes-Formula

2011-04-23 Thread bstudent
Hello, for my diploma thesis I need to program a solver for Merton´s respectively Black´s and Scholes´ Option pricing formula, which should be achieved for several dates. What I want to do is to estimate the value of a firm´s assets "vA" (x[2] denotes vA) and the option-implied volatility of firm

[R] replace certain elements in data frame

2011-04-23 Thread Yosub Jung
Hello, I have a data frame with 2 columns: year and code. In code column, I want to replace elements that are not "8210", "8310", or "9190" with "others". -- Sincerely, Yosub Jung. [[alternative HTML version deleted]] __ R-help@r-project.org

[R] random typing over text

2011-04-23 Thread derek
Dear R, When I'm writing script I probably hit accidently some hot key and then the text in script is being overwritten by subsequent typing. Please what is the hot key or how can I disable it? -- View this message in context: http://r.789695.n4.nabble.com/random-typing-over-text-tp3470428p347

Re: [R] Loop and Solver with Black/Scholes-Formula

2011-04-23 Thread bstudent
Naturally I mean that "x[1] denotes vA" and "x[2] denotes sigA" !!! Sorry for this mistake!!! Thank you and kind regards!!! bstudent. -- View this message in context: http://r.789695.n4.nabble.com/Loop-and-Solver-with-Black-Scholes-Formula-tp3470488p3470494.html Sent from the R help mailing lis

[R] nnet Multinom output of ordered predictors

2011-04-23 Thread DCharbonneau
Hello, I apologize if this seems like an obvious question, but I have been looking everywhere and have yet to find an answer. I am doing a multinomial regression with multinom() in the nnet package. I have a 3 level ordered response (ordered()) variable and 4 predictors, 3 of which are numerical a

Re: [R] Insert regression coefficients in a graphic.

2011-04-23 Thread csrabak
Em 22/4/2011 21:48, David Winsemius escreveu: On Apr 22, 2011, at 2:16 PM, JJCV wrote: Hello. I did a graphic with the next code: T=c(10,15,20,25,30) p=c(1003,1005,1010,1011,1014) plot(T, p, xlab=" ",, ylab=" ", pch=1, cex=2, lwd=2, xlim=c(5,30), ylim=c(1000,1015)) abline(lm(p ~ T), lwd=2) l

[R] Assigning variables using a loop

2011-04-23 Thread Nick Mosely
Hello R-world, I have multiple variables that have been generated within a function. I would like to assign them each to the Global Environment. I've tried the following: x = 1 y = 2 z = 3 for (i in c(x,y,z)) { assign("i",i,pos=.GlobalEnv) } i [1] 3 Obviously, the problem is that the code is a

Re: [R] Using Java methods in R

2011-04-23 Thread Shekhar
Hi Hill, I just finished interfacing the C++ with R, i.e. c++ functions from R and vice versa. Next thing in pipe line is Java and python. I just wanted to share some of the things which i think might be useful for you. Reason being whether its a C++, java or any other compiled language the interfa

[R] Questions about lrm, validate, pentrace (Re: BMA, logistic regression, odds ratio, model reduction etc)

2011-04-23 Thread khosoda
According to the advice, I tried rms package. Just to make sure, I have data of 104 patients (x6.df), which consists of 5 explanatory variables and one binary outcome (poor/good) (previous model 2 strategy). The outcome consists of 25 poor results and 79 good results. Therefore, My events per v

Re: [R] Using Java methods in R

2011-04-23 Thread lcn
Well, the call to Java methods should be really simple in rJava. What you had tried is actually correct, initialize jvm, create an object, then call method. For the error you met, maybe you should check .jaddClassPath. At 2011-04-23 20:58:22£¬hill0093 wrote: >That's more than I can understand

Re: [R] Using Java methods in R

2011-04-23 Thread Mike Marchywka
> From: marchy...@hotmail.com > To: hill0...@umn.edu; r-help@r-project.org > Date: Sat, 23 Apr 2011 15:12:30 -0400 > Subject: Re: [R] Using Java methods in R > > > > > > > > > > > > > > > > > > > Date: Sa

Re: [R] Loop and Solver with Black/Scholes-Formula

2011-04-23 Thread Berend Hasselman
bstudent wrote: > > Hello, > > for my diploma thesis I need to program a solver for Merton´s respectively > Black´s and Scholes´ Option pricing formula, which should be achieved for > several dates. > > What I want to do is to estimate the value of a firm´s assets "vA" (x[2] > denotes vA) and t

Re: [R] Using Java methods in R

2011-04-23 Thread Mike Marchywka
> Date: Sat, 23 Apr 2011 05:32:59 -0700 > From: hill0...@umn.edu > To: r-help@r-project.org > Subject: Re: [R] Using Java methods in R > > No answer to my post, > so let's try a simpler question. Am I doing this correctly? > I have the RGui wi

Re: [R] R_qsort decreasing =T

2011-04-23 Thread David Winsemius
On Apr 23, 2011, at 2:10 PM, kv wrote: Hello, i'm using & . What is the c equivalent to sort(x,deceasing=T) i.e. to get sort(x) i type R_qsort(x, 1, n), where do i set the decreasing=T flag ? More generally, is there a place where the functions in the R sources are documented ? methods(

Re: [R] Removing row with smallest value, for a given factor

2011-04-23 Thread David Winsemius
On Apr 23, 2011, at 1:30 PM, Peter Ehlers wrote: On 2011-04-23 07:02, David Winsemius wrote: On Apr 23, 2011, at 9:05 AM, - - wrote: I have a table. First column is a date, second column is an index and other columns contains some other values. I want to remove, for each date, the row with

[R] R_qsort decreasing =T

2011-04-23 Thread kv
Hello, i'm using & . What is the c equivalent to sort(x,deceasing=T) i.e. to get sort(x) i type R_qsort(x, 1, n), where do i set the decreasing=T flag ? More generally, is there a place where the functions in the R sources are documented ? Best, -- View this message in context: http://

[R] Arguments to order()

2011-04-23 Thread David Neu
Hi, The rows of a data frame can be sorted lexicographically as shown in this example, my.df <- data.frame(x=c(1,1,1,2,2), y=c(1,2,3,2,1)) my.df[order(my.df$x,my.df$y, decreasing=TRUE), ] however, I'm wondering if it's possible to pass a variable in as the first argument to order() so that the a

Re: [R] Removing row with smallest value, for a given factor

2011-04-23 Thread Peter Ehlers
On 2011-04-23 07:02, David Winsemius wrote: On Apr 23, 2011, at 9:05 AM, - - wrote: I have a table. First column is a date, second column is an index and other columns contains some other values. I want to remove, for each date, the row with the smallest index (it is not necessarily 1). ex: i

Re: [R] Using Java methods in R

2011-04-23 Thread hill0093
Since it cannot find a java class that is on my disk, is there a place I have to put it into first? -- View this message in context: http://r.789695.n4.nabble.com/Using-Java-methods-in-R-tp3469299p3470350.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Vertical bwplot and stripplot

2011-04-23 Thread Peter Ehlers
On 2011-04-23 08:03, David Neu wrote: On Sat, Apr 23, 2011 at 10:37 AM, Peter Ehlers wrote: On 2011-04-23 07:13, David Neu wrote: On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius wrote: On Apr 23, 2011, at 9:26 AM, David Neu wrote: Hi, I'd like to change the default orientation of bwpl

Re: [R] Vertical bwplot and stripplot

2011-04-23 Thread David Neu
On Sat, Apr 23, 2011 at 10:37 AM, Peter Ehlers wrote: > On 2011-04-23 07:13, David Neu wrote: >> >> On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius >>  wrote: >>> >>> On Apr 23, 2011, at 9:26 AM, David Neu wrote: >>> Hi, I'd like to change the default orientation of bwplot() and st

Re: [R] Vertical bwplot and stripplot

2011-04-23 Thread Peter Ehlers
On 2011-04-23 07:13, David Neu wrote: On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius wrote: On Apr 23, 2011, at 9:26 AM, David Neu wrote: Hi, I'd like to change the default orientation of bwplot() and stripplot() so the plots are displayed vertically. Passing horizontal=FALSE into stripp

Re: [R] Vertical bwplot and stripplot

2011-04-23 Thread David Neu
On Sat, Apr 23, 2011 at 10:23 AM, David Winsemius wrote: > > On Apr 23, 2011, at 10:13 AM, David Neu wrote: > >> On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius >> wrote: >>> >>> On Apr 23, 2011, at 9:26 AM, David Neu wrote: >>> Hi, I'd like to change the default orientation of bw

Re: [R] Vertical bwplot and stripplot

2011-04-23 Thread David Winsemius
On Apr 23, 2011, at 10:13 AM, David Neu wrote: On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius > wrote: On Apr 23, 2011, at 9:26 AM, David Neu wrote: Hi, I'd like to change the default orientation of bwplot() and stripplot() so the plots are displayed vertically. Passing horizontal=FALS

Re: [R] Vertical bwplot and stripplot

2011-04-23 Thread David Neu
On Sat, Apr 23, 2011 at 9:47 AM, David Winsemius wrote: > > On Apr 23, 2011, at 9:26 AM, David Neu wrote: > >> Hi, >> >> I'd like to change the default orientation of bwplot() and stripplot() >> so the plots are displayed vertically.  Passing horizontal=FALSE into >> stripplot in the simple code b

Re: [R] Removing row with smallest value, for a given factor

2011-04-23 Thread David Winsemius
On Apr 23, 2011, at 9:05 AM, - - wrote: I have a table. First column is a date, second column is an index and other columns contains some other values. I want to remove, for each date, the row with the smallest index (it is not necessarily 1). ex: in the following table, I want to remove

Re: [R] Vertical bwplot and stripplot

2011-04-23 Thread David Winsemius
On Apr 23, 2011, at 9:26 AM, David Neu wrote: Hi, I'd like to change the default orientation of bwplot() and stripplot() so the plots are displayed vertically. Passing horizontal=FALSE into stripplot in the simple code below doesn't seem to be the answer. library(lattice); x <- rnorm(100); y

[R] Removing row with smallest value, for a given factor

2011-04-23 Thread - -
I have a table. First column is a date, second column is an index and other columns contains some other values. I want to remove, for each date, the row with the smallest index (it is not necessarily 1). ex: in the following table, I want to remove row 1 (2013-05-12 with index 2) and row 8 (201

Re: [R] Could I use R function lm or nlm in C code?

2011-04-23 Thread Dirk Eddelbuettel
On 23 April 2011 at 18:25, Shuguang Sun wrote: | I'm doing some simulation work and it takes me a lot of time to do it | in R. So I try to implement it in C code, but I want to use some R | functions directly for my lazy and the robustness of code. For | example, I will use lm and nlm in my progra

Re: [R] simple loop questions

2011-04-23 Thread David Winsemius
On Apr 23, 2011, at 6:31 AM, wrote: Hi all, I am trying to write a loop to return the matched index for a column of values. Here is an simple example of this, A B 0 5 1 2 2 2 3 4 4 1 5 4 6 2 In this case, A is an index column for B. Now I have this new column C with jus

[R] Vertical bwplot and stripplot

2011-04-23 Thread David Neu
Hi, I'd like to change the default orientation of bwplot() and stripplot() so the plots are displayed vertically. Passing horizontal=FALSE into stripplot in the simple code below doesn't seem to be the answer. library(lattice); x <- rnorm(100); y <- as.factor(sapply(1:100, function(k) sample(c("

Re: [R] Random Relabelling

2011-04-23 Thread Peter Ehlers
On 2011-04-23 03:42, John Kane wrote: I KNEW there was a better way! --- On Wed, 4/20/11, Jeremy Hetzel wrote: From: Jeremy Hetzel Subject: Re: [R] Random Relabelling To: r-help-arch...@googlegroups.com Cc: r-help@r-project.org, "Kevin Matthews" Received: Wednesday, April 20, 2011, 2:25 PM Ke

Re: [R] Using Java methods in R

2011-04-23 Thread hill0093
That's more than I can understand. I just need help from someone who knows. Should be a simple answer from that person. -- View this message in context: http://r.789695.n4.nabble.com/Using-Java-methods-in-R-tp3469299p3469882.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Using Java methods in R

2011-04-23 Thread Gabor Grothendieck
On Sat, Apr 23, 2011 at 8:32 AM, hill0093 wrote: > No answer to my post, > so let's try a simpler question. Am I doing this correctly? > I have the RGui with R Console on the screen. > On rhe top pullDowns, Packages > Install Packages > USA(IA)> rJava >> library(rJava) >> .jinit() >> qsLin <- .jne

[R] simple loop questions

2011-04-23 Thread xueke
Hi all, I am trying to write a loop to return the matched index for a column of values. Here is an simple example of this, A B 0 5 1 2 2 2 3 4 4 1 5 4 6 2 In this case, A is an index column for B. Now I have this new column C with just two values of 2 and 4. I want to match

Re: [R] Survival analysis: same subject with multiple treatments and experience multiple events

2011-04-23 Thread Mike Marchywka
> Date: Fri, 22 Apr 2011 10:00:31 -0400 > From: littleduc...@gmail.com > To: r-help@r-project.org > Subject: [R] Survival analysis: same subject with multiple treatments and > experience multiple events > > Hi there, > > I need some help to figure

Re: [R] Using Java methods in R

2011-04-23 Thread hill0093
No answer to my post, so let's try a simpler question. Am I doing this correctly? I have the RGui with R Console on the screen. On rhe top pullDowns, Packages > Install Packages > USA(IA)> rJava > library(rJava) > .jinit() > qsLin <- .jnew("C:/ad/j/CalqsLin") Error in .jnew("C:/ad/j/CalqsLin") :

Re: [R] Random Relabelling

2011-04-23 Thread John Kane
I KNEW there was a better way! --- On Wed, 4/20/11, Jeremy Hetzel wrote: > From: Jeremy Hetzel > Subject: Re: [R] Random Relabelling > To: r-help-arch...@googlegroups.com > Cc: r-help@r-project.org, "Kevin Matthews" > Received: Wednesday, April 20, 2011, 2:25 PM > Kevin, > > The following fol

Re: [R] Could I use R function lm or nlm in C code?

2011-04-23 Thread Gabor Grothendieck
On Sat, Apr 23, 2011 at 6:25 AM, Shuguang Sun wrote: > Dear R, > > I'm doing some simulation work and it takes me a lot of time to do it > in R. So I try to implement it in C code, but I want to use some R > functions directly for my lazy and the robustness of code. For > example, I will use lm an

Re: [R] [R-pkgs] Boost library in R package.

2011-04-23 Thread Martin Maechler
Wrong mailing list!! This got posted accidentally to R-packages -- which is exclusively for (semi-)important announcements by package *authors*. Please do only reply to R-help --- and do use R-help for *ALL* questions about R packages (unless you ask the package maintainer directly ..). Martin

[R] Could I use R function lm or nlm in C code?

2011-04-23 Thread Shuguang Sun
Dear R, I'm doing some simulation work and it takes me a lot of time to do it in R. So I try to implement it in C code, but I want to use some R functions directly for my lazy and the robustness of code. For example, I will use lm and nlm in my program. How could I use R's lm and nlm function dire

[R] Using "procGPA" in library "shapes" for one dimension

2011-04-23 Thread Kate Yaraee
Hi, Does anyone know if the function "procGPA" in library "shapes" works for aligning one dimensional curve? For example my input to this function is: procGPA(data, tangentresiduals = FALSE), where data is a 14 x 1 x 10 array. But I don't get any result and the error is: "Error in procGPA(data,

Re: [R] How to delete an entire row, if a specific colum has the value of "#VALUE!"

2011-04-23 Thread David Winsemius
On Apr 23, 2011, at 2:49 AM, David Winsemius wrote: On Apr 22, 2011, at 10:35 PM, empyrean wrote: I am importing CSV data with thousands of rows, if any row contains an error from excel, the whole program crashes, so i need to delete all rows with the value of #VALUE!, all other values a