[R] automation of an R script to run

2013-10-11 Thread Johnson, Alex
Hi, I was wondering if there is there a way you can schedule an R script to run automatically through a scheduled task in windows or similar?.. Would R have to be open on the user's PC or could it be closed providing we pointed it correctly at R?... Thank you Alex Alex Johnson

[R] ggplot2 : to change the title of legend

2013-10-11 Thread Arnaud Michel
Hello I don't arrive to change the title of the legend My code is : library(ggplot2) ma - max(General$AgeChangCat) ; mi - min(General$AgeChangCat) Test$Recrutement - factor(Test$CadNonCadRecrut) p - ggplot(Test, aes(x=factor(Cat1), y=AgeChangCat )) + ylim(mi,ma) + geom_point() +

Re: [R] iconv question: SQL Server 2005 to R

2013-10-11 Thread Milan Bouchet-Valat
Le jeudi 10 octobre 2013 à 21:45 -0700, Ira Sharenow a écrit : Thanks for the suggestion. From R version 3.0.2, I tried testDF7 = iconv(x = test07 , from = UCS-2, to = ) Encoding(testDF7) [1] unknown testDF7[1:6] [1] NA NA NA NA NA NA So using UCS-2 produced

Re: [R] automation of an R script to run

2013-10-11 Thread Anthony Damico
if you want to use R itself, you could try -- # check your time zone's abbreviation Sys.time() # subtract the time you want the program to run from the current time, # including your time zone..mine is EDT Sys.sleep( as.POSIXct( 2013-10-11 06:30:00 EDT ) - Sys.time() ) -- at the very top of

[R] How to altering the colour of confidence intervals in a lattice.

2013-10-11 Thread Rebecca Stirnemann
Hi R wizards, Can any one tell me how to code to remove the title panels in a lattice graph and to make my confidence intervals black instead of coloured? I have the following code: library(effects) library(lme4) data(mao1, package=lme4) fm1 - lmer(frat ~ flandusenumb + ground.cover_lo +

[R] behaviour of read.xls (gdata package) when worksheet usesuser-defined cells formats

2013-10-11 Thread Olivier Eterradossi
(I'm afraid this post didn't reach the list on last Wednesday, here it is again ) hi R-list, And sorry for my frenglish ! I am running R Good Sport release ( i386-w64-mingw32/i386 (32-bit) ) ) under Windows 7 Professional, Service Pack 1. My perl executable is ActivePerl build 817 [257965]

Re: [R] Problems with R

2013-10-11 Thread S Ellison
I have recently installed R and am trying to do some work on it. Congratulations; you are learning one of (possibly the) world's most powerful statistics environments. To be honest I'm finding it a PAIN to [use?]. You can have cheap, powerful, easy to use statistics software. Pick any two.

Re: [R] Help required graphing factors with predicted model settings

2013-10-11 Thread Michael Friendly
On 10/10/2013 11:33 PM, Rebecca Stirnemann wrote: Hi Michael, Thanks! That worked. Which is so brilliant! A couple of questions. In regards to display. Do you know how to add labels on to the graph? The code below doesn't work. Not surprising, since your data, mao1, is not in the lme4

Re: [R] ggplot2 : to change the title of legend

2013-10-11 Thread PIKAL Petr
Hi I usually use scale something like scale_fill_discrete(name = Fancy Title) shall do the trick Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Arnaud Michel Sent: Friday, October 11, 2013 11:02 AM To: R

Re: [R] Possible loop/ if statement query

2013-10-11 Thread PIKAL Petr
Hi not sure if it is the most efficient and clever solution ifelse(b7, NA, cumsum(c(0,diff(!(b7)))==1)) Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Benjamin Gillespie Sent: Thursday, October 10, 2013 12:39

[R] Create sequential vector for values in another column

2013-10-11 Thread Steven Ranney
Hello all - I have an example column in a dataFrame id.name 123.45 123.45 123.45 123.45 234.56 234.56 234.56 234.56 234.56 234.56 234.56 345.67 345.67 345.67 456.78 456.78 456.78 456.78 456.78 456.78 456.78 456.78 456.78 ... [truncated] And I'd like to create a second vector of sequential

Re: [R] ggplot2 : to change the title of legend

2013-10-11 Thread Arnaud Michel
OK It is right Thank you Petr Michel Le 11/10/2013 14:58, PIKAL Petr a écrit : Hi I usually use scale something like scale_fill_discrete(name = Fancy Title) shall do the trick Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-

Re: [R] Create sequential vector for values in another column

2013-10-11 Thread arun
Also, it might be faster to use ?data.table() library(data.table)  dt1- data.table(dat1,key='id.name') dt1[,x:=seq(.N),by='id.name'] A.K. On , arun smartpink...@yahoo.com wrote: Hi, Try: dat1- structure(list(id.name = c(123.45, 123.45, 123.45, 123.45, 234.56, 234.56, 234.56, 234.56,

[R] Mixed models with overdispersion

2013-10-11 Thread Marine Regis
Hello everybody, I have count data and with these data, I would like to build a mixed model by using the function glmer(). In a first time, I calculated the c-hat of a simple model with glm() to verify overdispersion and I found a c-hat = 18. I also verified overdispersion in the mixed model

Re: [R] Bootstrap (bootSem) causes R to crash

2013-10-11 Thread Eric Green
To close the loop on this, I can report that I solved the convergence issue by updating the original semBoot code. I thought I might be using something out of date, so I ran sem:::bootSem.sem and grabbed the function code. I updated the gist where I create bootSem2() to stop R from crashing on

Re: [R] Create sequential vector for values in another column

2013-10-11 Thread PIKAL Petr
Hi I named your data test test$x-1 test$x-unlist(lapply(split(test$x, test$id.name), cumsum)) test id.name x 1 123.45 1 2 123.45 2 3 123.45 3 4 123.45 4 5 234.56 1 6 234.56 2 7 234.56 3 8 234.56 4 9 234.56 5 10 234.56 6 11 234.56 7 12 345.67 1 13 345.67 2 14 345.67 3

Re: [R] automation of an R script to run

2013-10-11 Thread vivek
Steps: 1. write your code in R command line format 2. save to a .sh file 3. Add to cron of linux machine Regards, Vivek -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Johnson, Alex Sent: Friday, October 11, 2013 4:05 PM To:

Re: [R] Create sequential vector for values in another column

2013-10-11 Thread Berend Hasselman
On 11-10-2013, at 15:26, Steven Ranney steven.ran...@gmail.com wrote: Hello all - I have an example column in a dataFrame id.name 123.45 123.45 123.45 123.45 234.56 234.56 234.56 234.56 234.56 234.56 234.56 345.67 345.67 345.67 456.78 456.78 456.78 456.78 456.78 456.78

Re: [R] iconv question: SQL Server 2005 to R

2013-10-11 Thread Ira Sharenow
Success! Thanks to everyone who helped. I needed to have the right file encoding parameter when using read.table(). test08 = read.table(test.csv, sep = ,, header = TRUE, stringsAsFactors = FALSE, fileEncoding = UCS-2) Upon further research:

Re: [R] Splitting times into groups based on a range of times

2013-10-11 Thread arun
Also, df1 - do.call(rbind,lapply(split(df,df$group),function(x) data.frame(dt2=seq(x[1,1],x[nrow(x),1],by=15 min),group=x[1,2]))) id1- df1[,2][match(as.POSIXct(dt),df1[,1])]  id1[is.na(id1)]- 0  identical(id1,id) #[1] TRUE A.K, On Thursday, October 10, 2013 9:29 PM, arun smartpink...@yahoo.com

Re: [R] order() not producing results as I expect

2013-10-11 Thread peter dalgaard
I'd wager that the problem lies in the expectations. Karl: Read up on what order() actually does; it is not what I think you think it does. Perhaps str.dat[match(gen.names, str.dat$ind.names),] or rownames(str.dat) - str.dat$ind.names str.dat[gen.names,] was intended? (Both untested, some

Re: [R] Looking for package to solve for exponent using newton's method

2013-10-11 Thread Prof J C Nash (U30A)
And if you need some extra digits: require(Rmpfr) testfn-function(x){2^x+3^x-13} myint-c(mpfr(-5,precBits=1000),mpfr(5,precBits=1000)) myroot-unirootR(testfn, myint, tol=1e-30) myroot John Nash On 13-10-11 06:00 AM, r-help-requ...@r-project.org wrote: Message: 33 Date: Thu, 10 Oct 2013

Re: [R] order() not producing results as I expect

2013-10-11 Thread S Ellison
-Original Message- I'm using R version 3.0.0 on a mac. I'm having trouble getting order to behave as I expect it should. I'm trying to sort a data.frame according to a character vector. I'm able to sort the data.frame, but it retruns an unexpected result. I have no idea where the

Re: [R] system2 commands with backslash

2013-10-11 Thread David Winsemius
On Oct 10, 2013, at 8:16 AM, Zev Ross wrote: Hi All, I'm trying to edit a file in place using system2 and sed from within R. I can get my command to work unless there is a backslash in the command in which case I'm warned about an unrecognized escape. So, for example: system2(sed -i

[R] labeling abscissa using a function of the plotted scale

2013-10-11 Thread Hurr
Is it easy or difficult to label the abscissa of a scatter graph as 1/trueScaleValue at that point? -- View this message in context: http://r.789695.n4.nabble.com/labeling-abscissa-using-a-function-of-the-plotted-scale-tp4678075.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] matrix values linked to vector index

2013-10-11 Thread arun
Hi, In the example you showed: m1- matrix(0,length(vec),max(vec)) 1*!upper.tri(m1) #or  m1[!upper.tri(m1)] -  rep(rep(1,length(vec)),vec) #But, in a case like below, perhaps: vec1- c(3,4,5)  m2- matrix(0,length(vec1),max(vec1))  indx -

Re: [R] Create sequential vector for values in another column

2013-10-11 Thread William Dunlap
At this point 3 functions have been suggested and I'll add a 4th: f1 - function(x)unlist(lapply(unname(split(rep.int(1L,length(x)), x)), cumsum)) f2 - function(x)unlist(sapply(rle(x)$lengths, function(k) 1:k )) f3 - function(x)ave(x,x,FUN=seq) f4 - function(x)ave(seq_along(x), x,

Re: [R] Create sequential vector for values in another column

2013-10-11 Thread William Dunlap
I think all of the above call lapply(split()) at some point and that can use a lot of memory when there are lots of unique values in x. You can use a sort-based algorithm to avoid that problem. E.g., Sequence - function(nvec) { # like base::sequence, but faster for long nvec. If

Re: [R] system2 commands with backslash

2013-10-11 Thread Henrik Bengtsson
system2(sed, args=c(-i, s/oldword\\s/newword/g, d:/junk/x/test.tex)) /Henrik On Fri, Oct 11, 2013 at 8:58 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 10, 2013, at 8:16 AM, Zev Ross wrote: Hi All, I'm trying to edit a file in place using system2 and sed from within R. I can

Re: [R] Gaussian Quadrature for arbitrary PDF

2013-10-11 Thread Spencer Graves
Are you familiar with the sos package? Consider the following: library(sos) op - findFn('orthogonal polynomial') # 165 links in 35 pkgs ops - findFn('orthogonal polynomials')#158 links in 35 pkgs op. - op |ops# 194 links in 43 pkgs save(op., file='orthopoly.rda') summary(op.)

Re: [R] system2 commands with backslash

2013-10-11 Thread Zev Ross
Thanks to Henrik and David for responses. Both were right. A small edit to my description of the problem (which has now been solved). I said that the first version of system2 ( system2(sed -i s/oldword/newword/g d:/junk/x/test.tex)) worked fine but in fact it was not working, it just wasn't

Re: [R] automation of an R script to run

2013-10-11 Thread Greg Snow
Look at the ?Startup help page in R. It shows a couple of ways to have code run automatically when R starts (and can depend on which folder R starts from). So you could have the windows task scheduler run R and use the above to set the script to run. Also look at ?Rscript for a way to run a

Re: [R] Help with expression()

2013-10-11 Thread Uwe Ligges
On 10.10.2013 21:40, Sheri wrote: Hi everyone, I am hoping someone can help with my attempted use of the expression function. I have a long series of text and variable to paste together including a degree symbol. The text is to be placed on my scatter plot using the mtext function. Using

[R] Looping over names of multiple data frames in an R for() loop XXXX

2013-10-11 Thread Dan Abner
Hi everybody, I thought I was using the get() fn correctly here to loop over multiple data frame names in an R for() loop. Can someone advise? miss-c(#NULL!,999) d-c(d1,d2,d3,d4) for(i in 1:4){ + + miss1-ifelse(i=2,miss[1],miss[2]) + miss1 + +

Re: [R] Looping over names of multiple data frames in an R for() loop XXXX

2013-10-11 Thread jim holtman
I think you want 'assign' at that point. Would suggest using a 'list' to store the input instead of unique named objects. 'list's are easier to manage. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On

Re: [R] Using cpquery function from bnlearn package inside loop

2013-10-11 Thread Marco Scutari
Dear Ryan, On 11 October 2013 16:50, Ryan Morrison ryan.r.morri...@me.com wrote: The cpquery function is definitely easier to use given that my evidence is contained in lists. For the record, this is not a general solution to the bug. It's true that likelihood weighting (method = lw) is easier

Re: [R] Using cpquery function from bnlearn package inside loop

2013-10-11 Thread Marco Scutari
Dear Ryan, On 11 October 2013 20:44, Ryan Morrison ryan.r.morri...@me.com wrote: Thanks for the clarification. For my immediate purposes I think using the likelihood weighting method will suffice. I'm calculating conditional probabilities based on a single instantiation each time I use the

Re: [R] matrix values linked to vector index

2013-10-11 Thread Dennis Murphy
Attempting to follow the OP's conditions and assuming I understood them correctly, here is one way to wrap this up into a function: makeMat - function(x) { stopifnot(is.integer(x)) nr - length(x) nc - max(x) # Initialize a matrix of zeros m - matrix(0, nr, nc) #

Re: [R] labeling abscissa using a function of the plotted scale

2013-10-11 Thread David Winsemius
On Oct 11, 2013, at 9:48 AM, Hurr wrote: Is it easy or difficult to label the abscissa of a scatter graph as 1/trueScaleValue at that point? It's easy. ?axis -- View this message in context:

Re: [R] matrix values linked to vector index

2013-10-11 Thread Bert Gunter
simpler (and sloppier) but with **no looping or apply's ** **IFF* the matrix is structured as in the OP's example, then lower.tri (or upper.tri) should be used: n - 4 ## number of columns in matrix -- note that I changed it from the example; does not have to be square x - 1:3 ## the number of

Re: [R] matrix values linked to vector index

2013-10-11 Thread arun
Thanks Dennis.  I noticed I didn't take the 0 value into consideration and also didn't check the unsorted vector.vec1- c(2,4,1) is.numeric(vec1) #[1] TRUE makeMat(as.integer(vec1)) makeMatrix2- function(x){  if(is.numeric(x)){ x - as.integer(round(x)) x} stopifnot(is.integer(x)) m1-

Re: [R] Splitting times into groups based on a range of times

2013-10-11 Thread Benjamin Gillespie
Hi Arun, Many thanks for that solution; it works well :) I also have some data where times and dates don't follow a 15 min intervals, so, for example: dates=rep(01/02/13,times=20)

Re: [R] Possible loop/ if statement query

2013-10-11 Thread Benjamin Gillespie
Nice, thanks Petr :) Ben Gillespie, Research Postgraduate o---o School of Geography, University of Leeds, Leeds, LS2 9JT o---o Tel: +44(0)113 34 33345 Mob: +44(0)770

Re: [R] matrix values linked to vector index

2013-10-11 Thread arun
Seems like a bug in the code: x- c(3,4,1) n- 3  matrix(rep(rep(c(1,0),n),rbind(x,n-x)),nc=n,byr=TRUE) #Error in rep(rep(c(1, 0), n), rbind(x, n - x)) : invalid 'times' argument  n- 4  matrix(rep(rep(c(1,0),n),rbind(x,n-x)),nc=n,byr=TRUE) #Error in rep(rep(c(1, 0), n), rbind(x, n - x)) : invalid

[R] R plotting

2013-10-11 Thread Mubar
Hi I have a question regarding plots in R. I have data from the SP 500 in the format: date close change 1980-01-07 109.92 3.4 I plotted the data with plot(spdata$date, log(spdata$close), type=p) Now I want to ad the colors green and red to the data frame. if the change is

[R] Singular matrix

2013-10-11 Thread Aya Anas
Dear all, I am using the DEoptim package. My optimization syntax has three decesion variables. If I increase the upper bound of the first or third variables,I get an error related to singularity of a matrix. However, I need to increase the upper bound of the first and third variables. The true

Re: [R] Using cpquery function from bnlearn package inside loop

2013-10-11 Thread Ryan Morrison
Thanks Marco, The cpquery function is definitely easier to use given that my evidence is contained in lists. Thanks for your help! --- Ryan Ryan Morrison, PE PhD Candidate University of New Mexico Department of Civil Engineering Centennial Engineering Center, Room 3057 Phone: 505-633-5506

[R] Updating RSQLite fails

2013-10-11 Thread Thibault Helleputte
Hello, Working on an ubuntu 13.04 with a sessionInfo() specified below, I try to update my packages, and RSQLite update consistently fails like this: update.packages(checkBuilt=TRUE, ask=FALSE) Warning: package 'RUnit' in library '/usr/lib/R/site-library' will not be updated trying URL

Re: [R] Using cpquery function from bnlearn package inside loop

2013-10-11 Thread Ryan Morrison
Hi Marco, Thanks for the clarification. For my immediate purposes I think using the likelihood weighting method will suffice. I'm calculating conditional probabilities based on a single instantiation each time I use the function. The evidence I use for instantiation changes for each i+1 in my

Re: [R] Splitting times into groups based on a range of times

2013-10-11 Thread arun
Hi Ben, No problem. Try: df1 - do.call(rbind,lapply(split(df,df$group),function(x) { data.frame(dt2=dt[dt=x[1,1] dtx[length(x),1]],group=x[1,2]) })) id1 - df1[,2][match(as.POSIXct(dt),df1[,1])] id1[is.na(id1)]- 0  identical(id,id1) #[1] TRUE A.K. On Friday, October 11, 2013 5:43 PM,

[R] rjava be-carefuls

2013-10-11 Thread Hurr
I have a java class with routines (and their tests) that I would like to use in R so I don't have to have two copies of important subroutines. I have looked at rjava, but can't grasp it all and don't know what are the important items to observe first so I don't get into too much trouble later. I

Re: [R] labeling abscissa using a function of the plotted scale

2013-10-11 Thread Hurr
Thanks. -- View this message in context: http://r.789695.n4.nabble.com/labeling-abscissa-using-a-function-of-the-plotted-scale-tp4678075p4678103.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] R plotting

2013-10-11 Thread Jim Lemon
On 10/11/2013 11:45 PM, Mubar wrote: Hi I have a question regarding plots in R. I have data from the SP 500 in the format: date close change 1980-01-07 109.92 3.4 I plotted the data with plot(spdata$date, log(spdata$close), type=p) Now I want to ad the colors green and red

[R] using ddply with segmented regression

2013-10-11 Thread Prew, Paul
Hello, I’m unsuccessfully trying to apply piecewise linear regression over each of 22 groups. The data structure of the reproducible toy dataset is below. I’m using the ‘segmented’ package, it worked fine with a data set that containing only one group (“Lot.Run”). $ Cycle :

[R] How do you add the x-bar (mean of x) symbol and show a calculated mean in the title of a histogram?

2013-10-11 Thread Emily Jean Fales
I am trying to get the calculated mean and the symbol of x-bar to show in the title of multiple histograms in R. Here is the code I have for one of the histograms: hist(outcome[,11], main= Heart Attack (expression(bar(x))) = (mean(outcome[,11])), xlab =30-day Death Rate, xlim = c(min(hist_min),

[R] MCP solver

2013-10-11 Thread Maxwell, John McFarland
Hello, I'm trying to find a solver that will work for the mixed complementarity problem (MCP). I've searched the CRAN task view page on optimization and mathematical programming as well as many google searches to no avail. Does anyone know if there is an MCP solver available for R? Thanks

Re: [R] How do you add the x-bar (mean of x) symbol and show a calculated mean in the title of a histogram?

2013-10-11 Thread Rolf Turner
On 10/12/13 11:39, Emily Jean Fales wrote: I am trying to get the calculated mean and the symbol of x-bar to show in the title of multiple histograms in R. Here is the code I have for one of the histograms: hist(outcome[,11], main= Heart Attack (expression(bar(x))) = (mean(outcome[,11])), xlab

Re: [R] matrix values linked to vector index

2013-10-11 Thread Bert Gunter
Your examples are the problem: On Fri, Oct 11, 2013 at 2:43 PM, arun smartpink...@yahoo.com wrote: Seems like a bug in the code: x- c(3,4,1) n- 3 matrix(rep(rep(c(1,0),n),rbind(x,n-x)),nc=n,byr=TRUE) #Error in rep(rep(c(1, 0), n), rbind(x, n - x)) : invalid 'times' argument ## This can't

Re: [R] Singular matrix

2013-10-11 Thread Bert Gunter
You have posted neither code nor your data, contrary to what the posting guide asks. How do you expect anyone to help? Cheers, Bert On Fri, Oct 11, 2013 at 4:54 AM, Aya Anas aa...@feps.edu.eg wrote: Dear all, I am using the DEoptim package. My optimization syntax has three decesion