Re: [R] paste0 in file path

2016-08-31 Thread Bob Rudis
if the files are supposed to be "1r.xlsx", "2r.xlsx" (etc) then you need to ensure there's a "/" before it. It's better to use `file.path()` to, well, build file paths since it will help account for differences between directory separators on the various operating systems out there. On Wed, Aug

[R] Number of Variables allowed in R

2016-08-31 Thread Mitul Daga
Hi, Can someone please tell me the maximum number of independent variables allowed in R for non linear regression. I have 50 independent variables and want to calculate non linear models to the power of 9 but R is unable to process it beyond to the power of 3 which means its taking maximum 150

Re: [R] paste0 in file path

2016-08-31 Thread Henrik Bengtsson
Also, the recommended way to build file paths is to use file.path(), i.e. file.path("C:", "temp", filename) rather than paste0("C:/temp/", filename) BTW, R provides tempdir() that gives you the temporary directory that R prefers to use on your OS. So, you might want to consider using:

Re: [R] GLM output problem

2016-08-31 Thread Bert Gunter
Inline. -- 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 Wed, Aug 31, 2016 at 10:03 AM, Anderson Eduardo wrote: > Hello > > I

Re: [R] Looping through different groups of variables in models

2016-08-31 Thread Jim Lemon
Hi Kai, Perhaps something like this: kmdf<-data.frame(group=rep(c("exp","cont"),each=50), time=factor(rep(1:5,20)), condition=rep(rep(c("hot","cold"),each=25),2), value=sample(100:200,100)) for(timeindx in levels(kmdf$time)) { for(condindx in levels(kmdf$condition)) {

Re: [R] Time format lagging issue

2016-08-31 Thread William Dunlap via R-help
That tmp1 - 30*60 can also be done as tmp1 - as.difftime(30, units="mins") so you don't have to remember that the internal representation of POSIXct is seconds since the start of 1970. You can choose from the following equivalent expressions. tmp1 - as.difftime(0.5, units="hours") tmp1 -

Re: [R] Time format lagging issue

2016-08-31 Thread MacQueen, Don
Try following this example: mydf <- data.frame(t1=c('201112312230', '201112312330')) tmp1 <- as.POSIXct(mydf$t1, format='%Y%m%d%H%M') tmp2 <- tmp1 - 30*60 mydf$t2 <- format(tmp2, '%Y%m%d%H%M') It can be made into a single line, but I used intermediate variables tmp1 and tmp2 so that it would be

Re: [R] Number of Variables allowed in R

2016-08-31 Thread Bert Gunter
Please show us your code and error messages. I suspect that what you mean by "nonlinear models" may not be what the rest of us mean. And please post in plain text, not HTML, as the latter tends to get mangled on this plai text list. Cheers, Bert Bert Gunter "The trouble with having an open mind

[R] Looping through different groups of variables in models

2016-08-31 Thread Kai Mx
Hi all, I am having trouble wrapping my head around a probably simple issue: After using the reshape package, I have a melted dataframe with the columns group (factor), time (int), condition (factor), value(int). These are experimental data. The data were obtained from different treatment

Re: [R] Time format lagging issue

2016-08-31 Thread jeremiah rounds
Building on Don's example here is something that looks a lot like what I do every day: Sys.setenv(TZ="UTC") mydf <- data.frame(t1=c('2011-12-31-22-30', '2011-12-31-23-30')) library(lubridate) mydf$timestamp = lubridate::ymd_hm(mydf$t1) mydf$t2 = mydf$timestamp - period(minute=30) On Wed, Aug

Re: [R] Looping through different groups of variables in models

2016-08-31 Thread Bert Gunter
Kai: 1. I think that this is a very bad idea, statistically, if I understand you correctly. Generally, your model should incorporate all groups, time points, and conditions together, not individually. 2. But plotting results in "small multiples" -- aka "trellis plots" may be useful. This is done

[R] Time format lagging issue

2016-08-31 Thread Bhaskar Mitra
Hello Everyone, I am trying a shift the time series in a dataframe (df) by 30 minutes . My current format looks something like this : *df$$Time 1* *201112312230* *201112312300* *201112312330* *I am trying to add an additional column of time (df$Time 2) next to Time 1 by lagging it by –

[R] GLM output problem

2016-08-31 Thread Anderson Eduardo
Hello I have started to work with GLM and I am facing the following problem: If I take: y = c(0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0) x = 1:18 model = y ~x + I(x^2) GLM = glm(model, family=binamial(link = logit)) And use the parameters returned by GLM to contruct an equation for

[R] How can I add text in plot and x axis of figures created in ggplot2?

2016-08-31 Thread Marna Wagley
Hi R users, I have created four figures using ggplot2, but I am having trouble to add "r2=XXX, p=XX" value on the upper left in each figure and also unit of X axis of each figure are different. I was also trying to write following : 1. "rainfall (mm/year") on X axix for fig A. 2. "temp (degree

[R] Need advice on linear programming in R

2016-08-31 Thread Michael Hannon
Greetings. A subset of a problem that the group I work with turns out to be an optimization problem, in the sense of linear programming. We've looked at several approaches to this but haven't found one that seems to be the right fit. I'm looking for some guidance in finding an R package that

Re: [R] 0 rows> (or 0-length row.names)

2016-08-31 Thread Shivi Bhatia
Thank you Mark & Dunlap, Will make changes to the variable as suggested. Thank you for your time & assistance. On Wed, Aug 31, 2016 at 9:16 PM, Mark Sharp wrote: > Shivi, > > Looking at the help from ?WOE, ?WOETable, and ?IV, your Y vector in all > cases is to be

Re: [R] 0 rows> (or 0-length row.names)

2016-08-31 Thread Shivi Bhatia
These are the packages i am using: library(woe) #WEIGHT OF EVIDENCE library(InformationValue) #INFORMATION VALUE The syntax used is : WOE(X=SFDC1$log_caseage, Y=SFDC1$survey) WOETable(X=SFDC1$case_age, Y=SFDC1$survey) IV(X=SFDC1$case_age, Y=SFDC1$survey) On Wed, Aug 31, 2016 at 12:54 AM, Mark

Re: [R] plot.drm in "drc" package

2016-08-31 Thread PIKAL Petr
Hi Thanks for code. see in line > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of li li > Sent: Tuesday, August 30, 2016 5:07 PM > To: r-help > Subject: [R] plot.drm in "drc" package > > Hi all, > I am trying to use the drc

Re: [R] yuen function of the WRS2 package

2016-08-31 Thread James Henson
Thanks, The 'droplevels' statement works. Best regards, James Henson On Tue, Aug 30, 2016 at 5:34 PM, William Dunlap wrote: > yuen does not work when there unused levels in the factors given to it. > >> yuen(GoalsGame ~ League, tr=0.2, data = SpainGer) > Call: > yuen(formula

Re: [R] source() does not include added code

2016-08-31 Thread Sarah Goslee
If it doesn't do ANYTHING, you may have failed to save the file. Unless that file contains a function, in which case it isn't supposed to do anything except load the function into your global environment. But it should have thrown an error in that case, as Duncan said. On Wed, Aug 31, 2016 at

Re: [R] source() does not include added code

2016-08-31 Thread Duncan Murdoch
On 31/08/2016 11:05 AM, Doug Edmunds wrote: I am trying to understand why "source" does not process all the code in this R file. 1. I copied maCross.R from the quantstrat/demo directory into my project area. QuantStrat is available at https://r-forge.r-project.org/R/?group_id=316

Re: [R] source() does not include added code

2016-08-31 Thread David Winsemius
> On Aug 31, 2016, at 8:05 AM, Doug Edmunds wrote: > > I am trying to understand why "source" does not process > all the code in this R file. > > 1. I copied maCross.R from the quantstrat/demo directory > into my project area. > > QuantStrat is available at >

Re: [R] source() does not include added code

2016-08-31 Thread Doug Edmunds
1. File is (was) saved. 2. The added code is t(tradeStats("macross")) with 2 )'s. I'd appreciate if someone with QuantStrat installed, to try this and see if they get a different result. My R and RStudio and QuantStrat libraries are all current. I get the chart and this much output. >

Re: [R] source() does not include added code

2016-08-31 Thread Joshua Ulrich
I have quantstrat installed and it works fine for me. If you're asking why the output of t(tradeStats('macross')) isn't being printed, that's because of what's described in the first paragraph in the *Details* section of help("source"): Note that running code via ‘source’ differs in a few

Re: [R] source() does not include added code

2016-08-31 Thread Doug Edmunds
Thank you. That explains it (auto-printing is not done). On 8/31/2016 8:35 AM, Joshua Ulrich wrote: I have quantstrat installed and it works fine for me. If you're asking why the output of t(tradeStats('macross')) isn't being printed, that's because of what's described in the first paragraph

[R] paste0 in file path

2016-08-31 Thread Leslie Rutkowski
Hi, I'm trying to reshape and output 8 simple tables into excel files. This is the code I'm using for (i in 1:8) { count <- table(mydata$ctry, mydata[,paste0("q0",i,"r")]) dat <- as.data.frame(q01count) wide <- reshape(dat, timevar="Var2",

Re: [R] 0 rows> (or 0-length row.names)

2016-08-31 Thread William Dunlap via R-help
I see the printout (not an "error") that you describe on the 2nd example you gave: > t2 <- WOETable(X=SFDC1$case_age, Y=SFDC1$survey) > print(t2) [1] GOODS BADS TOTAL PCT_G PCT_B WOE IV <0 rows> (or 0-length row.names) The result of WOETable is perfectly legal - it is a data.frame with no

[R] source() does not include added code

2016-08-31 Thread Doug Edmunds
I am trying to understand why "source" does not process all the code in this R file. 1. I copied maCross.R from the quantstrat/demo directory into my project area. QuantStrat is available at https://r-forge.r-project.org/R/?group_id=316 install.packages("quantstrat",

Re: [R] source() does not include added code

2016-08-31 Thread Joshua Ulrich
On Wed, Aug 31, 2016 at 10:05 AM, Doug Edmunds wrote: > I am trying to understand why "source" does not process > all the code in this R file. > > 1. I copied maCross.R from the quantstrat/demo directory > into my project area. > > QuantStrat is available at >

Re: [R] paste0 in file path

2016-08-31 Thread Uwe Ligges
On 31.08.2016 17:50, Leslie Rutkowski wrote: Hi, I'm trying to reshape and output 8 simple tables into excel files. This is the code I'm using for (i in 1:8) { count <- table(mydata$ctry, mydata[,paste0("q0",i,"r")]) dat <- as.data.frame(q01count) wide <- reshape(dat,

Re: [R] 0 rows> (or 0-length row.names)

2016-08-31 Thread Mark Sharp
Shivi, Looking at the help from ?WOE, ?WOETable, and ?IV, your Y vector in all cases is to be categorical and it is numeric. Mark R. Mark Sharp, Ph.D. Director of Primate Records Database Southwest National Primate Research Center Texas Biomedical Research Institute P.O. Box 760549 San

[R-es] Microsoft R Open 3.3.1 problema

2016-08-31 Thread javier.ruben.marcuzzi
Estimados Microsoft R Open 3.3.1 me está dando problemas, por ejemplo rbind. Los resultados son extraños, por ejemplo muchas columnas cuándo debería ser una sola sonde tomo solamente la primer columna de varios data.frames, como un arreglo de n x n donde los n son números “grandes”, cuándo

Re: [R-es] fechas NA

2016-08-31 Thread Carlos Ortega
Hola, Si la fecha tiene formato "d/m/y", entonces la función que hay que usar de lubridate es "dmy()". No debiera de darte mayores problemas. Es lo suficientemente versátil para diferenciar formatos de fecha de lo más variados. En estos caso de bloqueo, para que podamos ayudarte de una forma más