Re: [R] Help me

2016-03-02 Thread Morteza Firouzi via R-help
 Moses, If I understand correctly, you are installed R and Rstudio.Please do find the package(s) you would like to use.Once you run rstudio, you can search and install the package(s) using the bottom right corner menu:Packages> Install> install from Repository (Cran)> search the package you woul

Re: [R] Extract row form a dataframe by row names in another vector and factor . Need explanation

2016-03-02 Thread Jeff Newmiller
Posting in HTML makes a mess of your code... learn to post in plain text. Not sure what you thought you would accomplish by using as.vector... perhaps you should read the help file ?as.vector. Did you look at str( dat1 )? Factors are more closely akin to integers than to characters. Indexing w

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread Berend Hasselman
> On 2 Mar 2016, at 22:22, David L Carlson wrote: > > Another way would be to use matplot() or matlines(): > >> lx<-c(0.4, 0.5, 0.6, 0.7) >> x <- seq(1, 8, length.out=100) >> myfun <- function(x, k) {(log(k)-(0.37273*log(x)-1.79389))/0.17941} >> y <- sapply(lx, function(k) myfun(x, k)) >> matpl

[R] Help me

2016-03-02 Thread Moss Moss
Please, I need help from you. I am new to R. I installed R, Rstudio and R Crans or packages that I will like to use. Thanks for your help on that. Right now, what do I do? Will I upload the CRAN packages already installed, so that a GUI interface will come up. I am working on Location Model and

[R] Extract row form a dataframe by row names in another vector and factor . Need explanation

2016-03-02 Thread Mohammad Tanvir Ahamed via R-help
Hi,Here i have written an example to explain my problem ## Data Generationdat<-data.frame(matrix(1:50,ncol=5)) rownames(dat)<-letters[1:10] colnames(dat)<- c("SA1","SA2","SA3","SA4","SA5") dat1<-data.frame(matrix(letters[1:20],ncol=4)) colnames(dat1)<-c("AA","BB","CC","DD") ## Row names v1<-dat1[

[R] Help with step.gam

2016-03-02 Thread sbihorel
Hi, When very simple models are tested in step.gam, I have observed the some difference in the final output result based upon the version of the package tested. Is this an expected behavior or a bug in the latest version of the gam package? With gam 1.4: > data(gam.data) > gam.object <- gam

Re: [R] Problem installing packages: cannot open file '/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf'

2016-03-02 Thread David Winsemius
> On Mar 2, 2016, at 10:00 AM, John Hillier wrote: > > > Dear All, > > > I am a relative newbie to R, and am struggling to install packages on my > laptop (although I have managed to on my desktop and a borrowed departmental > laptop). > The words "my laptop" is rather uninformative. Base

Re: [R] Ruofei Mo - How can I generate correlated data with non-normal distribution?

2016-03-02 Thread Ben Bolker
Ruofei Mo【莫若飞】 <911mruofei tongji.edu.cn> writes: > > Hi, All, > > I have a question about how to generate correlated data with non-normal > distribution? Basic, I have a variable a that follows a normal distribution, > a ~ N(0,1), then I want to generate another variable b that follows a > uni

Re: [R] How to refer a variable in quotes

2016-03-02 Thread Jim Lemon
Hi Jinggaofu, Try this: for(u in 1:9) { pdffile<-paste(g[u],".pdf",sep="") pdf(pdffile) ... mtext(g[u],side=4) If you index the vector g, it will return one or more character strings. Jim On Thu, Mar 3, 2016 at 9:52 AM, Jinggaofu Shi wrote: > Hi, there > I am new to R, here is an urgent que

Re: [R] How to refer a variable in quotes

2016-03-02 Thread Bert Gunter
1. Please spend some time with an R tutorial or two to become familiar with R basics. 2. Please do not post in HTML. This is a plain text email list. 3. See e.g. ?sprintf or ?paste for your problem. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming al

Re: [R] Functional programming?

2016-03-02 Thread Roger Koenker
Thanks again to all. This was highly educational for me. As it turned out Mikiko's suggestion turned out to be most easily adaptable to my real problem. I’m not at all able to evaluate relative efficiency at this point, but fortunately this isn’t an important factor (so far) in what I’m trying t

[R] Ruofei Mo - How can I generate correlated data with non-normal distribution?

2016-03-02 Thread Ruofei Mo【莫若飞】
Hi, All, I have a question about how to generate correlated data with non-normal distribution? Basic, I have a variable a that follows a normal distribution, a ~ N(0,1), then I want to generate another variable b that follows a uniform distribution, b ~ U(0, 1). Most importantly, I want the cor

Re: [R] help in maximum likelihood

2016-03-02 Thread Alaa Sindi
Thank you very much prof. Ravi, That was very helpful. Is there a way to get the t and p value for the coefficients? Thanks Alaa > On Mar 2, 2016, at 10:05 AM, Ravi Varadhan wrote: > > There is nothing wrong with the optimization. It is a warning message. > However, this is a good example

[R] How to refer a variable in quotes

2016-03-02 Thread Jinggaofu Shi
Hi, there I am new to R, here is an urgent question. I want to save several graphs by a for loop. But I don't know how to refer the variable in the quotes. Here is my code. g<-c("g1","g2","g3","g4","g5","g6","g7","g8","g9") for (u in 1:9) {pdf("g[u]".pdf") + plot(1,1, xlim=range(x), ylim=c(-5,5),

[R] Problem installing packages: cannot open file '/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf'

2016-03-02 Thread John Hillier
Dear All, I am a relative newbie to R, and am struggling to install packages on my laptop (although I have managed to on my desktop and a borrowed departmental laptop). I have tried various packages with the same result. Illustration for > install.packages("outliers") leads to .

Re: [R] Seasonal Cointegration

2016-03-02 Thread John C Frain
tRY HEGY.test() in R package pdr. John C Frain 3 Aranleigh Park Rathfarnham Dublin 14 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:fra...@tcd.ie mailto:fra...@gmail.com On 29 February 2016 at 19:14, Sarah Goslee wrote: > Checking Rseek.org turns up this discussion thread: > http:/

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread David L Carlson
Another way would be to use matplot() or matlines(): > lx<-c(0.4, 0.5, 0.6, 0.7) > x <- seq(1, 8, length.out=100) > myfun <- function(x, k) {(log(k)-(0.37273*log(x)-1.79389))/0.17941} > y <- sapply(lx, function(k) myfun(x, k)) > matplot(x, a, type="l", col="black", lty=1)

Re: [R] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
Sorry, I was assuming your data was a matrix (as you indicated in your question). Try: write.table(as.matrix(PRdist), file = 'clipboard', sep = '\t', row.names = F, col.names = F) -Dan On Wed, Mar 2, 2016 at 1:01 PM, Michael wrote: > I got an error message. > > > > write.table(PRdist, file =

Re: [R] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
Hi Michael, If you are working in Windows: # You can put the matrix directly into the clipboard write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F, col.names = F) The "sep" argument tells what character to use for separating columns. Default for Excel is tab (i.e. '\t') Default fo

Re: [R] output my results into Excel

2016-03-02 Thread Sarah Goslee
Hi Michael, Googling "export R data to Excel" gives LOTS of advice, including packages that can write your data directly to Excel spreadsheets. I don't use Excel, so I haven't tried any of those, but using write.csv() to export your data will create something that my colleagues who use Excel have

[R] output my results into Excel

2016-03-02 Thread Michael
I can get R to calculate the distance that I want between my data points. However, I am stuck trying to get R to output the data so I can paste it into Excel. Instead, R outputs a matrix mess in the console. Below are the steps I am taking to calculate the distance between my data. Also, I h

Re: [R] Functional programming?

2016-03-02 Thread Bert Gunter
Thanks, Roger: I think Duncan's approach is far more efficient, but I believe the following replicates your result and may be a bit easier to understand. f <- function(u) function(x) u * x^2 g <- function(u) function(x) u * log(x) set.seed(3) a <- runif(5) h <- list() hit <- list() h[[1]] <- f(a[

Re: [R] Functional programming?

2016-03-02 Thread Mikko Korpela
On 02.03.2016 18:47, Roger Koenker wrote: > I have a (remarkably ugly!!) code snippet (below) that, given > two simple functions, f and g, generates > a list of new functions h_{k+1} = h_k * g, k= 1, …, K. Surely, there are > vastly > better ways to do this. I don’t particularly care about th

Re: [R] Functional programming?

2016-03-02 Thread Gabor Grothendieck
This manufactures the functions without using eval by using substitute to substitute i-1 and a[i] into an expression for the body which is then assigned to the body of the function: hh <- vector("list", 5) hh[[1]] <- f(a[1]) for(i in 2:5) { hh[[i]] <- hh[[1]] body(hh[[i]]) <- substitute(

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread Dalthorp, Daniel
Or, if you want easy labels, you can play around with contour graphs. ?contour # will give you info on how to make contour plots The basic idea is to construct a matrix of z-values...one z for every combination of x and y contour(x,y,z) The x's would then be the x-values you want in (0.37273*log

Re: [R] Functional programming?

2016-03-02 Thread Roger Koenker
Thanks, Duncan and Bert, Duncan’s version does replicate my result, Bert’s does something a bit different, now I just need some time to digest what you have done, and try to see how and why. Many thanks!!! Roger url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.e

Re: [R] Functional programming?

2016-03-02 Thread Duncan Murdoch
On 02/03/2016 11:47 AM, Roger Koenker wrote: I have a (remarkably ugly!!) code snippet (below) that, given two simple functions, f and g, generates a list of new functions h_{k+1} = h_k * g, k= 1, …, K. Surely, there are vastly better ways to do this. I don’t particularly care about the ret

Re: [R] Functional programming?

2016-03-02 Thread Bert Gunter
Does this do what you want: f <- function(u) function(x) u * x^2 g <- function(u) function(x) u * log(x) set.seed(3) a <- runif(5) h <- list() hit <- list() h[[1]] <- f(a[1]) hit[[1]] <- f(a[1]) for(i in 2:5)h[[i]] <- eval(bquote(function(x).(h[[i-1]])(x) * g(a[i])(x))) x <- 1:99/10 plot(x, h[[1]]

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread Dalthorp, Daniel
A simple solution that will give you an idea of some of the plot parameters: x<-seq(1,10,length=1000) # values for x-axis x0<-c(0.4,0.5,0.6,0.7) miny<-(log(min(x0))-(0.37273*log(max(x))-1.79389))/0.17941 # minimum y-value to show on graph maxy<-(log(max(x0))-(0.37273*log(min(x))-1.79389))/0.17941

[R] Plot multiple similar equations in r

2016-03-02 Thread Jinggaofu Shi
Hi, there I am new on R. I want to plot a graph like this. The curves are created by these equations : (log(0.4)-(0.37273*log(x)-1.79389))/0.17941, (log(0.5)-(0.37273*log(x)-1.79389))/0.17941, (log(0.6)-(0.37273*log(x)-1.79389))/0.17941, etc. The equations are similar, the only difference is the f

[R] Functional programming?

2016-03-02 Thread Roger Koenker
I have a (remarkably ugly!!) code snippet (below) that, given two simple functions, f and g, generates a list of new functions h_{k+1} = h_k * g, k= 1, …, K. Surely, there are vastly better ways to do this. I don’t particularly care about the returned list, I’d be happy to have the final h_K

Re: [R] plotting spline term when frailty term is included

2016-03-02 Thread Therneau, Terry M., Ph.D.
On 03/02/2016 05:00 AM, r-help-requ...@r-project.org wrote: I'd very much appreciate your help in resolving a problem that I'm having with plotting a spline term. I have a Cox PH model including a smoothing spline and a frailty term as follows: fit<-coxph(Surv(start,end,exit) ~ x + pspl

[R] discriminant analysis lda under MASS

2016-03-02 Thread Jens Koch
Hello all, I'd like to run a simple discriminant analysis to jump into the topic with the following dataset provided by a textbook: Gruppe Einwohner Kosten 1 1642 478,2 1 2418 247,3 1 1417 223,6 1 2761 505,6 1 3991 399,3 1 2500 276 1 6261 542,5 1 3260 308,9 1 2516 453,6 1 4451 430,2 1 3504 413,8

Re: [R] help in maximum likelihood

2016-03-02 Thread Ravi Varadhan
There is nothing wrong with the optimization. It is a warning message. However, this is a good example to show that one should not simply dismiss a warning before understanding what it means. The MLE parameters are also large, indicating that there is something funky about the model or the da

Re: [R] Change the location of R

2016-03-02 Thread Loris Bennett
Hi Carol, carol white via R-help writes: > Hi,I have R v 3.0 installed /usr/... and the new version R-3.2.3 in my > home under ubuntu. Is it correct to copy the R-3.2.3 directory into > /usr/local/lib/R/ or should I reconfig and remake into > /usr/local/lib/R/? > Regards, > Carol The standard w

[R] Change the location of R

2016-03-02 Thread carol white via R-help
Hi,I have R v 3.0 installed /usr/... and the new version R-3.2.3 in my home under ubuntu. Is it correct to copy the R-3.2.3 directory into /usr/local/lib/R/ or should I reconfig and remake into /usr/local/lib/R/? Regards, Carol [[alternative HTML version deleted]] __

Re: [R] path + name of the running R file

2016-03-02 Thread PIKAL Petr
Hi Jean As I said I am not a programmer, although I made some stuff with old languages like Basic (not Visual) or some kind of assembly language from late 80s. So your questions are out of my depth. I hope others can give you better insight. Cheers Petr > -Original Message- > From: MA

Re: [R] how to get the 'starting directory'

2016-03-02 Thread MAURICE Jean - externe
Hi Martin, And you forgot Git ! So for now, I gave up (abandonned ?) Git And if Rstudio annoys me once more, I'll abandon it (skip it ?) I like when things are simple and when I error occurs I like to have a message ... Jean PS I know something complicated that is very simple to use : SBB CFF

Re: [R] how to get the 'starting directory'

2016-03-02 Thread Martin Maechler
> MAURICE Jean <- externe > > on Wed, 2 Mar 2016 08:50:50 + writes: > The message with the bomb is R session .. see picture > Jean > De : jdnew...@dcn.davis.ca.us [mailto:jdnew...@dcn.davis.ca.us] > Envoyé : mercredi 2 mars 2016 09:10 > À : MAURICE Jean - exter

Re: [R] path + name of the running R file

2016-03-02 Thread MAURICE Jean - externe
> from late 80s The good old time Jean -Message d'origine- De : petr.pi...@precheza.cz [mailto:petr.pi...@precheza.cz] Envoyé : mercredi 2 mars 2016 09:51 À : MAURICE Jean - externe; r-help@r-project.org Objet : RE: path + name of the running R file Hi Jean As I said I am not a p

Re: [R] how to get the 'starting directory'

2016-03-02 Thread MAURICE Jean - externe
The message with the bomb is R session .. see picture Jean De : jdnew...@dcn.davis.ca.us [mailto:jdnew...@dcn.davis.ca.us] Envoyé : mercredi 2 mars 2016 09:10 À : MAURICE Jean - externe; petr.pi...@precheza.cz; r-help@r-project.org Objet : Re: [R] how to get the 'starting directory' I am guessin

Re: [R] ggplot2-theme(panel.border)

2016-03-02 Thread Aashish Jain
You can write "fill = NA" in the argument of element_rect(), that should solve your problem. On Tue, Mar 1, 2016 at 3:46 PM, Hoji, Akihiko wrote: > A quick question. How come data points disappear when > “theme(panel.border=element_rect()) is used and how could I get those > points back on the

Re: [R] path + name of the running R file

2016-03-02 Thread MAURICE Jean - externe
I suppose (think) that, in RStudio the shorcut alt+ctrl+R is converted to a source command so it can work : I try. Thanks Jean -Message d'origine- De : drjimle...@gmail.com [mailto:drjimle...@gmail.com] Envoyé : mercredi 2 mars 2016 09:13 À : MAURICE Jean - externe; r-help@r-project.org

Re: [R] how to get the 'starting directory'

2016-03-02 Thread MAURICE Jean - externe
I didn’t know that Rstudio was a separate tool ! So now, I have a new field to manage ! Thanks Jean De : jdnew...@dcn.davis.ca.us [mailto:jdnew...@dcn.davis.ca.us] Envoyé : mercredi 2 mars 2016 09:10 À : MAURICE Jean - externe; petr.pi...@precheza.cz; r-help@r-project.org Objet : Re: [R] how

Re: [R] path + name of the running R file

2016-03-02 Thread Jim Lemon
Hi Maurice, If you have used "source" to run an R script, perhaps you could try something like this: get.running.file<-function(pattern="source",...) { file1 <- tempfile("Rrawhist") savehistory(file1) rawhist <- readLines(file1) unlink(file1) last.source<-grep(pattern,rev(rawhist),value=TRUE)

Re: [R] how to get the 'starting directory'

2016-03-02 Thread Jeff Newmiller
I am guessing that it is RStudio that bombs... I have seen that bomb dialog from RStudio but never from R. However, this is not the RStudio support forum... you should be asking someone involved with that software. -- Sent from my phone. Please excuse my brevity. On March 1, 2016 11:38:00 PM P

Re: [R] path + name of the running R file

2016-03-02 Thread MAURICE Jean - externe
Hi Petr, I am an old FORTRAN programmer and new to R. The 'philosophy' of R is very very far from FORTRAN ! So, may be I am wrong but : I want to test 3 projects. In fact, these 3 projects are identical but not in the same directory : one within Git (a source management), one on the server and