Re: [R] Run an external software in R

2016-09-06 Thread William Dunlap via R-help
You can use system() or shell(), which adds "cmd.exe /c " to the front of your command so you can use DOS syntax. Remember to add double quotes when file names have spaces in them. E.g., I can call an old version of R with the following and later read its text output into my current session. > i

Re: [R] Run an external software in R

2016-09-06 Thread Bert Gunter
?system But this begs the question: WHY would you want to do this? More specifically, what should R communicate to your other software, and what should the other software communicate to R? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and stick

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Bert Gunter
Jun: "My problem is the pattern has to be dynamically constructed on the input data of the function " What does that mean? How can a pattern be "dynamically constructed" when you have not made clear (at least to me, perhaps also to yourself and/or others) *how* it is to be constructed? Cheers, B

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Ista, Thanks for the suggestion. I didn't know mapply can be used this way! Let me take one more step. Instead of defining a pattern for each string, I would like to define a set of patterns from all the possible combination of the unique values of those variables. Then I need each string to fi

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Jeff, Thanks for the reply. I tried your suggestion and it doesn't seem to work and I tried a simple pattern as follows and it works as expected sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\1', "3.mg.kg.>50-70.kg.P05") [1] "3.mg.kg" sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\2', "3.mg.k

[R] Run an external software in R

2016-09-06 Thread Marino David
Hi all R users: Does anybody have the experience of running an external software in R? I try to use R to run ANSYS software, which is a engineering simulation package. I ever have done this task in Matlab platform by executing the following code line: system('"C:\Program Files\Ansys Inc\v100\ANSY

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Bert, In the final.pattern, there are ten patterns. >sub(final.pattern, '\\1', test.string) Expected results: "240.m.g" "3.mg.kg" "240.m.g" Current results: "" "" "240.m.g" >sub(final.pattern, '\\2', test.string) Expected results: ">110.kg" ">110.kg" ">50-70.kg" Current results: "" "" ">50-70

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jeff Newmiller
I am not near my computer today, but each parenthesis gets its own result number, so you should put the parenthesis around the whole pattern of alternatives instead of having many parentheses. I recommend thinking in terms of what common information you expect to find in these various strings,

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Bert, I still couldn't make the multiple patterns to work. Here is an example. I make the pattern as follows final.pattern <- "(240\\.m\\.g)\\.(>50-70\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>70-90\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>70-90\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>9

Re: [R] save R object into a remote directory

2016-09-06 Thread Henrik Bengtsson
On Tue, Sep 6, 2016 at 2:00 AM, Rainer M Krug wrote: > Please reply to the mailing list to keep the conversation available for > everybody. I Send this mail to the mailing list as well. > > Simone Tenan writes: > >> Thanks Rainer, >> it's very kind of you. >> Unfortunately, I cannot save the (lar

Re: [R] graph together 4 series after HP filter

2016-09-06 Thread Giorgio Garziano
Hi Sebastian, here are examples with ggplot2 and basic graphic. http://stackoverflow.com/questions/3777174/plotting-two-variables-as-lines-using-ggplot2-on-the-same-graph http://stackoverflow.com/questions/17150183/r-plot-multiple-lines-in-one-graph You may also impress your audience by using

Re: [R] R-square prob is not calculated by randomization in lmPerm::lmp

2016-09-06 Thread Cade, Brian
For a linear model without an intercept term as in this example, neither the usual permutation scheme for testing Ho: B1 = 0 nor usual definition of R-squared apply. So you need to check what the developer of this code chose to do. If I'm recalling correctly, in a linear model with an intercept t

Re: [R] graph together 4 series after HP filter

2016-09-06 Thread Bert Gunter
?lines ?points to add to an existing base graphics graph. There are other ways to do this in the other graph systems (ggplot, lattice,...) used in R. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkele

Re: [R] R-square prob is not calculated by randomization in lmPerm::lmp

2016-09-06 Thread Jeff Newmiller
That is contributed code. It could do anything the author felt like. I recommend reading the source code. -- Sent from my phone. Please excuse my brevity. On September 5, 2016 11:52:15 PM PDT, Agustin Lobo wrote: >Any reason why the R-square prob is not calculated by randomization in >lmPerm::

Re: [R] Factor analysis and time as an offset variable

2016-09-06 Thread Tahereh Dehdarirad
Thank you for your reply. I am grouping citation and some social media indictors ( number of tweets, mendeley readers, etc). The number of citaions a paper recievs or the number of social media indicators that a papers receives depends on time. For example a paper published in 2009 has more time to

Re: [R] Factor analysis and time as an offset variable

2016-09-06 Thread Jeff Newmiller
That step is easy, but context is hard. You really need to provide a reproducible example. There are many models, many analysis tools, and many timescales to choose from. In fact, this could easily be mistaken for a question about statistics (not really on-topic here) since you have failed to

Re: [R] (no subject)

2016-09-06 Thread Jeff Newmiller
It is not the implementation of regex that requires double backslashes, but the R string parser. You can use cat to see what the pattern looks like to the parser. Try cat( "\\(.*?\\)" ) -- Sent from my phone. Please excuse my brevity. On September 6, 2016 6:33:15 AM PDT, Sarah Goslee wrote:

Re: [R] Conditional gap time frailty cox model for recurrent events

2016-09-06 Thread Therneau, Terry M., Ph.D.
You can ignore the message below. The maximizing routine buried within the frailty() command buried with coxph() has a maximizer that is not the brightest. It sometimes gets lost but then finds its way again. The message is from one of those. It likely took a not-so-good update step, and too

Re: [R] save R object into a remote directory

2016-09-06 Thread peter dalgaard
On 06 Sep 2016, at 11:00 , Rainer M Krug wrote: > Please reply to the mailing list to keep the conversation available for > everybody. I Send this mail to the mailing list as well. > > Simone Tenan writes: > >> Thanks Rainer, >> it's very kind of you. >> Unfortunately, I cannot save the (lar

[R] graph together 4 series after HP filter

2016-09-06 Thread Sebastian Kruk
Dear R-users: Let's see if you can help. I have an matrix of class "ts" of 100 rows by 4 columns which called PP. In each column I have the time series of quarterly GDP from 4 countries. They applied the Hodrick -Prescott filter and now I want to plot simultaneously cyclical component of the 4

Re: [R] (no subject)

2016-09-06 Thread Sarah Goslee
R's implementation of regex requires double backslashes. Reading ?regex will tell you more. cleanBetweenBrackets <- function(String) { return(gsub("\\(.*?\\)", "", String)) } Str <- "The cat is crazy (but not too crazy)" cleanBetweenBrackets(Str) > cleanBetweenBrackets(Str) [1] "The cat is c

[R] Factor analysis and time as an offset variable

2016-09-06 Thread Tahereh Dehdarirad
Hi, Is it possible to use time as an offset (exposure variable) in factor analysis? If yes, would you please advise how? Thanks, Tahereh Tahereh Dehdarirad PhD Student of Library and Information Science University of Barcelona, Spain [[alternative HTML version deleted]] __

Re: [R] outliers in Box Plot

2016-09-06 Thread Giorgio Garziano
Hi Rosa, you may take advantage of the extremevalues package. https://cran.r-project.org/web/packages/extremevalues/extremevalues.pdf An example: set.seed(1023) v3 <- c(rnorm(100, 0, 0.2), rnorm(5, 4, 0.1), rnorm(5, -4, 0.1)) v4 <- sample(v3, length(v3)) nam <- as.character(1:length(v4)) df <-

[R] Fwd:

2016-09-06 Thread Audrey Riddell
Hello, I have been able to figure this out using \\ (two back slashes for escape) Working R code for what I wanted is... cleanBetweenBrackets <- function(String) { return(gsub("\\(.*?\\)", "", String))} I thought I had tried that (the \\) before I emailed the list. Please ignore my previous em

Re: [R] Help with a code in R

2016-09-06 Thread Bert Gunter
?traceback ?debug ?trace R has built-in debugging tools. Learn to use them. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Sep 5, 2016 at 1

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Bert Gunter
Just noticed: My clumsy do.call() line in my previously posted code below should be replaced with: pat <- paste(pat,collapse = "|") > pat <- c(pat1,pat2) > paste(pat,collapse="|") [1] "a+\\.*a+|b+\\.*b+" replace this ** > pat <- do.call(paste,c(as.list(pat),

[R] (no subject)

2016-09-06 Thread Audrey Riddell
Hello, I am trying to remove brackets and the text contained in brackets. I tried to do a user defined formula... my attempt at this is pasted below. cleanBetweenBrackets <- function(String) { return(gsub("\(.*?\)", "", String))} I keep getting errors (namely that there is an unrecognised es

[R] R-square prob is not calculated by randomization in lmPerm::lmp

2016-09-06 Thread Agustin Lobo
Any reason why the R-square prob is not calculated by randomization in lmPerm::lmp? The help pages states "Either permutation test p-values or the usual F-test p-values will be output", but I always get the F test for R-square as with lm(): require(lmPerm) x <- 1:1000 set.seed(1000) y1 <- x*2+runi

Re: [R] finegray function in survival package

2016-09-06 Thread Ahalya Sivathayalan
Dear R-Team, I have been trying to use the finegray routine that creates a special data so that Fine and Gray model can be fit. However, it does not seem to work. Could you please help me with this issue? Thanks, Ahalya. [[alternative HTML version deleted]]

Re: [R] Iteration over variables

2016-09-06 Thread Rolf Turner
You need to *print* results explicitly within a for-loop. E.g. print(head(d_dataset[, c(paste0("v_turnover_",year), paste0("v_customer_", year))])) See FAQ 7.16 for a related discussion. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of

[R] Iteration over variables

2016-09-06 Thread G . Maubach
Hi All, I would like to write a program that iterates over a set of dynamically generated variables and produces some stats or prints parts of the data. # --- data v_turnover_2011 <- c(10, 20, 30, 40 , 50) v_customer_2011 <- c(0, 1, NA, 0, 1) v_turnover_2012 <- c(10, 20, 30, 40 , 50) v_customer_

Re: [R] save R object into a remote directory

2016-09-06 Thread Rainer M Krug
Please reply to the mailing list to keep the conversation available for everybody. I Send this mail to the mailing list as well. Simone Tenan writes: > Thanks Rainer, > it's very kind of you. > Unfortunately, I cannot save the (large) R object where the current R session > is running. There is

Re: [R] save R object into a remote directory

2016-09-06 Thread Rainer M Krug
Simone Tenan writes: > Hi all, > I'm using R remotely via ssh connection in linux. I need to save a large R > object from the remote server to my laptop. How can I specify the path in > the save() function? You are working on the remote machine and there is no way that you can specify "out of th

[R] save R object into a remote directory

2016-09-06 Thread Simone Tenan
Hi all, I'm using R remotely via ssh connection in linux. I need to save a large R object from the remote server to my laptop. How can I specify the path in the save() function? Thanks much for your help, Simone [[alternative HTML version deleted]] ___