[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 debería ser solo 1 x 
n .

¿Alguno tiene problemas? Está imposible para trabajar.

Javier Rubén Marcuzzi


[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[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
does what we want in an acceptable time.

Here's a toy example.  We start with a matrix, called "gMat1" (historical
reasons):

> gMat1 <- matrix(c(3, 6, 9, 5, 9, 5), nrow=3)
> print(gMat1)
 [,1] [,2]
[1,]35
[2,]69
[3,]95

The goal is to add the contents of one column of each row to one of two bins
(in general the number of bins equals the number of columns) such that the
minimum number in each bin is maximized.  An example follows.

In the toy example, the possibilities can be enumerated simply:

> allChoices <- expand.grid(rep(list(1:ncol(gMat1)), nrow(gMat1)))
> print(allChoices)
  Var1 Var2 Var3
1111
2211
3121
4221
5112
6212
7122
8222

For example, with the first choice, (1, 1, 1), column 1, hence, bin 1, is
selected for all three rows, giving a result for the two bins of:

18   0

For the second choice, (2, 1, 1), the '2' in the first position selects the
contents of column 2 for bin 2.  The remaining (1, 1) select the (6, 9) in the
first column and assign those to bin 1:

15   5

The result is a set of "binSums" corresponding to the each of the set of
possible choices:

> print(binSums)
 [,1] [,2]
[1,]   180
[2,]   155
[3,]   129
[4,]9   14
[5,]95
[6,]6   10
[7,]3   14
[8,]0   19

Having generated the sums, the goal is to pick the row that has the largest
minimum and map that back to the original choice.  In the toy example, both
rows 3 and 4 satisfy that criterion ('9' is the minimum in each, and '9' is
bigger than the minima in the other 6 rows -- 0, 3, 5, 6).

In the real case there are potentially thousands of rows and columns, so
eye-balling is not an option.  And, in fact, using "expand.grid" isn't even an
option to generate the original choices.

We've tried some ad hoc approaches that seem to work tolerably well.  Here's
one that we *might* have considered, if we *could* have generated the
"allChoices/binSums":

> bsVar <- apply(binSums, 1, var)
> locBestVar <- which(bsVar == min(bsVar))
> allChoices[locBestVar, ]
  Var1 Var2 Var3
3121

But there was a feeling within the group that we didn't have a solid-enough
foundation using the ad hoc approaches.  Hence, we asked for help from an
expert in Operations Research.  He was able to solve a problem of realistic
size in more or less no time at all using the "GAMS" software:

https://www.gams.com/

Unfortunately, GAMS is not free software, and we are hoping to produce an R
package that is freely distributable.  The next suggestion was to use Gurobi:

http://www.gurobi.com/

which is evidently free for academic use but not otherwise.  Better, but still
not perfect.  (And I couldn't use the free version of Gurobi while working
from home, as it didn't consider my home network to be associated with an
academic institution -- which of course it isn't).

Finally, we tried:

Rglpk_solve_LP

from the R package "Rglpk":

https://cran.r-project.org/web/packages/Rglpk/index.html

This satisfied the licensing constraints, but we were unable to produce a
result in a "finite" amount of time.  By this I mean that we ran the Rglpk
software on a problem with 200 rows and 20 columns on the latest Mac Pro with
64GB of memory, and it didn't finish overnight.  A realistic problem would
have at least 1 rows and 50 columns.  (This admittedly might simply have
been a consequence of our unfamiliarity with the package. Suggestions
welcome.) To be clear, this process is not something we'd be doing once in
order to build the package.  This is something an end user would have to do
every time he/she ran our package.

If you've managed to read this far and have any suggestions as to how we might
proceed, please send them my way.  Thanks.

-- Mike

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 Celsius)" on X axis for fig B
3.  "distance (m)" on X axis for fig C
4.  "survival Proba(%) on X axis for fig D

I am wondering how I can create the figures with the above information

Thank you for your help in advance

Sincerely,

Marna

following code and the example I have used.

dat<-structure(list(x = c(0.31, 0.04, 0.1, 0.54, 0.03, 0.86, 0.97,

0.4, 0.62, 0.3, 0.44, 0.51, 0.03, 0.12, 0.79, 0.3, 0.22, 0.66,

0.75, 0.45), y = c(0.38, 0.61, 0.16, 0.06, 0.42, 0.67, 0.85,

0.11, 0.79, 0.21, 0.84, 0.95, 0.3, 0.47, 0.79, 0.2, 0.34, 0.21,

0.62, 0.25), group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,

2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L), .Label = c("A",

"B", "C", "D"), class = "factor")), .Names = c("x", "y", "group"

), class = "data.frame", row.names = c(NA, -20L))


gp<-ggplot(data=dat, aes(x=x, y=y))

Gp<-gp + geom_point(size=1, col="blue")

Gp<-Gp+ stat_smooth(method="lm", level=0.99, col="black",formula=y~poly(x,1
))+

coord_cartesian(ylim=c(0, 1))+theme_bw()+

theme(axis.text.y = element_text(angle = 90, vjust = 0))+

ylab *(*"My Y"*)+*theme(
axis.text.x = element_text(size=8))

Gp+ facet_wrap(~group,ncol=5, scales="free_x")

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)) {
  cat("Time",timeindx,"Condition",condindx,"\n")
  subdat<-kmdf[kmdf$time == timeindx & kmdf$condition == condindx,]
  fit<-lm(value~group,subdat)
  print(summary(fit))
  plot(subdat$group,subdat$value)
  by(subdat$value,subdat$group,mean)
 }
}

Getting elegant output is another matter. Have a look at packages
meant to produce fancier R output.

Jim


On Thu, Sep 1, 2016 at 7:58 AM, Kai Mx  wrote:
> 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 groups (group) under different conditions at different time
> points.
>
> I would now like to perform ANOVA, boxplots and calculate means to compare
> groups for all combinations of conditions and time points with something
> like
>
> fit <- lm(value~group, data=[subset of data with combination of
> condition/timepoint])
> summary (fit)
> p <- ggplot([subset of data with combination of condition/timepoint],
> aes(x= group, y=value)) + geom_boxplot ()
> print (p)
> tapply ([subset of data with combination of condition/timepoint]$value,
> subset of data with combination of condition/timepoint]$group, mean)
>
> How can I loop through these combinations and output the data in an elegant
> way?
>
> Thanks so much!
>
> Best,
>
> Kai
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 in ggplot through "faceting" which you
could read up on and try (I use lattice, not ggplot, to do this sort
of thing, so can't help with code).

3. However, I think your question is mostly statistical in nature
(define "elegant"), and if so, is off topic here. You might therefore
try stats.stackexchange.com instead to get ideas on how to approach
your data, solicit other opinions on whether what you want to do makes
sense (and if not, what else), etc. Or, perhaps better yet, consult a
local statistical resource.

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 Wed, Aug 31, 2016 at 2:58 PM, Kai Mx  wrote:
> 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 groups (group) under different conditions at different time
> points.
>
> I would now like to perform ANOVA, boxplots and calculate means to compare
> groups for all combinations of conditions and time points with something
> like
>
> fit <- lm(value~group, data=[subset of data with combination of
> condition/timepoint])
> summary (fit)
> p <- ggplot([subset of data with combination of condition/timepoint],
> aes(x= group, y=value)) + geom_boxplot ()
> print (p)
> tapply ([subset of data with combination of condition/timepoint]$value,
> subset of data with combination of condition/timepoint]$group, mean)
>
> How can I loop through these combinations and output the data in an elegant
> way?
>
> Thanks so much!
>
> Best,
>
> Kai
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 - as.difftime(1/2 * 1/24, units="days")
  tmp1 - as.difftime(30*60, units="secs")
  tmp1 - as.difftime(1/2 * 1/24 * 1/7, units="weeks")


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Aug 31, 2016 at 2:44 PM, MacQueen, Don  wrote:

> 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 easier to follow.
>
> Base R is more than adequate for this task.
>
> Please get rid of the asterisks in your next email. The just get in the
> way. Learn how to send plain text email, not HTML email. Please.
>
>
>
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 8/31/16, 9:07 AM, "R-help on behalf of Bhaskar Mitra"
> 
> wrote:
>
> >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 ­ 30minutes. Something like this :*
> >
> >
> >*df$Time1   **df$$Time2*
> >
> >
> >*201112312230  **201112312200*
> >
> >*201112312300  **201112312230*
> >
> >*201112312330  **201112312300*
> >
> >*201112312330  *
> >
> >
> >
> >
> >
> >*Based on some of the suggestions available, I have tried this option *
> >
> >
> >
> >*require(zoo)*
> >
> >*df1$Time2  <- lag(df1$Time1, -1, na.pad = TRUE)*
> >
> >*View(df1)*
> >
> >
> >
> >*This does not however give me the desired result. I would appreciate any
> >suggestions/advice in this regard.*
> >
> >
> >*Thanks,*
> >
> >*Bhaskar*
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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 31, 2016 at 2:44 PM, MacQueen, Don  wrote:

> 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 easier to follow.
>
> Base R is more than adequate for this task.
>
> Please get rid of the asterisks in your next email. The just get in the
> way. Learn how to send plain text email, not HTML email. Please.
>
>
>
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 8/31/16, 9:07 AM, "R-help on behalf of Bhaskar Mitra"
> 
> wrote:
>
> >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 ­ 30minutes. Something like this :*
> >
> >
> >*df$Time1   **df$$Time2*
> >
> >
> >*201112312230  **201112312200*
> >
> >*201112312300  **201112312230*
> >
> >*201112312330  **201112312300*
> >
> >*201112312330  *
> >
> >
> >
> >
> >
> >*Based on some of the suggestions available, I have tried this option *
> >
> >
> >
> >*require(zoo)*
> >
> >*df1$Time2  <- lag(df1$Time1, -1, na.pad = TRUE)*
> >
> >*View(df1)*
> >
> >
> >
> >*This does not however give me the desired result. I would appreciate any
> >suggestions/advice in this regard.*
> >
> >
> >*Thanks,*
> >
> >*Bhaskar*
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[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 groups (group) under different conditions at different time
points.

I would now like to perform ANOVA, boxplots and calculate means to compare
groups for all combinations of conditions and time points with something
like

fit <- lm(value~group, data=[subset of data with combination of
condition/timepoint])
summary (fit)
p <- ggplot([subset of data with combination of condition/timepoint],
aes(x= group, y=value)) + geom_boxplot ()
print (p)
tapply ([subset of data with combination of condition/timepoint]$value,
subset of data with combination of condition/timepoint]$group, mean)

How can I loop through these combinations and output the data in an elegant
way?

Thanks so much!

Best,

Kai

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 easier to follow.

Base R is more than adequate for this task.

Please get rid of the asterisks in your next email. The just get in the
way. Learn how to send plain text email, not HTML email. Please.




-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 8/31/16, 9:07 AM, "R-help on behalf of Bhaskar Mitra"

wrote:

>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 ­ 30minutes. Something like this :*
>
>
>*df$Time1   **df$$Time2*
>
>
>*201112312230  **201112312200*
>
>*201112312300  **201112312230*
>
>*201112312330  **201112312300*
>
>*201112312330  *
>
>
>
>
>
>*Based on some of the suggestions available, I have tried this option *
>
>
>
>*require(zoo)*
>
>*df1$Time2  <- lag(df1$Time1, -1, na.pad = TRUE)*
>
>*View(df1)*
>
>
>
>*This does not however give me the desired result. I would appreciate any
>suggestions/advice in this regard.*
>
>
>*Thanks,*
>
>*Bhaskar*
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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 the
> regression model:
>
> model.eq = -0.446078 + 0.267673*x - 0.014577*I(x^2)

## Not what I got with your data. I got:

Coefficients:
(Intercept)x   I(x^2)
   -18.5750   5.0403  -0.2845


I suspect you had some other x,y variables lying around when you
defined your model.

-- Bert

>
> And backtransform it from the logit to the natural scale (using the inverse
> link-function for this case):
>
> model.proj = exp(model.eq)/(1+exp(model.eq))
>
> the plot for model.proj~x is not the same of the plot for fitted(GLM)~x
> (see the output attached).
>
> Why is this happening? Can someone help me?
>
> Regards,
>
> Anderson Eduardo
>
>  --
> Anderson A. Eduardo
> --
> Lattes  | Researcher ID
>  | Google Acadêmico
>  | Site
> 
> --
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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 is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Aug 30, 2016 at 10:20 PM, Mitul Daga  wrote:
> 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 independent variables for its calculation.
>
> Also, it would be great if someone could guide me as to how I can achieve
> the above in R.
>
> --
>
>
> Regards,
> Mitul
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 – 30minutes. Something like this :*


*df$Time1   **df$$Time2*


*201112312230  **201112312200*

*201112312300  **201112312230*

*201112312330  **201112312300*

*201112312330  *





*Based on some of the suggestions available, I have tried this option *



*require(zoo)*

*df1$Time2  <- lag(df1$Time1, -1, na.pad = TRUE)*

*View(df1)*



*This does not however give me the desired result. I would appreciate any
suggestions/advice in this regard.*


*Thanks,*

*Bhaskar*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[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 the
regression model:

model.eq = -0.446078 + 0.267673*x - 0.014577*I(x^2)

And backtransform it from the logit to the natural scale (using the inverse
link-function for this case):

model.proj = exp(model.eq)/(1+exp(model.eq))

the plot for model.proj~x is not the same of the plot for fitted(GLM)~x
(see the output attached).

Why is this happening? Can someone help me?

Regards,

Anderson Eduardo

 --
Anderson A. Eduardo
--
Lattes  | Researcher ID
 | Google Acadêmico
 | Site

--
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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 31, 2016 at 11:54 AM, Uwe Ligges <
lig...@statistik.tu-dortmund.de> wrote:

>
>
> 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,
>>   timevar="Var2",
>>   idvar="Var1",
>>   direction="wide")
>>write.xlsx(wide, file=paste0(i, 'C:/temp/q0',i,'r.xlsx'))
>>
>
>   ^^
> remove the i?
>
> Best,
> Uwe Ligges
>
>
>
>   }
>>
>> All goes well until the write.xlsx, which produces the error
>>
>> Error in .jnew("java/io/FileOutputStream", jFile) :
>>   java.io.FileNotFoundException: 1C:\temp\q01r.xlsx (The filename,
>> directory name, or volume label syntax is incorrect)
>>
>> Among other things, I'm puzzled about why a "1" is getting tacked on to
>> the
>> file path.
>>
>> Any hints?
>>
>> Thanks,
>> Leslie
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 independent variables for its calculation.

Also, it would be great if someone could guide me as to how I can achieve
the above in R.

-- 


Regards,
Mitul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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:

   paste0(tempdir(), filename)

It is specific and temporary to the R session running though, so if
you want to store things across R sessions, tempdir() is not what you
want to use.

/Henrik


On Wed, Aug 31, 2016 at 8:54 AM, Uwe Ligges
 wrote:
>
>
> 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,
>>   timevar="Var2",
>>   idvar="Var1",
>>   direction="wide")
>>write.xlsx(wide, file=paste0(i, 'C:/temp/q0',i,'r.xlsx'))
>
>
>   ^^
> remove the i?
>
> Best,
> Uwe Ligges
>
>
>
>>   }
>>
>> All goes well until the write.xlsx, which produces the error
>>
>> Error in .jnew("java/io/FileOutputStream", jFile) :
>>   java.io.FileNotFoundException: 1C:\temp\q01r.xlsx (The filename,
>> directory name, or volume label syntax is incorrect)
>>
>> Among other things, I'm puzzled about why a "1" is getting tacked on to
>> the
>> file path.
>>
>> Any hints?
>>
>> Thanks,
>> Leslie
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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 Antonio, TX 78245-0549
> Telephone: (210)258-9476
> e-mail: msh...@txbiomed.org
>
>
> On Aug 31, 2016, at 5:37 AM, Shivi Bhatia  wrote:
> >
> > 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 Sharp 
> wrote:
> > Shivi,
> >
> > What package(s) are you using. What functions are you using. How are you
> calling the functions. A reproducible sample has all of the actual code
> needed to create a representative error. There are multiple packages you
> could be using to look at weight of evidence and information value. For
> example, there is a WOE function in the Information package and a woe
> function in the woe package.
> >
> > Mark
> >
> >> On Aug 30, 2016, at 2:15 PM, Shivi Bhatia  wrote:
> >>
> >> Hi Mark,
> >> What i understand, probably when i run the WOE & IV to check
> significant variables that is where i get this error. Thanks for your
> assistance Mark really appreciate i will look into some other measure on
> this.
> >>
> >> On Wed, Aug 31, 2016 at 12:35 AM, Mark Sharp 
> wrote:
> >> Shivi,
> >>
> >> It is likely that William knows what you are trying to do because of
> his considerable experience, but I am not able to figure it out from what
> you have written. You have apparently sent the output from something like
> dput(SFDC[1:50, ]), but I still do not know what you did to get the error.
> >>
> >> I successfully assigned the structure you sent to the name SFDC and
> nothing seems amiss.
> >>
> >>
> >> 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 Antonio, TX 78245-0549
> >> Telephone: (210)258-9476
> >> e-mail: msh...@txbiomed.org
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> > On Aug 30, 2016, at 12:32 PM, Shivi Bhatia 
> wrote:
> >> >
> >> > Hi William/ Mark,
> >> >
> >> > I am using WOE & IV (weight of evidence) reduce the number of
> independent
> >> > vars.
> >> > I have read this data as a csv file.
> >> > reproducible example for your reference please:
> >> >
> >> > structure(list(date = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 14L,
> >> > 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
> >> >
> >> ... truncated
> >> > __
> >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> >> > and provide commented, minimal, self-contained, reproducible code.
> >>
> >> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments
> transmitted, may contain privileged and confidential information and is
> intended solely for the exclusive use of the individual or entity to whom
> it is addressed. If you are not the intended recipient, you are hereby
> notified that any review, dissemination, distribution or copying of this
> e-mail and/or attachments is strictly prohibited. If you have received this
> e-mail in error, please immediately notify the sender stating that this
> transmission was misdirected; return the e-mail to sender; destroy all
> paper copies and delete all electronic copies from your system without
> disclosing its contents.
> >
> > CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments
> transmitted, may contain privileged and confidential information and is
> intended solely for the exclusive use of the individual or entity to whom
> it is addressed. If you are not the intended recipient, you are hereby
> notified that any review, dissemination, distribution or copying of this
> e-mail and/or attachments is strictly prohibited. If you have received this
> e-mail in error, please immediately notify the sender stating that this
> transmission was misdirected; return the e-mail to sender; destroy all
> paper copies and delete all electronic copies from your system without
> disclosing its contents.
> >
>
> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments
> transmitted, may contain privileged and confidential 

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 Antonio, TX 78245-0549
Telephone: (210)258-9476
e-mail: msh...@txbiomed.org


On Aug 31, 2016, at 5:37 AM, Shivi Bhatia  wrote:
>
> 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 Sharp  wrote:
> Shivi,
>
> What package(s) are you using. What functions are you using. How are you 
> calling the functions. A reproducible sample has all of the actual code 
> needed to create a representative error. There are multiple packages you 
> could be using to look at weight of evidence and information value. For 
> example, there is a WOE function in the Information package and a woe 
> function in the woe package.
>
> Mark
>
>> On Aug 30, 2016, at 2:15 PM, Shivi Bhatia  wrote:
>>
>> Hi Mark,
>> What i understand, probably when i run the WOE & IV to check significant 
>> variables that is where i get this error. Thanks for your assistance Mark 
>> really appreciate i will look into some other measure on this.
>>
>> On Wed, Aug 31, 2016 at 12:35 AM, Mark Sharp  wrote:
>> Shivi,
>>
>> It is likely that William knows what you are trying to do because of his 
>> considerable experience, but I am not able to figure it out from what you 
>> have written. You have apparently sent the output from something like 
>> dput(SFDC[1:50, ]), but I still do not know what you did to get the error.
>>
>> I successfully assigned the structure you sent to the name SFDC and nothing 
>> seems amiss.
>>
>>
>> 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 Antonio, TX 78245-0549
>> Telephone: (210)258-9476
>> e-mail: msh...@txbiomed.org
>>
>>
>>
>>
>>
>>
>>
>> > On Aug 30, 2016, at 12:32 PM, Shivi Bhatia  wrote:
>> >
>> > Hi William/ Mark,
>> >
>> > I am using WOE & IV (weight of evidence) reduce the number of independent
>> > vars.
>> > I have read this data as a csv file.
>> > reproducible example for your reference please:
>> >
>> > structure(list(date = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 14L,
>> > 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
>> >
>> ... truncated
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments 
>> transmitted, may contain privileged and confidential information and is 
>> intended solely for the exclusive use of the individual or entity to whom it 
>> is addressed. If you are not the intended recipient, you are hereby notified 
>> that any review, dissemination, distribution or copying of this e-mail 
>> and/or attachments is strictly prohibited. If you have received this e-mail 
>> in error, please immediately notify the sender stating that this 
>> transmission was misdirected; return the e-mail to sender; destroy all paper 
>> copies and delete all electronic copies from your system without disclosing 
>> its contents.
>
> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments 
> transmitted, may contain privileged and confidential information and is 
> intended solely for the exclusive use of the individual or entity to whom it 
> is addressed. If you are not the intended recipient, you are hereby notified 
> that any review, dissemination, distribution or copying of this e-mail and/or 
> attachments is strictly prohibited. If you have received this e-mail in 
> error, please immediately notify the sender stating that this transmission 
> was misdirected; return the e-mail to sender; destroy all paper copies and 
> delete all electronic copies from your system without disclosing its contents.
>

CONFIDENTIALITY NOTICE: This e-mail and any files and/or...{{dropped:10}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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,
  timevar="Var2",
  idvar="Var1",
  direction="wide")
   write.xlsx(wide, file=paste0(i, 'C:/temp/q0',i,'r.xlsx'))


  ^^
remove the i?

Best,
Uwe Ligges



  }

All goes well until the write.xlsx, which produces the error

Error in .jnew("java/io/FileOutputStream", jFile) :
  java.io.FileNotFoundException: 1C:\temp\q01r.xlsx (The filename,
directory name, or volume label syntax is incorrect)

Among other things, I'm puzzled about why a "1" is getting tacked on to the
file path.

Any hints?

Thanks,
Leslie

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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",
  idvar="Var1",
  direction="wide")
   write.xlsx(wide, file=paste0(i, 'C:/temp/q0',i,'r.xlsx'))
  }

All goes well until the write.xlsx, which produces the error

Error in .jnew("java/io/FileOutputStream", jFile) :
  java.io.FileNotFoundException: 1C:\temp\q01r.xlsx (The filename,
directory name, or volume label syntax is incorrect)

Among other things, I'm puzzled about why a "1" is getting tacked on to the
file path.

Any hints?

Thanks,
Leslie

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 in the
*Details* section of help("source"):

 Note that running code via ‘source’ differs in a few respects from
 entering it at the R command line.  Since expressions are not
 executed at the top level, auto-printing is not done.  So you will
 need to include explicit ‘print’ calls for things you want to be
 printed (and remember that this includes plotting by ‘lattice’,
 FAQ Q7.22).

So you need:

print(t(tradeStats('macross')))

if you want the output printed to the console.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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 respects from
 entering it at the R command line.  Since expressions are not
 executed at the top level, auto-printing is not done.  So you will
 need to include explicit ‘print’ calls for things you want to be
 printed (and remember that this includes plotting by ‘lattice’,
 FAQ Q7.22).

So you need:

print(t(tradeStats('macross')))

if you want the output printed to the console.

On Wed, Aug 31, 2016 at 10:26 AM, Doug Edmunds  wrote:
> 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.
>
>> source('~/CodingData/RCode/Quantstrat1/maCross.R')
> [1] "2001-06-27 00:00:00 AAPL 100 @ 1.526312"
> [1] "2001-09-07 00:00:00 AAPL -100 @ 1.13002"
> [1] "2002-01-07 00:00:00 AAPL 100 @ 1.497538"
> [1] "2002-07-10 00:00:00 AAPL -100 @ 1.132636"
> [1] "2003-05-16 00:00:00 AAPL 100 @ 1.22942"
> [1] "2006-06-22 00:00:00 AAPL -100 @ 7.792429"
> [1] "2006-09-26 00:00:00 AAPL 100 @ 10.150561"
> [1] "2008-03-07 00:00:00 AAPL -100 @ 15.988996"
> [1] "2008-05-19 00:00:00 AAPL 100 @ 24.012922"
> [1] "2008-09-24 00:00:00 AAPL -100 @ 16.833895"
> [1] "2009-05-14 00:00:00 AAPL 100 @ 16.080549"
> [1] "2012-12-11 00:00:00 AAPL -100 @ 71.436852"
> [1] "2013-09-11 00:00:00 AAPL 100 @ 62.897826"
> [1] "2015-08-31 00:00:00 AAPL -100 @ 110.399553"
> Time difference of 0.3014359 secs
> [1] "trade blotter portfolio update:"
> Time difference of 0.1732061 secs
>
>>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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.

> source('~/CodingData/RCode/Quantstrat1/maCross.R')
[1] "2001-06-27 00:00:00 AAPL 100 @ 1.526312"
[1] "2001-09-07 00:00:00 AAPL -100 @ 1.13002"
[1] "2002-01-07 00:00:00 AAPL 100 @ 1.497538"
[1] "2002-07-10 00:00:00 AAPL -100 @ 1.132636"
[1] "2003-05-16 00:00:00 AAPL 100 @ 1.22942"
[1] "2006-06-22 00:00:00 AAPL -100 @ 7.792429"
[1] "2006-09-26 00:00:00 AAPL 100 @ 10.150561"
[1] "2008-03-07 00:00:00 AAPL -100 @ 15.988996"
[1] "2008-05-19 00:00:00 AAPL 100 @ 24.012922"
[1] "2008-09-24 00:00:00 AAPL -100 @ 16.833895"
[1] "2009-05-14 00:00:00 AAPL 100 @ 16.080549"
[1] "2012-12-11 00:00:00 AAPL -100 @ 71.436852"
[1] "2013-09-11 00:00:00 AAPL 100 @ 62.897826"
[1] "2015-08-31 00:00:00 AAPL -100 @ 110.399553"
Time difference of 0.3014359 secs
[1] "trade blotter portfolio update:"
Time difference of 0.1732061 secs
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
>   https://r-forge.r-project.org/R/?group_id=316
> install.packages("quantstrat", repos="http://R-Forge.R-project.org;)
>
> 2. I added this line at the end of the R file:
>
> t(tradeStats("macross")
>
> 3. When I enter:
>  source('maCross.R')
>
> at the prompt, it fails to process the added line of code.
>
> Why not?
>
My guess is that you forgot to save the file after you made your
change.  That never happens to me. :P

> --DAE
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 11:11 AM, Duncan Murdoch
 wrote:
> 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
>> install.packages("quantstrat", repos="http://R-Forge.R-project.org;)
>>
>> 2. I added this line at the end of the R file:
>>
>>  t(tradeStats("macross")
>>
>> 3. When I enter:
>>   source('maCross.R')
>>
>> at the prompt, it fails to process the added line of code.
>>
>> Why not?
>
>
> You're missing a closing parenthesis.  I'd have hoped for an error message
> about that, and I get one with a similar example. Not sure why you didn't.
>
>> source('test.R')
> Error in source("test.R") : test.R:4:0: unexpected end of input
> 2: message("bad"
> 3:
>
> Duncan Murdoch
>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
>  https://r-forge.r-project.org/R/?group_id=316
> install.packages("quantstrat", repos="http://R-Forge.R-project.org;)
> 
> 2. I added this line at the end of the R file:
> 
>t(tradeStats("macross")
> 
> 3. When I enter:
> source('maCross.R')
> 
> at the prompt, it fails to process the added line of code.

Have you read the help page? On my machine the default for verbose appears to 
be 

getOption("verbose")
[1] FALSE

> 
> Why not?
> 
> --DAE
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
install.packages("quantstrat", repos="http://R-Forge.R-project.org;)

2. I added this line at the end of the R file:

 t(tradeStats("macross")

3. When I enter:
  source('maCross.R')

at the prompt, it fails to process the added line of code.

Why not?


You're missing a closing parenthesis.  I'd have hoped for an error 
message about that, and I get one with a similar example. Not sure why 
you didn't.


> source('test.R')
Error in source("test.R") : test.R:4:0: unexpected end of input
2: message("bad"
3:

Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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", repos="http://R-Forge.R-project.org;)

2. I added this line at the end of the R file:

t(tradeStats("macross")

3. When I enter:
 source('maCross.R')

at the prompt, it fails to process the added line of code.

Why not?

--DAE

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 rows.

help(WOETable) says that the 'X' argument should be a "categorical variable
stored as factor" but the function does not check that that is true.  You
gave it a numeric (continuous) variable, case_age, and it misbehaved.  You
can turn case_age into a factor with the cut() function.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Aug 31, 2016 at 3:37 AM, Shivi Bhatia  wrote:

> 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 Sharp  wrote:
>
>> Shivi,
>>
>> What package(s) are you using. What functions are you using. How are you
>> calling the functions. A reproducible sample has all of the actual code
>> needed to create a representative error. There are multiple packages you
>> could be using to look at weight of evidence and information value. For
>> example, there is a WOE function in the Information package and a woe
>> function in the woe package.
>>
>> Mark
>>
>> On Aug 30, 2016, at 2:15 PM, Shivi Bhatia  wrote:
>>
>> Hi Mark,
>> What i understand, probably when i run the WOE & IV to check significant
>> variables that is where i get this error. Thanks for your assistance Mark
>> really appreciate i will look into some other measure on this.
>>
>> On Wed, Aug 31, 2016 at 12:35 AM, Mark Sharp  wrote:
>>
>>> Shivi,
>>>
>>> It is likely that William knows what you are trying to do because of his
>>> considerable experience, but I am not able to figure it out from what you
>>> have written. You have apparently sent the output from something like
>>> dput(SFDC[1:50, ]), but I still do not know what you did to get the error.
>>>
>>> I successfully assigned the structure you sent to the name SFDC and
>>> nothing seems amiss.
>>>
>>>
>>> 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 Antonio, TX 78245-0549
>>> Telephone: (210)258-9476
>>> e-mail: msh...@txbiomed.org 
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> > On Aug 30, 2016, at 12:32 PM, Shivi Bhatia 
>>> wrote:
>>> >
>>> > Hi William/ Mark,
>>> >
>>> > I am using WOE & IV (weight of evidence) reduce the number of
>>> independent
>>> > vars.
>>> > I have read this data as a csv file.
>>> > reproducible example for your reference please:
>>> >
>>> > structure(list(date = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 14L,
>>> > 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
>>> >
>>> ... truncated
>>> > __
>>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide http://www.R-project.org
>>> /posting-guide.html 
>>> > and provide commented, minimal, self-contained, reproducible code.
>>>
>>> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments
>>> transmitted, may contain privileged and confidential information and is
>>> intended solely for the exclusive use of the individual or entity to whom
>>> it is addressed. If you are not the intended recipient, you are hereby
>>> notified that any review, dissemination, distribution or copying of this
>>> e-mail and/or attachments is strictly prohibited. If you have received this
>>> e-mail in error, please immediately notify the sender stating that this
>>> transmission was misdirected; return the e-mail to sender; destroy all
>>> paper copies and delete all electronic copies from your system without
>>> disclosing its contents.
>>>
>>
>> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments
>> transmitted, may contain privileged and confidential information and is
>> intended solely for the exclusive use of the individual or entity to whom
>> it is addressed. If you are not the intended recipient, you are hereby
>> notified that any review, dissemination, distribution or copying of this
>> e-mail and/or attachments is strictly prohibited. If you have received this
>> e-mail in error, please immediately notify the sender stating that this
>> transmission was misdirected; return the e-mail to sender; destroy all
>> paper copies and delete all electronic copies from your system without
>> disclosing its contents.
>>
>
>

[[alternative HTML version deleted]]


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 = GoalsGame ~ League, data = SpainGer, tr = 0.2)
>
> Test statistic: NaN (df = NA), p-value = NA
>
> Trimmed mean difference:  NaN
> 95 percent confidence interval:
> NaN NaN
>
>>  yuen(GoalsGame ~ League, tr=0.2, data = droplevels(SpainGer))
> Call:
> yuen(formula = GoalsGame ~ League, data = droplevels(SpainGer),
> tr = 0.2)
>
> Test statistic: 0.8394 (df = 16.17), p-value = 0.4135
>
> Trimmed mean difference:  -0.11494
> 95 percent confidence interval:
> -0.405 0.1751
>
> Complain to WSR2's maintainer.
>> maintainer("WRS2")
> [1] "Patrick Mair "
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Tue, Aug 30, 2016 at 2:07 PM, James Henson  wrote:
>>
>> Greetings R community,
>> Here is a small but perplexing problem with the ‘yuen’ function in the
>> ‘WRS2’ package.
>> I begin with the ‘eurosoccer’ data frame from the ‘WRS2’ package.
>> Then make a subset that contains only two Leagues Spain and Germany
>> (subset data frame is ‘SpainGer’).   The ‘yuen’ function cannot read
>> the data in subset data frame ‘SpainGer’.  My code is below.
>> Thanks you for your help.
>> James F. Henson
>>
>>
>> # Examples from 'Robust Statistical Methods on R Using the WRS2 Package’
>> # Robust t-test, and ANOVA (pages5-13)
>> library(WRS2)
>> data("eurosoccer")
>> class(eurosoccer)
>> print(eurosoccer)
>> library("digest")
>> library("DT")
>> datatable(eurosoccer)
>> str(eurosoccer)
>> # make a subset with only Spain and Germany
>> SpainGer <- subset (eurosoccer, subset = League =="Spain" | League ==
>> "Germany")
>> print(SpainGer)
>> class(SpainGer)
>> str(SpainGer)
>> # The 'yuen' function can not read the data in the subset data.frame
>> "SpainGer"
>> yuen(GoalsGame ~ League, tr=0.2, data = SpainGer)
>> # the 'yuen' function works on the orginioal data.frame
>> yuen(GoalsGame ~ League, tr=0.2, data = eurosoccer)
>> # the 'aov' function reads the data in the subset data.frame "SpainGer"
>> Goals.fit <- aov(GoalsGame ~ League, data = SpainGer)
>> summary(Goals.fit)
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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 package to fit 4L curve.
> I am so confused about the plot.drm function in the drc package.
> Particularly, I am confused about the scale of the xaxis in the plots 
> generated
> using the plot.drm function. See the example below:
>
> ## generate data and fit the model
> dose <- rep(50*2^(-(0:11)),3)
> dose
> d <- 100
> c <- 1
> b <- 1
> e <- 1.6
> y <- rnorm(length(dose))+ c+ (d-c)/(1+exp(b*(log(dose)-log(e
> library(drc)
> mod <- drm(y~dose, fct = LL.4())
> summary(mod)
>
> Now I plot the data and the fitted curve with the plot.drm using the code
> below and get the figure 1 below.
>
>
> ##obtaining figure 1
> plot(mod, type="all",log="x")
>
>
> Next I plot the raw data and add the curve by extracting the estimate of the
> parameters.
>
> ##extract parameters
> para <- mod$fit$par
> bhat<- para[1]
> chat <- para[2]
> dhat <- para[3]
> ehat <- para[4]
>
> ##plot figure 2
> plot(log(dose),y)
> points(log(50*2^(-(0:11))),  chat +
> (dhat-chat)/(1+exp(bhat*(log(50*2^(-(0:11)))-log(ehat, type="l")
>
> My question is regarding the figure 1 generated by the plot.drm.
> The x axis is the not the log scale of the doses. I checked the package 
> manual,
 ^^^
Well I am either missing something obvios but when I tried

plot(mod, type="all",log="x")

I got x axis with log scaling. Actually the result is the same as

plot(mod, type="all")

If you want x axis to be in original range you need to put empty string

plot(mod, type="all",log="")

Cheers
Petr

> it says the default is log base 10. But it is not true in this case.
> Does some have some insight on the correct usage of the plot.drm function.
>
> Thanks much in advance.
>   Hanna
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts 

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 Sharp  wrote:

> Shivi,
>
> What package(s) are you using. What functions are you using. How are you
> calling the functions. A reproducible sample has all of the actual code
> needed to create a representative error. There are multiple packages you
> could be using to look at weight of evidence and information value. For
> example, there is a WOE function in the Information package and a woe
> function in the woe package.
>
> Mark
>
> On Aug 30, 2016, at 2:15 PM, Shivi Bhatia  wrote:
>
> Hi Mark,
> What i understand, probably when i run the WOE & IV to check significant
> variables that is where i get this error. Thanks for your assistance Mark
> really appreciate i will look into some other measure on this.
>
> On Wed, Aug 31, 2016 at 12:35 AM, Mark Sharp  wrote:
>
>> Shivi,
>>
>> It is likely that William knows what you are trying to do because of his
>> considerable experience, but I am not able to figure it out from what you
>> have written. You have apparently sent the output from something like
>> dput(SFDC[1:50, ]), but I still do not know what you did to get the error.
>>
>> I successfully assigned the structure you sent to the name SFDC and
>> nothing seems amiss.
>>
>>
>> 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 Antonio, TX 78245-0549
>> Telephone: (210)258-9476
>> e-mail: msh...@txbiomed.org 
>>
>>
>>
>>
>>
>>
>>
>> > On Aug 30, 2016, at 12:32 PM, Shivi Bhatia 
>> wrote:
>> >
>> > Hi William/ Mark,
>> >
>> > I am using WOE & IV (weight of evidence) reduce the number of
>> independent
>> > vars.
>> > I have read this data as a csv file.
>> > reproducible example for your reference please:
>> >
>> > structure(list(date = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 14L,
>> > 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
>> >
>> ... truncated
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.
>> org/posting-guide.html 
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments
>> transmitted, may contain privileged and confidential information and is
>> intended solely for the exclusive use of the individual or entity to whom
>> it is addressed. If you are not the intended recipient, you are hereby
>> notified that any review, dissemination, distribution or copying of this
>> e-mail and/or attachments is strictly prohibited. If you have received this
>> e-mail in error, please immediately notify the sender stating that this
>> transmission was misdirected; return the e-mail to sender; destroy all
>> paper copies and delete all electronic copies from your system without
>> disclosing its contents.
>>
>
> CONFIDENTIALITY NOTICE: This e-mail and any files and/or attachments
> transmitted, may contain privileged and confidential information and is
> intended solely for the exclusive use of the individual or entity to whom
> it is addressed. If you are not the intended recipient, you are hereby
> notified that any review, dissemination, distribution or copying of this
> e-mail and/or attachments is strictly prohibited. If you have received this
> e-mail in error, please immediately notify the sender stating that this
> transmission was misdirected; return the e-mail to sender; destroy all
> paper copies and delete all electronic copies from your system without
> disclosing its contents.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
efectiva lo adecuado es proporcionar un ejemplo reproducible, esto es,
incluir el código que has utilizado (que lo has hecho) y datos reales que
en este caso es lo que te está faltando.

Saludos,
Carlos Ortega
www.qualityexcellence.es



El 31 de agosto de 2016, 4:11, javier valdes 
escribió:

> Estimados:
> Ayer tratè de usar openair, sin embargo, me durò poco el entusiasmo, ya
> que el primer paso, pasarlas fechas a fomato me arrojo un campo de NA, y la
> verdad es que ya no sè como resolver este problema, ya que lo he intentado
> de muchas formas. Mi fecha  es de la forma dd/mm/ yy.  Las sentencias las
> detallo;
> >meteo$date<-as.POSIXct(strptime(meteo$date, format = "%d/%m/%yy%))
> resultado
> str(meteo$date)
> $ date: POSIXct, format: *NA NA NA *...
> $ temp: num -7.25 -7.96 -6.91 -7.41 -7.07 ...
>
>
> intentè con lubridate y el  resultado es similar, la verdad ya no se que
> hacer con el campo fecha.
>
>
> SAludos a todos y gracias
> *Sent:* Tuesday, August 30, 2016 at 11:12 AM
> *From:* "Carlos Ortega" 
> *To:* "Javier Valdes Cantallopts (DGA)" 
> *Cc:* "r-help-es@r-project.org" 
> *Subject:* Re: [R-es] encontrar fechas saltadas
> ​El considerar las horas, minutos y segundos, depende de lo que quieras
> hacer.
>
> - Puedes incorporarlo en el campo fecha con la función de lubridate:
> "ymd_hms()".
> - Pero luego al crear el vector de referencia para encontrar los
> faltantes tienes que crear un vector secuencia entre la fecha mínima y la
> máxima. Este vector de referencia no tiene dudas de que es entre el max y
> el min con saltos de un día, pero si incluyes horas, minutos y segundos,
> seguramente al crear el vector tendrás que indicarle que los saltos los
> quieres cada día. Vaya, en la solución de tu duda, me he planteado el
> escenario más sencillo.
> - Sobre el tema de los faltantes, indicarte que en openair a la hora
> de hacer los análisis, las funciones ya son capaces de detectar estos
> agujeros y tratarlos como NAs. Al menos en alguos de los
> gráficos recuerdo
> que incluso se indica el % de estos faltantes.
> - Mira en openair por si hubiera alguna función que te diera este
> análisis automáticamente.
> - Con las fechas sin horas, minutos y segundos, obviamente no podrás
> hacer análisis viendo la variabilidad de temperaturas a lo largo del día.
> Pero con los faltantes, tampoco vas a poder hacer mucho más, salvo que
> hagas algún proceso de imputación para recrear el dato.
>
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
> El 30 de agosto de 2016, 15:59, Javier Valdes Cantallopts (DGA) <
> javier.val...@mop.gov.cl> escribió:
>
> > Reinstalaré el programa y comenzaré desde 0
> >
> > Respecto de los campos, el de fecha lo configuré de la siguiente forma;
> >
> > > datos$F1<-as.character(datos$F1)
> > > datos$F1<-as.Date(datos$F1,"%Y-%m-%d")
> >
> > Es correcto? Que pasa con el campo de horas minutos y segundos? Lo debo
> > configurar también? si es así, como lo hago entonces
> >
> > Gracias por lo anterior.
> >
> >
> >
> > *De:* Carlos Ortega [mailto:c...@qualityexcellence.es]
> > *Enviado el:* martes, 30 de agosto de 2016 10:55
> >
> > *Para:* Javier Valdes Cantallopts (DGA)
> > *CC:* r-help-es@r-project.org
> > *Asunto:* Re: [R-es] encontrar fechas saltadas
> >
> >
> >
> > Hola,
> >
> >
> >
> > Usé "textConnection" para poder utilizar tus propios datos y leerlos con
> > read.table.
> >
> > En tu caso, si tienes los datos en un .csv, simplemente tienes que
> leerlos
> > con read.table y utilizar la parte que sigue a "library(lubridate)" en el
> > código que compartí ayer: coger la columna de fechas, leerla con
> > "lubridate" y compararla con el vector de referencia.
> >
> >
> >
> > El error que obtienes no es problema de "lubridate". Antes sí, por el
> tipo
> > de error que incluiste, sí que había un problema con la librería. Ahora
> el
> > problema es otro, es un problema de identificar correctamente el campo
> > fecha.
> >
> >
> >
> > Saludos,
> >
> > Carlos Ortega
> >
> > www.qualityexcellence.es
> >
> >
> >
> > El 30 de agosto de 2016, 15:23, Javier Valdes Cantallopts (DGA) <
> > javier.val...@mop.gov.cl> escribió:
> >
> > SIGO CON EL PROBLEMA con “*lubridate”* después de reiniciar y reinstalar
> >
> >
> >
> > Al hacer “*EL TEXTCONNECTION*” no reconoce ningún campo.
> >
> > 1] date hour T
> >
> > <0 rows> (or 0-length row.names)
> >
> > >
> >
> >
> >
> >
> >
> > *De:* Carlos Ortega [mailto:c...@qualityexcellence.es]
> > *Enviado el:* martes, 30 de agosto de 2016 10:13
> >
> >
> > *Para:* Javier Valdes Cantallopts (DGA)
> > *CC:* r-help-es@r-project.org
> > *Asunto:* Re: [R-es]