[R] stepAIC() that can use new extractAIC() function implementing AICc

2017-06-07 Thread Marc Girondot via R-help
I would like test AICc as a criteria for model selection for a glm using 
stepAIC() from MASS package.


Based on various information available in WEB, stepAIC() use 
extractAIC() to get the criteria used for model selection.


I have created a new extractAIC() function (and extractAIC.glm() and 
extractAIC.lm() ones) that use a new parameter criteria that can be AIC, 
BIC or AICc.


It works as expected using extractAIC() but when I run stepAIC(), the 
first AIC shown in the result is correct, but after it still shows the 
original AIC:


For example (the full code is below) the "Start:  AIC=70.06" is indeed 
the AICc but after, "  47.548 67.874" is the AIC.


> stepAIC(G1, criteria="AICc")
Start:  AIC=70.06
x ~ A + B

   Df DevianceAIC
- A 1   48.506 66.173
  47.548 67.874
- B 1   57.350 68.685

Thanks if you can help me that stepAIC() use always the new extractAIC() 
function.


Marc




library("MASS")
set.seed(1)

df <- data.frame(x=rnorm(15, 15, 2))
for (i in 1:10) {
  df <- cbind(df, matrix(data = rnorm(15, 15, 2), ncol=1, 
dimnames=list(NULL, LETTERS[i])))

}

G1 <- glm(formula = x ~ A + B,
  data=df, family = gaussian(link = "identity"))

extractAIC(G1)
stepAIC(G1)

extractAIC.glm <- function(fit, scale, k = 2, criteria = c("AIC", 
"AICc", "BIC"), ...) {

  criteria <- match.arg(arg=criteria, choice=c("AIC", "AICc", "BIC"))
  AIC <- fit$aic
  edf <- length(fit$coefficients)
  n <- nobs(fit, use.fallback = TRUE)
  if (criteria == "AICc") return(c(edf, AIC + (2*edf*(edf+1))/(n - edf 
-1)))

  if (criteria == "AIC")  return(c(edf, AIC-2*edf + k*edf))
  if (criteria == "BIC")  return(c(edf, AIC -2*edf + log(n)*edf))
}

extractAIC <- extractAIC.lm <- extractAIC.glm

extractAIC(G1, criteria="AIC")
extractAIC(G1, k=log(15))
extractAIC(G1, criteria="BIC")
stats:::extractAIC.glm(G1, k=log(15))
extractAIC(G1, criteria="AICc")

stepAIC(G1)
stepAIC(G1, criteria="AICc")

__
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] Matrix multiplication

2017-06-07 Thread Jeff Newmiller
Fine,  except that you already seen to have a very compact solution if that 
really is what you are looking for. What am I missing? 
-- 
Sent from my phone. Please excuse my brevity.

On June 7, 2017 9:16:48 PM PDT, Steven Yen  wrote:
>OK Thanks. Your response made me think. Here (the last line) is what I
>need:
>
>set.seed(76543211)
>w<-1:10; w
>a<-matrix(rpois(20,2),nrow=10); a
>t(w*a)%*%a
>
>On 6/8/2017 12:09 PM, Jeff Newmiller wrote:
>> Is this a question? You seem to have three possible calculations,
>have already implemented two of them (?) and it is unclear (to me) what
>you think the right answer for any of them is supposed to be.
>> -- Sent from my phone. Please excuse my brevity. On June 7, 2017 
>> 8:50:55 PM PDT, Steven Yen  wrote:
>>> I need to have all elements of a matrix multiplied by a weight
>before
>>> being post-multiplied by itself, as shown in the forst block of
>codes
>>> below. I can also multiply the matrix by the square root of the
>weight
>>> and then take the outer product.
>>>
>>> Actually, what I need is this. Denote each row of the matrix by a
>row
>>> vector as xi and each element of the weighting vector as wi. Then, I
>>> need the sum of wi * t(xi) %*% xi over i.
>>>
>>> Any suggestion for a compact approach would be appreciated.
>>>
>>> set.seed(76543211)
>>> w<-1:10; w
>>> a<-matrix(rpois(20,2),nrow=10); a
>>> b<-a
>>> a<-w*a
>>> t(a)%*%b
>>>
>>> set.seed(76543211)
>>> a<-matrix(rpois(20,2),nrow=10); a
>>> a<-sqrt(w)*a; a
>>> t(a)%*%a

__
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] Matrix multiplication

2017-06-07 Thread Steven Yen
OK Thanks. Your response made me think. Here (the last line) is what I need:

set.seed(76543211)
w<-1:10; w
a<-matrix(rpois(20,2),nrow=10); a
t(w*a)%*%a

On 6/8/2017 12:09 PM, Jeff Newmiller wrote:
> Is this a question? You seem to have three possible calculations, have 
> already implemented two of them (?) and it is unclear (to me) what you think 
> the right answer for any of them is supposed to be.
> -- Sent from my phone. Please excuse my brevity. On June 7, 2017 
> 8:50:55 PM PDT, Steven Yen  wrote:
>> I need to have all elements of a matrix multiplied by a weight before
>> being post-multiplied by itself, as shown in the forst block of codes
>> below. I can also multiply the matrix by the square root of the weight
>> and then take the outer product.
>>
>> Actually, what I need is this. Denote each row of the matrix by a row
>> vector as xi and each element of the weighting vector as wi. Then, I
>> need the sum of wi * t(xi) %*% xi over i.
>>
>> Any suggestion for a compact approach would be appreciated.
>>
>> set.seed(76543211)
>> w<-1:10; w
>> a<-matrix(rpois(20,2),nrow=10); a
>> b<-a
>> a<-w*a
>> t(a)%*%b
>>
>> set.seed(76543211)
>> a<-matrix(rpois(20,2),nrow=10); a
>> a<-sqrt(w)*a; a
>> t(a)%*%a


[[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] Matrix multiplication

2017-06-07 Thread Jeff Newmiller
Is this a question? You seem to have three possible calculations, have already 
implemented two of them (?) and it is unclear (to me) what you think the right 
answer for any of them is supposed to be. 
-- 
Sent from my phone. Please excuse my brevity.

On June 7, 2017 8:50:55 PM PDT, Steven Yen  wrote:
>I need to have all elements of a matrix multiplied by a weight before 
>being post-multiplied by itself, as shown in the forst block of codes 
>below. I can also multiply the matrix by the square root of the weight 
>and then take the outer product.
>
>Actually, what I need is this. Denote each row of the matrix by a row 
>vector as xi and each element of the weighting vector as wi. Then, I 
>need the sum of wi * t(xi) %*% xi over i.
>
>Any suggestion for a compact approach would be appreciated.
>
>set.seed(76543211)
>w<-1:10; w
>a<-matrix(rpois(20,2),nrow=10); a
>b<-a
>a<-w*a
>t(a)%*%b
>
>set.seed(76543211)
>a<-matrix(rpois(20,2),nrow=10); a
>a<-sqrt(w)*a; a
>t(a)%*%a
>
>
>
>
>On 1/4/2017 5:41 PM, Steven Yen wrote:
>> I need help with gls{nlme}.
>> Specifically, I am estimating an equation with AR(1) using 
>> maximum-likelihood. I am not understanding the correlationoption 
>> below. Help appreciated.
>>
>> ===
>> library(nlme)
>> eq1<-log(chnimp)~log(chempi)+log(gas)+log(rtwex)+befile6+
>>  affile6+afdec6
>> reg1<-gls(eq1,data=mydata,correlation=corAR1(),method="ML",verbose=T)
>>
>
>   [[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 series x axis labels

2017-06-07 Thread Felipe Carrillo via R-help
I hope this is the appropriate list for this type of question
Consider the dataset below:I have a column DOC with values from 3 to 101and 
those are the values that I want to show on my x axis, howeverI only get 3, 
3.1, 3.2 and so on. I tried to change those values with xlim(3, 101) but I 
getthe following error:Error in unit(x, default.units) : 'x' and 'units' must 
have length > 0
question: Which argument is needed in the ts() call to make the x axis 
showbreaks every 7 days starting with 3?
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66, 73, 80, 87, 
94, 101), AvgWeight = c(1, 1.67, 2.07, 2.275, 
3.83, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625, 15.2, 16.375, 17.8, 
21.5), PondName = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L), .Label = "Pond01", class = "factor"),     SampleDate = 
structure(c(1182585600, 1183190400, 1183795200,     118440, 1185004800, 
1185609600, 1186214400, 1186819200,     1187424000, 1188028800, 1188633600, 
1189238400, 1189843200,     1190448000, 1191052800), class = c("POSIXct", 
"POSIXt"))), .Names = c("DOC", "AvgWeight", "PondName", "SampleDate"), 
row.names = c(NA, 15L), class = "data.frame")  
wt$SampleDate <- as.Date(wt$SampleDate)  wt
library(forecast)library(ggplot2)pond <- 
ts(wt$AvgWeight,start=3,frequency=52)pond d.arima <- auto.arima(pond)d.forecast 
<- forecast(d.arima, level = c(95), h = 3)d.forecast

autoplot(d.forecast) + xlim(7, 101)Error in unit(x, default.units) : 'x' and 
'units' must have length > 0

Take a look at the attached plot

__
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] Matrix multiplication

2017-06-07 Thread Steven Yen
I need to have all elements of a matrix multiplied by a weight before 
being post-multiplied by itself, as shown in the forst block of codes 
below. I can also multiply the matrix by the square root of the weight 
and then take the outer product.

Actually, what I need is this. Denote each row of the matrix by a row 
vector as xi and each element of the weighting vector as wi. Then, I 
need the sum of wi * t(xi) %*% xi over i.

Any suggestion for a compact approach would be appreciated.

set.seed(76543211)
w<-1:10; w
a<-matrix(rpois(20,2),nrow=10); a
b<-a
a<-w*a
t(a)%*%b

set.seed(76543211)
a<-matrix(rpois(20,2),nrow=10); a
a<-sqrt(w)*a; a
t(a)%*%a




On 1/4/2017 5:41 PM, Steven Yen wrote:
> I need help with gls{nlme}.
> Specifically, I am estimating an equation with AR(1) using 
> maximum-likelihood. I am not understanding the correlationoption 
> below. Help appreciated.
>
> ===
> library(nlme)
> eq1<-log(chnimp)~log(chempi)+log(gas)+log(rtwex)+befile6+
>  affile6+afdec6
> reg1<-gls(eq1,data=mydata,correlation=corAR1(),method="ML",verbose=T)
>

[[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] Another way to count TRUE

2017-06-07 Thread Suharto Anggono Suharto Anggono via R-help
Ah, yes, of course.
tabulate(x, 1)
doesn't work, too, in R 3.4.0. Sorry, I didn't actually try.

I thought of an alternative when TRUE count is 2^31 or more. sum(x) returns NA 
with a warning. sum(as.numeric(x)) works, but requires a quite large memory.


On Thu, 8/6/17, Bert Gunter  wrote:

 Subject: Re: [R] Another way to count TRUE

 Cc: "R-help" 
 Date: Thursday, 8 June, 2017, 1:09 AM

 Bad idea!

 In R3.3.3 it doesn't even work:

 > y1 <- tabulate(x,1)
 Error in tabulate(x, 1) : 'bin' must be
 numeric or a factor

 ## This
 does:
 >  y1 <-
 tabulate(as.integer(x),1)

 But it's more inefficient than just using
 sum(), even discounting the
 as.integer()
 conversion:

 > y1 <-
 tabulate(as.integer(x),1)
 > y2 <-
 sum(x)
 > identical(y1,y2)
 [1] TRUE

 >
 xx <- as.integer(x)
 >
 system.time(replicate(12,tabulate(xx,1)))
  
  user  system elapsed
   2.488   0.003  
 2.491
 >
 system.time(replicate(12,sum(x)))
    user 
 system elapsed
   0.626   0.001   0.627

 Were you simply unaware of
 sum() or was there some other reason for
 your recommendation?

 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, Jun 7, 2017 at 9:33 AM, Suharto Anggono
 Suharto Anggono via
 R-help 
 wrote:
 > To get the number of TRUE in
 logical vector 'x',
 > tabulate(x,
 1)
 > can be used. Actually, it gives
 count of 1, but TRUE as integer is 1. Since R 3.4.0, it
 gives a correct answer, too, when the count is 2^31 or
 more.
 >
 >
 __
 > 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] rmarkdown and font size

2017-06-07 Thread MacQueen, Don
Suppose I have a file (named "tmp.rmd") containing:


---
title: Test
---

```{r example, echo=FALSE, results='asis'}
tmp <- data.frame(a=1:5, b=letters[1:5])
print( knitr::kable(tmp, row.names=FALSE))
```



And I render it with:

rmarkdown::render('tmp.rmd', output_format=c('html_document','pdf_document'))

I get two files:
  tmp.pdf
  tmp.html

Is there a way to control (change or specify) the font size of the table in the 
pdf output?
(or of the entire document, if it can't be changed for just the table)

With my actual data, the table is too wide to fit on a page in the pdf output; 
perhaps if I reduce the font size I can get it to fit.

I would like the html version to still look decent, but I don't care very much 
what happens to its font size.

Thanks!
-Don

-- 
Don MacQueen

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


__
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] Color en líneas (ggplot2)

2017-06-07 Thread Freddy Omar López Quintero
¡Gracias!

Pero al hacerlo R se cae y aparece un "R session aborted"... :-\

¿Habrá alguna manera manual?

2017-06-07 17:53 GMT-04:00 Carlos Ortega :

> Hola,
>
> Para este tipo de ajustes, vaya u otros sobre "ggplot2", este asistente
> ayuda mucho a modificar y adaptar la mayor parte de los elementos que
> forman un gráfico "ggplot"...
>
> https://github.com/calligross/ggthemeassist
>
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
>
> El 7 de junio de 2017, 23:17, Freddy Omar López Quintero <
> freddy.lopez.quint...@gmail.com> escribió:
>
>> ¡Hola!
>>
>> Espero que estén muy bien.
>>
>> Le he dado muchas vueltas a este asunto pero ggplot lleva ganada la
>> batalla.
>>
>> Les consulto. Tengo un conjunto de datos longitudinales y se hicieron
>> varios ajustes sobre ellos.
>>
>> Ahora, intento colocar las predicciones sobre el mismo gráfico con el
>> código adjunto. Mi problema exacto es que quisiera que la leyenda, además
>> del tipo de línea, pudiera mostrar el color de la línea. En este momento,
>> solo los individuos tienen líneas grises continuas, sin embargo la leyenda
>> solo muestra la línea continua, y negra.
>>
>> ¿Alguien podría ayudarme?
>>
>> ¡Gracias!
>>
>> --
>> «Pídeles sus títulos a los que te persiguen, pregúntales
>> cuándo nacieron, diles que te demuestren su existencia.»
>>
>> Rafael Cadenas
>>
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>



-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas

[[alternative HTML version deleted]]

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


Re: [R] [FORGED] Problem related to rowSums

2017-06-07 Thread Rolf Turner


On 07/06/17 21:08, Yogesh Gupta wrote:


Hi...

I have a dataframe with n columns and n rows. I need to find how many rows
contains zero raw read count across all column.


(1) You should probably have a *matrix*, not a data frame.

(2) Have you ever heard of the idea of providing a *reproducible* example?

(3) I *think* the following may be what you want/need:

M <- as.matrix(M) # Where the initial M is your "data frame".
sum(apply(M,1,function(x){isTRUE(all.equal(x,rep(0,length(x}))

Untested, since you did not supply a reproducible example.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] purrr::pmap does not work

2017-06-07 Thread MacQueen, Don
You might try
   matplot()

example:
x <- matrix(rnorm(30), ncol=3)

## plot a dependent variable (1:10) against a bunch of independent variables 
(the three columns of x)
matplot(x , 1:10, type='b')

## or a bunch of dependent variables (the three columns of x) against an 
independent variable (1:10)
matplot(1:10,  x, type='b')

-- 
Don MacQueen

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


On 6/7/17, 7:34 AM, "R-help on behalf of g.maub...@weinwolf.de" 
 wrote:

Hi All,

I try to do a scatterplot for a bunch of variables. I plot a dependent 
variable against a bunch of independent variables:

-- cut --
graphics::plot(
  v01_r01 ~ v08_01_up11,
  data = dataset,
  xlab = "Dependent",
  ylab = "Independent #1"
)

-- cut --

It is tedious to repeat the statement for all independent variables. Found 
an alternative, i.e. :

-- cut --

mu <- list(5, 10, -3)
sigma <- list(1, 5, 10)
n <- list(1, 3, 5)
fargs <- list(mean = mu, sd = sigma, n = n)
fargs %>%
  purrr::pmap(rnorm) %>%
  str()

-- cut --

I tried to use this for may scatterplot task:

-- cut --

var_battery$v08 <- paste0("v08_", formatC(1:8, width = 2, format = "d", 
flag = "0"))
v08_var_labs <- paste0("Label_", 1:8)

dataset <- as.data.frame(
  matrix(
data = sample(
  x = 1:11,
  size = 90,
  replace = TRUE),
nrow = 10,
ncol = 9))
names(dataset) <- c("v01_r01", var_battery$v08)

independent <- as.list(dataset$v01_r01)
dependent <- as.list(dataset[var_battery$v08])

fargs <- list(
  x = independent,
  y = dependent,
  ylab = v08_var_labs)

fargs %>% 
  purrr::pmap(
function(d = dataset, xvalue = x, yvalue = y,
 xlab = "Label for x variable",
 ylab = ylab) {
  graphics::plot(
xvalue ~ yvalue,
data = d,
xlab = xlab,
ylab = ylab)
}
  )

-- cut --

The last statement comes back with

Error: Element 2 has length 8, not 1 or 10.

How can I get it up n running? Do you suggest a better solution for the 
task described?

Kind regards

Georg

__
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-es] Color en líneas (ggplot2)

2017-06-07 Thread Carlos Ortega
Hola,

Para este tipo de ajustes, vaya u otros sobre "ggplot2", este asistente
ayuda mucho a modificar y adaptar la mayor parte de los elementos que
forman un gráfico "ggplot"...

https://github.com/calligross/ggthemeassist

Saludos,
Carlos Ortega
www.qualityexcellence.es


El 7 de junio de 2017, 23:17, Freddy Omar López Quintero <
freddy.lopez.quint...@gmail.com> escribió:

> ¡Hola!
>
> Espero que estén muy bien.
>
> Le he dado muchas vueltas a este asunto pero ggplot lleva ganada la
> batalla.
>
> Les consulto. Tengo un conjunto de datos longitudinales y se hicieron
> varios ajustes sobre ellos.
>
> Ahora, intento colocar las predicciones sobre el mismo gráfico con el
> código adjunto. Mi problema exacto es que quisiera que la leyenda, además
> del tipo de línea, pudiera mostrar el color de la línea. En este momento,
> solo los individuos tienen líneas grises continuas, sin embargo la leyenda
> solo muestra la línea continua, y negra.
>
> ¿Alguien podría ayudarme?
>
> ¡Gracias!
>
> --
> «Pídeles sus títulos a los que te persiguen, pregúntales
> cuándo nacieron, diles que te demuestren su existencia.»
>
> Rafael Cadenas
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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


Re: [R-es] OPINIONES comparacion personal de R en linux y windows

2017-06-07 Thread Freddy Omar López Quintero
2017-06-07 10:33 GMT-04:00 Javier Valdes Cantallopts (DGA) <
javier.val...@mop.gov.cl>:

> No sé qué opinan?


​Con R propiamente, yo creo que no encuentro mayor diferencia puesto que
uso RStudio y en general es la misma experiencia de usuario (con conjuntos
de datos bastante modestos), pero las diferencias me vienen cuando hay
herramientas o paquetes que hay que compilar o quiero trabajar más rápido
con la consola (tools>shell). Desde windows ignoro muchas cosas,
simplemente, y no les puedo sacar provecho. ¿Pero es esto un problema de R
o del usuario (yo)? :D

¡Saludos!​



-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas

[[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-es] Color en líneas (ggplot2)

2017-06-07 Thread Freddy Omar López Quintero
¡Hola!

Espero que estén muy bien.

Le he dado muchas vueltas a este asunto pero ggplot lleva ganada la batalla.

Les consulto. Tengo un conjunto de datos longitudinales y se hicieron
varios ajustes sobre ellos.

Ahora, intento colocar las predicciones sobre el mismo gráfico con el
código adjunto. Mi problema exacto es que quisiera que la leyenda, además
del tipo de línea, pudiera mostrar el color de la línea. En este momento,
solo los individuos tienen líneas grises continuas, sin embargo la leyenda
solo muestra la línea continua, y negra.

¿Alguien podría ayudarme?

¡Gracias!

-- 
«Pídeles sus títulos a los que te persiguen, pregúntales
cuándo nacieron, diles que te demuestren su existencia.»

Rafael Cadenas
parametros<-structure(list(X = 1:51, X.1 = c(93.6443045794884, 0.274514923404001, 
-0.618328826511992, 6.35004789645277, 80.4486680704678, 0.398671210849383, 
-0.36311742015548, 1.03735833192979, 123.433079354653, 0.0102818971461322, 
0.0737926758635394, 0.667956051190706, 0.166023046221436, 0.169835680441718, 
92.8727273392054, 0.280548440675895, -0.591788496784862, 6.34069803543858, 
0.00396918686734812, 0.003873777667181, 0.00397871442819185, 
8.62002235763456e-05, 0.000177982071249404, -7.20746737162845e-05, 
83.6179497099678, 0.37456999758485, -0.395741042334919, 1.35275234352414, 
9.19666589730974, 0.049465436765756, 0.262280809304406, 90.4949487031123, 
0.309798683863988, -0.455118957698306, 4.59410797144556, 6.70214183242127, 
2.55241318343321, 0.0040969271690877, 0.00406057805801237, 0.00408729052989319, 
-0.0001337437288817, -9.02974739023956e-05, -4.79605394640869e-05, 
84.1324991529296, 0.371924990227874, -0.394364833252805, 12.2942829860544, 
15.1762245140945, 9.39329446699581, 15.2777604868252, 1.12559789523233
), X2.5. = c(89.8075680676307, 0.24062495144807, -0.77721816380053, 
6.10328321127024, 82.0970864037386, 0.41628213216484, -0.316459851584057, 
1.10925276972414, 151.676569972767, 0.0136445644723838, 0.0964128077066584, 
0.566110617222703, 0.0719498743654596, 0.288082253061202, 88.7480021052549, 
0.248299724724991, -0.738083589646706, 6.13608196789711, 0.0033131765251182, 
0.00331992605912848, 0.00330510660938651, -0.000385787681769791, 
-0.000279920354928013, -0.000648710689208116, 82.1887422364474, 
0.361429662565472, -0.444308809159175, 1.26215061383911, 8.34267614185542, 
0.0373843251863912, 0.231315025808771, 88.4278512805936, 0.28043065708031, 
-0.576980216992324, 3.72759905121779, 2.51202639984708, 2.50514689364638, 
0.00352687109447984, 0.00343525744154969, 0.00338207649947237, 
-0.000660750333682392, -0.000468516920705751, -0.000454316005673436, 
82.6462425607854, 0.359068069451452, -0.441167465031998, 8.62796498220036, 
10.1227010680911, 5.12805200272888, 9.26381073259622, 1.01759087592246
), X97.5. = c(98.3877041960296, 0.309426923468285, -0.477640818649688, 
6.61776093280683, 83.7455047370094, 0.433893053480296, -0.269802283012633, 
1.18612987361049, 186.382629348511, 0.0181069832731281, 0.12596683046256, 
0.447134504827384, 0.0136480105954702, 0.411703462075963, 97.0714933511228, 
0.3231018418536, -0.440032765543431, 6.5910793206374, 0.00458902518252994, 
0.00459529042640684, 0.00459033307804952, 0.000433596593495416, 
0.000469433582168282, 0.000280674306287311, 84.9503686450073, 
0.388274472592534, -0.348087133287464, 1.45030802655994, 10.2002714211677, 
0.0609950356940555, 0.299171819309348, 93.548966629373, 0.333696770103566, 
-0.363375587398017, 5.0879499410823, 9.76329673573814, 2.7431077428306, 
0.00474466476593635, 0.0046929951241291, 0.00478980004233669, 
0.000449783679712311, 0.000413896440866447, 0.000443348858707374, 
85.4751963528418, 0.384064677811932, -0.348277751176412, 17.4449169639356, 
22.4575183191046, 16.3379448906165, 24.2774760534726, 1.23218199233448
)), .Names = c("X", "X.1", "X2.5.", "X97.5."), row.names = c(NA, 
-51L), class = "data.frame")

dd<-structure(list(x = c(1L, 2L, 3L, 4L, 5L, 3L, 4L, 5L, 6L, 1L, 
2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 
5L, 6L, 1L, 4L, 5L, 1L, 2L, 3L, 5L, 3L, 4L, 5L, 4L, 1L, 2L, 3L, 
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 
5L, 6L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 2L, 3L, 
4L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 1L, 2L, 4L, 1L, 3L, 4L), y = c(28.032936, 47.78408, 
59.070448, 66.124428, 71.767612, 59.6954225, 66.54971, 73.4039975, 
78.8874275, 30.3693767567568, 47.0061689189189, 61.0834545945946, 
66.2024675675676, 71.3214805405405, 76.4404935135135, 31.292405333, 
44.719304, 55.460822933, 66.202341867, 74.258481067, 
79.629240533, 82.314620267, 32.530764556962, 44.8980734177215, 
57.265382278481, 65.9224984810127, 70.8694220253165, 75.8163455696203, 
29.5625964864865, 72.2403994594595, 77.4134664864865, 44.697832238806, 
60.9025955223881, 72.6878779104478, 80.0536794029851, 60.0298032876712, 
67.7313161643836, 74.1492435616438, 63.8927616901408, 41.41994, 
53.44556, 

[R] Time series axis breaks

2017-06-07 Thread Felipe Carrillo via R-help
I hope this is the appropriate list for this type of question
Consider the dataset below:I have a column DOC with values from 3 to 101and 
those are the values that I want to show on my x axis, howeverI only get 3, 
3.1, 3.2 and so on. I tried to change those values with xlim(3, 101) but I 
getthe following error:Error in unit(x, default.units) : 'x' and 'units' must 
have length > 0
question: Which argument is needed in the ts() call to make the x axis 
showbreaks every 7 days starting with 3?
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66, 73, 80, 87, 
94, 101), AvgWeight = c(1, 1.67, 2.07, 2.275, 
3.83, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625, 15.2, 16.375, 17.8, 
21.5), PondName = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L), .Label = "Pond01", class = "factor"),     SampleDate = 
structure(c(1182585600, 1183190400, 1183795200,     118440, 1185004800, 
1185609600, 1186214400, 1186819200,     1187424000, 1188028800, 1188633600, 
1189238400, 1189843200,     1190448000, 1191052800), class = c("POSIXct", 
"POSIXt"))), .Names = c("DOC", "AvgWeight", "PondName", "SampleDate"), 
row.names = c(NA, 15L), class = "data.frame")  
wt$SampleDate <- as.Date(wt$SampleDate)  wt
library(forecast)library(ggplot2)pond <- 
ts(wt$AvgWeight,start=3,frequency=52)pond d.arima <- auto.arima(pond)d.forecast 
<- forecast(d.arima, level = c(95), h = 3)d.forecast

autoplot(d.forecast) + xlim(7, 101)Error in unit(x, default.units) : 'x' and 
'units' must have length > 0

Take a look at the attached plot
__
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] Tablas en R

2017-06-07 Thread doblett
Buenas noches a todos,
Muchísimas gracias por la ayuda y por las recomendaciones. Sobre los
paquetes "ReporteRs" y "tangram" nunca había oído nada sobre ellos pero lo
que he mirado por encima tiene muy buena pinta. Me ponga manos a la obra.


Saludos.




El 7 de junio de 2017, 9:54, Carlos Ortega 
escribió:

> Hola,
>
> Hace poco vi este nuevo paquete "tangram", que busca aplicar el concepto
> de "Grammar of Graphics" a las tablas...
> La viñeta es muy ilustrativa de todo lo que se puede hacer:
>
> https://cloud.r-project.org/web/packages/tangram/vignettes/example.html
>
> Gracias,
> Carlos Ortega
> www.qualityexcellence.es
>
> El 7 de junio de 2017, 9:15, 
> escribió:
>
>> Hola doblett.
>>
>> No sé si te lo han comentado ya, pero yo le echaría un ojo al paquete
>> ReporteRs.
>>
>> Un saludo,
>> Miguel.
>>
>>
>>
>>
>> El 06/06/2017 a las 16:00, doblett escribió:
>> > Muchas gracias a todos por las sugerencias y por la rápida respuesta.
>> > Mi impresión es que no tenemos una solución cómoda para este tema y al
>> > menos en mi día a día es muy útil.
>> >
>> > - Tables, funciona muy bien con latex y se pueden llegar a hacer
>> tablas
>> > muy completas. El problema no está en la tabla sino en el formato de
>> > documento. Si en la oficina le doy el informe a mi jefe en latex se
>> va a
>> > quedar a cuadros. Necesitamos volcar la tabla a un documento que
>> > posteriormente se pueda editar para incorporar texto.
>> > - Stargazer, cuenta con similares prestaciones que tables y con las
>> > similares carencias en cuanto al formato de salida del documento.
>> >
>> > Por lo que veo, salvo que alguien tenga otra forma de trabajar esto, lo
>> > tenemos complicado. Sacar las tablas por pantalla no es tan difícil, el
>> > problema lo tenemos para llevárnoslas a un documento fácilmente editable
>> > tipo ODF. R markdown da muchas facilidades cuando se trata de texto,
>> > podemos obtener el mismo documento en tres formatos diferentes (HTML,
>> PDF y
>> > ODF) casi sin esfuerzo, pero con tablas la cosa se complica.
>> >
>> > Si no es posible crear las tablas "al vuelo" en formatos "editables a
>> > posteriori" y alguien tiene una forma de trabajar que pueda ser útil,
>> > también será bienvenida.
>> >
>> >
>> > Saludos.
>> > doblett.
>> >
>>
>> 
>>
>> Nota: A información contida nesta mensaxe e os seus posibles documentos
>> adxuntos é privada e confidencial e está dirixida únicamente ó seu
>> destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe,
>> por favor elimínea. A distribución ou copia desta mensaxe non está
>> autorizada.
>>
>> Nota: La información contenida en este mensaje y sus posibles documentos
>> adjuntos es privada y confidencial y está dirigida únicamente a su
>> destinatario/a. Si usted no es el/la destinatario/a original de este
>> mensaje, por favor elimínelo. La distribución o copia de este mensaje no
>> está autorizada.
>>
>> See more languages: http://www.sergas.es/aviso-confidencialidad
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>

[[alternative HTML version deleted]]

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


Re: [R] Determining which.max() within groups

2017-06-07 Thread Charles C. Berry

On Tue, 6 Jun 2017, Morway, Eric wrote:


Using the dataset below, I got close to what I'm after, but not quite all
the way there.  Any suggestions appreciated:

Daily <- read.table(textConnection(" Date  wyrQ
1911-04-01 1990 4.530695
1911-04-02 1990 4.700596
1911-04-03 1990 4.898814
1911-04-04 1990 5.097032
1911-04-05 1991 5.295250
1911-04-06 1991 6.569508
1911-04-07 1991 5.861587
1911-04-08 1991 5.153666
1911-04-09 1992 4.445745
1911-04-10 1992 3.737824
1911-04-11 1992 3.001586
1911-04-12 1992 3.001586
1911-04-13 1993 2.350298
1911-04-14 1993 2.661784
1911-04-16 1993 3.001586
1911-04-17 1993 2.661784
1911-04-19 1994 2.661784
1911-04-28 1994 3.369705
1911-04-29 1994 3.001586
1911-05-20 1994 2.661784"),header=TRUE)

aggregate(Q ~ wyr, data = Daily, which.max)

# gives:
#wyr Q
# 1 1990 4
# 2 1991 2
# 3 1992 1
# 4 1993 3
# 5 1994 2

I can 'see' that it is returning the which.max() relative to each
grouping.  Is there a way to instead return the absolute position (row) of
the max value within each group.  i.e.:

# Would instead like to have
# wyr  Q
# 1  1990  4
# 2  1991  6
# 3  1992  9
# 4  1993  15
# 5  1994  18

The icing on the cake would be to get the Julien Day corresponding to the
date on which each year's maximum occurs?




Like this:


which.max.by.wyr <- with(Daily, which( ave( Q, wyr, FUN=max) == Q))
cbind( Daily[ which.max.by.wyr, ], index=which.max.by.wyr )

 Date  wyrQ index
4  1911-04-04 1990 5.097032 4
6  1911-04-06 1991 6.569508 6
9  1911-04-09 1992 4.445745 9
15 1911-04-16 1993 3.00158615
18 1911-04-28 1994 3.36970518

If there are ties in Q and you do not want more than one max value listed, 
you can add a litle fuzz to randomly pick one. i.e.



fuzz <- runif(nrow(Daily), 0, 1e-10)
which.max.by.wyr <- with(Daily, which(ave(Q+fuzz,wyr,FUN=max)==Q+fuzz))



If you want the first tied value, then sort fuzz before determining 
which.max.by.wyr.


HTH,

Chuck

__
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] Another way to count TRUE

2017-06-07 Thread Bert Gunter
Bad idea!

In R3.3.3 it doesn't even work:

> y1 <- tabulate(x,1)
Error in tabulate(x, 1) : 'bin' must be numeric or a factor

## This does:
>  y1 <- tabulate(as.integer(x),1)

But it's more inefficient than just using sum(), even discounting the
as.integer() conversion:

> y1 <- tabulate(as.integer(x),1)
> y2 <- sum(x)
> identical(y1,y2)
[1] TRUE

> xx <- as.integer(x)
> system.time(replicate(12,tabulate(xx,1)))
   user  system elapsed
  2.488   0.003   2.491
> system.time(replicate(12,sum(x)))
   user  system elapsed
  0.626   0.001   0.627

Were you simply unaware of sum() or was there some other reason for
your recommendation?

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, Jun 7, 2017 at 9:33 AM, Suharto Anggono Suharto Anggono via
R-help  wrote:
> To get the number of TRUE in logical vector 'x',
> tabulate(x, 1)
> can be used. Actually, it gives count of 1, but TRUE as integer is 1. Since R 
> 3.4.0, it gives a correct answer, too, when the count is 2^31 or more.
>
> __
> 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-es] OPINIONES comparacion personal de R en linux y windows

2017-06-07 Thread Javier Valdes Cantallopts (DGA)
Buena la idea de hacer una especie de diagnóstico entre las distribuciones, a 
modo de información entre los que contribuimos de alguna manera al foro.
En mi caso, en ubuntu y fedora anda muy bien.
Podría probar con Opensuse..

[Descripción: FIRMA3]

De: Javier Nieto [mailto:mac_j...@hotmail.com]
Enviado el: miércoles, 07 de junio de 2017 12:42
Para: Javier Marcuzzi; Javier Valdes Cantallopts (DGA); Carlos Ortega 
(c...@qualityexcellence.es)
CC: r-help-es@r-project.org
Asunto: Re: OPINIONES comparacion personal de R en linux y windows


Me parece que R funciona mejor en Linux que en Windows, en mac ni idea. Un buen 
ejercicio sería hacer lo que plantea Marcuzzi Linux con Linux, en lo personal 
lo he probrado en Ubuntu, Centos, Oracle Linux y Fedora y no he sentido 
diferencias significativas, tal vez porque han sido tareas diferentes. Sería 
que bueno hacer un benchmark  y ver que resultados salen o si alguien ya lo ha 
realizado tal vez pueda compartirlo.





Saludos


De: R-help-es  en nombre de Javier Marcuzzi 

Enviado: miércoles, 7 de junio de 2017 11:27:22 a. m.
Para: Javier Valdes Cantallopts (DGA); Carlos Ortega (c...@qualityexcellence.es)
CC: r-help-es@r-project.org
Asunto: Re: [R-es] OPINIONES comparacion personal de R en linux y windows

Estimado Javier Valdes Cantallopts

Hace mucho que no uso R en Linux ni en mac, como experiencia de usuario Windows 
no es tan cómodo, aunque realice lo mismo, sin embargo es algo muy personal que 
tiene más que ver con la interfaz gráfica y su funcionamiento, aunque R en 
Ubuntu me parecía desafortunado al lado de R en SUSE.

Creo que debe hacer diferencias en la compilación (o el compilador). Pero si 
usted puede intente realizar el mismo trabajo con (no recuerdo justo el 
comando) para marcar el tiempo que demora.

Javier Rubén Marcuzzi

De: Javier Valdes Cantallopts (DGA)
Enviado: miércoles, 7 de junio de 2017 11:33
Para: Carlos Ortega 
(c...@qualityexcellence.es)
CC: r-help-es@r-project.org
Asunto: [R-es] OPINIONES comparacion personal de R en linux y windows

Hola estimados.
Les quería plantear un tema que tiene que ver con las plataformas en donde 
hacemos correr nuestro R.
En mi caso, tengo instalado R en mi oficina(Windows) y en mi casa(Linux) y la 
verdad, después de probar algunas funciones gráficas, claramente R sobre Linux 
me entrega resultados más satisfactorios, no solo por la rapidez, sino porque 
también, Linux al parecer, interpreta mejor las instrucciones de R.
R corre mucho más fluidamente sobre mi notebook que ya cumplirá 11 años 
conmigo, que sobre la estación de trabajo de última generación con Windows.
No sé qué opinan?


[Descripción: FIRMA3]




CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los archivos 
adjuntos es de carácter confidencial o privilegiada y está destinada al uso 
exclusivo del emisor y/o de la persona o entidad a quien va dirigida. Si usted 
no es el destinatario, cualquier almacenamiento, divulgación, distribución o 
copia de esta información está estrictamente prohibido y sancionado por la ley. 
Si recibió este mensaje por error, por favor infórmenos inmediatamente 
respondiendo este mismo mensaje y borre todos los archivos adjuntos. Gracias.

CONFIDENTIAL NOTE: The information transmitted in this message and/or 
attachments is confidential and/or privileged and is intented only for use of 
the person or entity to whom it is addressed. If you are not the intended 
recipient, any retention, dissemination, distribution or copy of this 
information is strictly prohibited and sanctioned by law. If you received this 
message in error, please reply us this same message and delete this message and 
all attachments. Thank you.




CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los archivos 
adjuntos es de carácter confidencial o privilegiada y está destinada al uso 
exclusivo del emisor y/o de la persona o entidad a quien va dirigida. Si usted 
no es el destinatario, cualquier almacenamiento, divulgación, distribución o 
copia de esta información está estrictamente prohibido y sancionado por la ley. 
Si recibió este mensaje por error, por favor infórmenos inmediatamente 
respondiendo este mismo mensaje y borre todos los archivos adjuntos. Gracias.

CONFIDENTIAL NOTE: The information transmitted in this message and/or 
attachments is confidential and/or privileged and is intented only for use of 
the person or entity to whom it is addressed. If you are not the intended 
recipient, any retention, dissemination, distribution or copy of this 
information is strictly prohibited and sanctioned by law. If you received this 
message in error, please reply us this same message and delete this message and 
all attachments. Thank you.

[R] Another way to count TRUE

2017-06-07 Thread Suharto Anggono Suharto Anggono via R-help
To get the number of TRUE in logical vector 'x',
tabulate(x, 1)
can be used. Actually, it gives count of 1, but TRUE as integer is 1. Since R 
3.4.0, it gives a correct answer, too, when the count is 2^31 or more.

__
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] Problem related to rowSums

2017-06-07 Thread Jeff Newmiller

I don't understand "zero raw read count across all column".

Please read the Posting Guide (mentioned below) which points out that this 
is a plain text mailing list (your email gets damaged to varying degrees 
if you don't set your sending format to plain text), and you need to make 
your example reproducible (look up the package "reprex") to clearly 
communicate your problem.


On Wed, 7 Jun 2017, Yogesh Gupta wrote:


Hi...

I have a dataframe with n columns and n rows. I need to find how many rows
contains zero raw read count across all column.

Thanks

--
*Yogesh Gupta*
*Postdoctoral Researcher*
*Department of Biological Science*
*Seoul National University*
*Seoul, South Korea*

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] error while opening vignette DESeq2

2017-06-07 Thread Jeff Newmiller
Sounds like your operating system does not have a default PDF viewer, or 
does not have X-windows installed.


On Wed, 7 Jun 2017, Yogesh Gupta wrote:


Hi ,

I am trying to open vignette DESeq2 but getting below error:


vignette("DESeq2")
START /usr/bin/evince "/usr/lib64/R/library/DESeq2/doc/DESeq2.pdf"

Cannot parse arguments: Cannot open display:
xdg-open: no method available for opening
'/usr/lib64/R/library/DESeq2/doc/DESeq2.pdf'

--
*Yogesh Gupta*
*Postdoctoral Researcher*
*Department of Biological Science*
*Seoul National University*
*Seoul, South Korea*

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] purrr::pmap does not work

2017-06-07 Thread Jeff Newmiller
A) You are not making reproducible examples. Try out the package "reprex" 
to help you recognize when you are forgetting details.


B) I suspect your problem is not understanding formulas. The first thing 
that comes to my mind is using a version of the plot function that does 
not use formulas for the input data specification. E.g.


graphics::plot(
  dataset[[ xvarname ]],
  dataset[[ yvarname ]],
  xlab = "Dependent",
  ylab = "Independent #1"
)

On Wed, 7 Jun 2017, g.maub...@weinwolf.de wrote:


Hi All,

I try to do a scatterplot for a bunch of variables. I plot a dependent
variable against a bunch of independent variables:

-- cut --
graphics::plot(
 v01_r01 ~ v08_01_up11,
 data = dataset,
 xlab = "Dependent",
 ylab = "Independent #1"
)

-- cut --

It is tedious to repeat the statement for all independent variables. Found
an alternative, i.e. :

-- cut --

mu <- list(5, 10, -3)
sigma <- list(1, 5, 10)
n <- list(1, 3, 5)
fargs <- list(mean = mu, sd = sigma, n = n)
fargs %>%
 purrr::pmap(rnorm) %>%
 str()

-- cut --

I tried to use this for may scatterplot task:

-- cut --

var_battery$v08 <- paste0("v08_", formatC(1:8, width = 2, format = "d",
flag = "0"))
v08_var_labs <- paste0("Label_", 1:8)

dataset <- as.data.frame(
 matrix(
   data = sample(
 x = 1:11,
 size = 90,
 replace = TRUE),
   nrow = 10,
   ncol = 9))
names(dataset) <- c("v01_r01", var_battery$v08)

independent <- as.list(dataset$v01_r01)
dependent <- as.list(dataset[var_battery$v08])

fargs <- list(
 x = independent,
 y = dependent,
 ylab = v08_var_labs)

fargs %>%
 purrr::pmap(
   function(d = dataset, xvalue = x, yvalue = y,
xlab = "Label for x variable",
ylab = ylab) {
 graphics::plot(
   xvalue ~ yvalue,
   data = d,
   xlab = xlab,
   ylab = ylab)
   }
 )

-- cut --

The last statement comes back with

Error: Element 2 has length 8, not 1 or 10.

How can I get it up n running? Do you suggest a better solution for the
task described?

Kind regards

Georg

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Adding zeros in each dimension of an array

2017-06-07 Thread li li
Thanks! That is the method I am using now but I was checking whether there
is a simpler option. I will look into the abind package too.
   Hanna

2017-06-07 12:25 GMT-04:00 Jeff Newmiller :

> Please read
> https://www.lifewire.com/how-to-send-a-message-in-plain-text
> -from-gmail-1171963
>
> Re your question: easy is in the eye of the beholder.
>
> a <- array( 1:12, dim = c( 2, 2, 3 ) )
> b <- array( 0, dim = dim( a ) + 1 )
> b[ 1:2, 1:2, 1:3 ] <- a
>
> If you want to do a lot of this, it could be wrapped for convenience
> though implementing that last expression without hardcoding the sequences
> may not be obvious:
>
> expandArray <- function( a ) {
>   b <- array( 0, dim = dim( a ) + 1 )
>   do.call( `[<-`, c( list( b ), lapply( dim( a ), seq.int ), list( a ) ) )
> }
> expandArray( a )
>
>
> On Wed, 7 Jun 2017, li li wrote:
>
> For a data frame, we can add an additional row or column easily. For
>> example, we can add an additional row of zero and an additional row of
>> column as follows.
>>
>> Is there an easy and similar way to add zeros in each dimension? For
>> example, for
>> array(1:12, dim=c(2,2,3))?
>>
>> Thanks for your help!!
>>   Hanna
>>
>>
>>
>> x <- as.data.frame(matrix(1:20,4,5))> x[5,] <- 0> x[,6] <- 0> x  V1 V2
>>> V3 V4 V5 V6
>>>
>> 1  1  5  9 13 17  0
>> 2  2  6 10 14 18  0
>> 3  3  7 11 15 19  0
>> 4  4  8 12 16 20  0
>> 5  0  0  0  0  0  0
>>
>> [[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.
>>
>>
> 
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> 
> ---
>

[[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] OPINIONES comparacion personal de R en linux y windows

2017-06-07 Thread Javier Marcuzzi
Estimado Javier Valdes Cantallopts

Hace mucho que no uso R en Linux ni en mac, como experiencia de usuario Windows 
no es tan cómodo, aunque realice lo mismo, sin embargo es algo muy personal que 
tiene más que ver con la interfaz gráfica y su funcionamiento, aunque R en 
Ubuntu me parecía desafortunado al lado de R en SUSE.

Creo que debe hacer diferencias en la compilación (o el compilador). Pero si 
usted puede intente realizar el mismo trabajo con (no recuerdo justo el 
comando) para marcar el tiempo que demora.

Javier Rubén Marcuzzi

De: Javier Valdes Cantallopts (DGA)
Enviado: miércoles, 7 de junio de 2017 11:33
Para: Carlos Ortega (c...@qualityexcellence.es)
CC: r-help-es@r-project.org
Asunto: [R-es] OPINIONES comparacion personal de R en linux y windows

Hola estimados.
Les quería plantear un tema que tiene que ver con las plataformas en donde 
hacemos correr nuestro R.
En mi caso, tengo instalado R en mi oficina(Windows) y en mi casa(Linux) y la 
verdad, después de probar algunas funciones gráficas, claramente R sobre Linux 
me entrega resultados más satisfactorios, no solo por la rapidez, sino porque 
también, Linux al parecer, interpreta mejor las instrucciones de R.
R corre mucho más fluidamente sobre mi notebook que ya cumplirá 11 años 
conmigo, que sobre la estación de trabajo de última generación con Windows.
No sé qué opinan?







CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los archivos 
adjuntos es de carácter confidencial o privilegiada y está destinada al uso 
exclusivo del emisor y/o de la persona o entidad a quien va dirigida. Si usted 
no es el destinatario, cualquier almacenamiento, divulgación, distribución o 
copia de esta información está estrictamente prohibido y sancionado por la ley. 
Si recibió este mensaje por error, por favor infórmenos inmediatamente 
respondiendo este mismo mensaje y borre todos los archivos adjuntos. Gracias.

CONFIDENTIAL NOTE: The information transmitted in this message and/or 
attachments is confidential and/or privileged and is intented only for use of 
the person or entity to whom it is addressed. If you are not the intended 
recipient, any retention, dissemination, distribution or copy of this 
information is strictly prohibited and sanctioned by law. If you received this 
message in error, please reply us this same message and delete this message and 
all attachments. Thank you.

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

[R] error while opening vignette DESeq2

2017-06-07 Thread Yogesh Gupta
Hi ,

I am trying to open vignette DESeq2 but getting below error:

> vignette("DESeq2")
> START /usr/bin/evince "/usr/lib64/R/library/DESeq2/doc/DESeq2.pdf"
Cannot parse arguments: Cannot open display:
xdg-open: no method available for opening
'/usr/lib64/R/library/DESeq2/doc/DESeq2.pdf'

-- 
*Yogesh Gupta*
*Postdoctoral Researcher*
*Department of Biological Science*
*Seoul National University*
*Seoul, South Korea*

[[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] Problem related to rowSums

2017-06-07 Thread Yogesh Gupta
Hi...

I have a dataframe with n columns and n rows. I need to find how many rows
contains zero raw read count across all column.

Thanks

-- 
*Yogesh Gupta*
*Postdoctoral Researcher*
*Department of Biological Science*
*Seoul National University*
*Seoul, South Korea*

[[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] Adding zeros in each dimension of an array

2017-06-07 Thread Jeff Newmiller

Please read
https://www.lifewire.com/how-to-send-a-message-in-plain-text-from-gmail-1171963

Re your question: easy is in the eye of the beholder.

a <- array( 1:12, dim = c( 2, 2, 3 ) )
b <- array( 0, dim = dim( a ) + 1 )
b[ 1:2, 1:2, 1:3 ] <- a

If you want to do a lot of this, it could be wrapped for convenience 
though implementing that last expression without hardcoding the sequences 
may not be obvious:


expandArray <- function( a ) {
  b <- array( 0, dim = dim( a ) + 1 )
  do.call( `[<-`, c( list( b ), lapply( dim( a ), seq.int ), list( a ) ) )
}
expandArray( a )

On Wed, 7 Jun 2017, li li wrote:


For a data frame, we can add an additional row or column easily. For
example, we can add an additional row of zero and an additional row of
column as follows.

Is there an easy and similar way to add zeros in each dimension? For
example, for
array(1:12, dim=c(2,2,3))?

Thanks for your help!!
  Hanna




x <- as.data.frame(matrix(1:20,4,5))> x[5,] <- 0> x[,6] <- 0> x  V1 V2 V3 V4 V5 
V6

1  1  5  9 13 17  0
2  2  6 10 14 18  0
3  3  7 11 15 19  0
4  4  8 12 16 20  0
5  0  0  0  0  0  0

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] OPINIONES comparacion personal de R en linux y windows

2017-06-07 Thread Javier Nieto
Hola, estoy totalmente de acuerdo contigo. R en Linux en una máquina virtual 
corre mucho mejor que en la máquina física con Windows.


Saludos



De: R-help-es  en nombre de Javier Valdes 
Cantallopts (DGA) 
Enviado: miércoles, 7 de junio de 2017 09:33:25 a. m.
Para: Carlos Ortega (c...@qualityexcellence.es)
CC: r-help-es@r-project.org
Asunto: [R-es] OPINIONES comparacion personal de R en linux y windows

Hola estimados.
Les quería plantear un tema que tiene que ver con las plataformas en donde 
hacemos correr nuestro R.

la verdad, después de probar algunas funciones gráficas, claramente R sobre 
Linux me entrega resultados más satisfactorios, no solo por la rapidez, sino 
porque también, Linux al parecer, interpreta mejor las instrucciones de R.
R corre mucho más fluidamente sobre mi notebook que ya cumplirá 11 años 
conmigo, que sobre la estación de trabajo de última generación con
No sé qué opinan?


[Descripción: FIRMA3]




CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los archivos 
adjuntos es de carácter confidencial o privilegiada y está destinada al uso 
exclusivo del emisor y/o de la persona o entidad a quien va dirigida. Si usted 
no es el destinatario, cualquier almacenamiento, divulgación, distribución o 
copia de esta información está estrictamente prohibido y sancionado por la ley. 
Si recibió este mensaje por error, por favor infórmenos inmediatamente 
respondiendo este mismo mensaje y borre todos los archivos adjuntos. Gracias.

CONFIDENTIAL NOTE: The information transmitted in this message and/or 
attachments is confidential and/or privileged and is intented only for use of 
the person or entity to whom it is addressed. If you are not the intended 
recipient, any retention, dissemination, distribution or copy of this 
information is strictly prohibited and sanctioned by law. If you received this 
message in error, please reply us this same message and delete this message and 
all attachments. Thank you.
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] Adding zeros in each dimension of an array

2017-06-07 Thread David Winsemius

> On Jun 7, 2017, at 8:33 AM, li li  wrote:
> 
> For a data frame, we can add an additional row or column easily. For
> example, we can add an additional row of zero and an additional row of
> column as follows.
> 
> Is there an easy and similar way to add zeros in each dimension? For
> example, for
> array(1:12, dim=c(2,2,3))?
> 
> Thanks for your help!!
>   Hanna
> 
> 
> 
>> x <- as.data.frame(matrix(1:20,4,5))> x[5,] <- 0> x[,6] <- 0> x  V1 V2 V3 V4 
>> V5 V6
> 1  1  5  9 13 17  0
> 2  2  6 10 14 18  0
> 3  3  7 11 15 19  0
> 4  4  8 12 16 20  0
> 5  0  0  0  0  0  0
> 

Try installing the abind package.


>   [[alternative HTML version deleted]]

And learn to post in plaint text.


> 
> __
> 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] Determining which.max() within groups

2017-06-07 Thread Jeff Newmiller
Aggregate can do both which.max and group length calculations, but the 
result ends up as a matrix inside the data frame, which I find cumbersome 
to work with.


Daily <- read.table( text =
" Date  wyrQ
1911-04-01 1990 4.530695
1911-04-02 1990 4.700596
1911-04-03 1990 4.898814
1911-04-04 1990 5.097032
1911-04-05 1991 5.295250
1911-04-06 1991 6.569508
1911-04-07 1991 5.861587
1911-04-08 1991 5.153666
1911-04-09 1992 4.445745
1911-04-10 1992 3.737824
1911-04-11 1992 3.001586
1911-04-12 1992 3.001586
1911-04-13 1993 2.350298
1911-04-14 1993 2.661784
1911-04-16 1993 3.001586
1911-04-17 1993 2.661784
1911-04-19 1994 2.661784
1911-04-28 1994 3.369705
1911-04-29 1994 3.001586
1911-05-20 1994 2.661784
", header = TRUE, stringsAsFactors=FALSE)

# this algorithm only works if wyr groups are contiguous
out <- out[ order(out$wyr), ]
# generate a data frame with key column wyr and matrix Q as the second 
column

out <- aggregate( Q ~ wyr
, data = Daily
, FUN = function(x) {
 c( WM = which.max(x)
  , n=length( x )
  )
  }
)
# put matrix into separate columns Q.WM
out[ , paste( "Q", colnames( out$Q ), sep="." ) ] <- out$Q
# drop the matrix
out$Q <- NULL
# form absolute indexes Q.N
out <- within( out, {
Q.maxidx <- cumsum( c( 0, Q.n[ -length(Q.n) ] ) ) + Q.WM
   })
result <- Daily[ with( out, Q.maxidx ), ]

# or save ourselves some effort
library(dplyr)
result2 <- (   Daily
   %>% group_by( wyr )
   %>% slice( which.max( Q ) )
   %>% as.data.frame
   )

On Tue, 6 Jun 2017, Bert Gunter wrote:


cumsum() seems to be what you need.

This can probably be done more elegantly, but ...

out <- aggregate(Q ~ wyr, data = Daily, which.max)
tbl <- table(Daily$wyr)
out$Q <- out$Q + cumsum(c(0,tbl[-length(tbl)]))
out

## yields

  wyr  Q
1 1990  4
2 1991  6
3 1992  9
4 1993 15
5 1994 18

I leave the matter of Julian dates to you or others.

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, Jun 6, 2017 at 6:30 PM, Morway, Eric  wrote:

Using the dataset below, I got close to what I'm after, but not quite all
the way there.  Any suggestions appreciated:

Daily <- read.table(textConnection(" Date  wyrQ
1911-04-01 1990 4.530695
1911-04-02 1990 4.700596
1911-04-03 1990 4.898814
1911-04-04 1990 5.097032
1911-04-05 1991 5.295250
1911-04-06 1991 6.569508
1911-04-07 1991 5.861587
1911-04-08 1991 5.153666
1911-04-09 1992 4.445745
1911-04-10 1992 3.737824
1911-04-11 1992 3.001586
1911-04-12 1992 3.001586
1911-04-13 1993 2.350298
1911-04-14 1993 2.661784
1911-04-16 1993 3.001586
1911-04-17 1993 2.661784
1911-04-19 1994 2.661784
1911-04-28 1994 3.369705
1911-04-29 1994 3.001586
1911-05-20 1994 2.661784"),header=TRUE)

aggregate(Q ~ wyr, data = Daily, which.max)

# gives:
#wyr Q
# 1 1990 4
# 2 1991 2
# 3 1992 1
# 4 1993 3
# 5 1994 2

I can 'see' that it is returning the which.max() relative to each
grouping.  Is there a way to instead return the absolute position (row) of
the max value within each group.  i.e.:

# Would instead like to have
# wyr  Q
# 1  1990  4
# 2  1991  6
# 3  1992  9
# 4  1993  15
# 5  1994  18

The icing on the cake would be to get the Julien Day corresponding to the
date on which each year's maximum occurs?

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



---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

__
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] Adding zeros in each dimension of an array

2017-06-07 Thread li li
For a data frame, we can add an additional row or column easily. For
example, we can add an additional row of zero and an additional row of
column as follows.

Is there an easy and similar way to add zeros in each dimension? For
example, for
array(1:12, dim=c(2,2,3))?

Thanks for your help!!
   Hanna



> x <- as.data.frame(matrix(1:20,4,5))> x[5,] <- 0> x[,6] <- 0> x  V1 V2 V3 V4 
> V5 V6
1  1  5  9 13 17  0
2  2  6 10 14 18  0
3  3  7 11 15 19  0
4  4  8 12 16 20  0
5  0  0  0  0  0  0

[[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] An R question

2017-06-07 Thread li li
Thank you!

2017-06-07 10:38 GMT-04:00 Ivan Calandra :

> Hi,
>
> Check the FAQ 7.31
> https://cran.rstudio.com/doc/FAQ/R-FAQ.html#Why-doesn_0027t-
> R-think-these-numbers-are-equal_003f
>
> And read the posting guide too...
> https://www.r-project.org/posting-guide.html
>
> HTH,
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, Laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
>
> On 07/06/2017 16:32, li li wrote:
>
>> Hi all,
>>In checking my R codes, I encountered the following problem. Is there a
>> way to fix this?
>> I tried to specify options(digits=). I did not fix the problem.
>>Thanks so much for your help!
>> Hanna
>>
>>
>> cdf(pmass)[2,2]==pcum[2,2][1] FALSE> cdf(pmass)[2,2][1] 0.758>
>>> pcum[2,2][1] 0.758
>>>
>> [[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.


Re: [R] An R question

2017-06-07 Thread Ivan Calandra

Hi,

Check the FAQ 7.31
https://cran.rstudio.com/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

And read the posting guide too...
https://www.r-project.org/posting-guide.html

HTH,
Ivan

--
Dr. Ivan Calandra
TraCEr, Laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 07/06/2017 16:32, li li wrote:

Hi all,
   In checking my R codes, I encountered the following problem. Is there a
way to fix this?
I tried to specify options(digits=). I did not fix the problem.
   Thanks so much for your help!
Hanna



cdf(pmass)[2,2]==pcum[2,2][1] FALSE> cdf(pmass)[2,2][1] 0.758> pcum[2,2][1] 
0.758

[[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] purrr::pmap does not work

2017-06-07 Thread G . Maubach
Hi All,

I try to do a scatterplot for a bunch of variables. I plot a dependent 
variable against a bunch of independent variables:

-- cut --
graphics::plot(
  v01_r01 ~ v08_01_up11,
  data = dataset,
  xlab = "Dependent",
  ylab = "Independent #1"
)

-- cut --

It is tedious to repeat the statement for all independent variables. Found 
an alternative, i.e. :

-- cut --

mu <- list(5, 10, -3)
sigma <- list(1, 5, 10)
n <- list(1, 3, 5)
fargs <- list(mean = mu, sd = sigma, n = n)
fargs %>%
  purrr::pmap(rnorm) %>%
  str()

-- cut --

I tried to use this for may scatterplot task:

-- cut --

var_battery$v08 <- paste0("v08_", formatC(1:8, width = 2, format = "d", 
flag = "0"))
v08_var_labs <- paste0("Label_", 1:8)

dataset <- as.data.frame(
  matrix(
data = sample(
  x = 1:11,
  size = 90,
  replace = TRUE),
nrow = 10,
ncol = 9))
names(dataset) <- c("v01_r01", var_battery$v08)

independent <- as.list(dataset$v01_r01)
dependent <- as.list(dataset[var_battery$v08])

fargs <- list(
  x = independent,
  y = dependent,
  ylab = v08_var_labs)

fargs %>% 
  purrr::pmap(
function(d = dataset, xvalue = x, yvalue = y,
 xlab = "Label for x variable",
 ylab = ylab) {
  graphics::plot(
xvalue ~ yvalue,
data = d,
xlab = xlab,
ylab = ylab)
}
  )

-- cut --

The last statement comes back with

Error: Element 2 has length 8, not 1 or 10.

How can I get it up n running? Do you suggest a better solution for the 
task described?

Kind regards

Georg

__
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] An R question

2017-06-07 Thread Rui Barradas

Hello,

See FAQ 7.31
And try ?all.equal.

Hope this helps,

Rui Barradas


Em 07-06-2017 15:32, li li escreveu:

Hi all,
   In checking my R codes, I encountered the following problem. Is there a
way to fix this?
I tried to specify options(digits=). I did not fix the problem.
   Thanks so much for your help!
Hanna



cdf(pmass)[2,2]==pcum[2,2][1] FALSE> cdf(pmass)[2,2][1] 0.758> pcum[2,2][1] 
0.758


[[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-es] mediana en el grafico box-plot

2017-06-07 Thread Pedro Herrero Petisco
Si quieres probar otra alternativa puedes modificar el código de este
ejemplo:
http://www.r-graph-gallery.com/26-add-text-over-a-boxplot/

Hace tiempo lo hice yo así: En la parte de texto tendrías que poner en el
eje X los factores del boxplot, en el eje Y los valores de mediana y en el
texto de nuevo los valores de mediana.

Espero que te sirva de ayuda


El 7 de junio de 2017, 13:00, Jose Manuel Veiga del Baño 
escribió:

> Hola a todos,
>
> Estoy intentando poner sobre un gráfico box-plot el valor de la mediana,
> pero no lo consigo. Las opciones de stackoverflow no consigo que funcionen.
> Este sería el código que estoy intentando:
>
>   require(ggplot2)
>   require(reshape2)
>   df2 <- melt(df[, 1:4])
>   means <- aggregate(value ~  factor(variable), df2, mean)
>   p<-ggplot(df2, aes(factor(variable), value)) + geom_boxplot(aes(fill =
> TIPO))
>
> Hasta aquí funciona perfectamente, pero en teoría para poner el valor de
> la mediana sería:
>
> p<-ggplot(df2, aes(factor(variable), value)) + geom_boxplot(aes(fill =
> TIPO))+stat_summary(fun.y=mean, colour="darkred", geom="point", shape=18,
> size=3,show_guide = FALSE) + geom_text(data = means, aes(label = value, y =
> factor(variable) + 0.08))
>
> Y me arroja el error. Error in factor(variable): objeto 'variable' no
> encontrado.
>
> El dataframe es una tabla con tres variables y lo único que se agrupan en
> PACIENTE, PLACEBO.
>
> Gracias
>
> Dr. José M. Veiga
> Dpt. Química Agrícola, Geología y Edafología.
> Universidad de Murcia.
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[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-es] OPINIONES comparacion personal de R en linux y windows

2017-06-07 Thread Javier Valdes Cantallopts (DGA)
Hola estimados.
Les quería plantear un tema que tiene que ver con las plataformas en donde 
hacemos correr nuestro R.
En mi caso, tengo instalado R en mi oficina(Windows) y en mi casa(Linux) y la 
verdad, después de probar algunas funciones gráficas, claramente R sobre Linux 
me entrega resultados más satisfactorios, no solo por la rapidez, sino porque 
también, Linux al parecer, interpreta mejor las instrucciones de R.
R corre mucho más fluidamente sobre mi notebook que ya cumplirá 11 años 
conmigo, que sobre la estación de trabajo de última generación con Windows.
No sé qué opinan?


[Descripción: FIRMA3]




CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los archivos 
adjuntos es de carácter confidencial o privilegiada y está destinada al uso 
exclusivo del emisor y/o de la persona o entidad a quien va dirigida. Si usted 
no es el destinatario, cualquier almacenamiento, divulgación, distribución o 
copia de esta información está estrictamente prohibido y sancionado por la ley. 
Si recibió este mensaje por error, por favor infórmenos inmediatamente 
respondiendo este mismo mensaje y borre todos los archivos adjuntos. Gracias.

CONFIDENTIAL NOTE: The information transmitted in this message and/or 
attachments is confidential and/or privileged and is intented only for use of 
the person or entity to whom it is addressed. If you are not the intended 
recipient, any retention, dissemination, distribution or copy of this 
information is strictly prohibited and sanctioned by law. If you received this 
message in error, please reply us this same message and delete this message and 
all attachments. Thank you.
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] An R question

2017-06-07 Thread li li
Hi all,
  In checking my R codes, I encountered the following problem. Is there a
way to fix this?
I tried to specify options(digits=). I did not fix the problem.
  Thanks so much for your help!
   Hanna


> cdf(pmass)[2,2]==pcum[2,2][1] FALSE> cdf(pmass)[2,2][1] 0.758> 
> pcum[2,2][1] 0.758

[[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] Determining which.max() within groups

2017-06-07 Thread David L Carlson
If you want the Julian date, you could use Bert's index on the original data 
frame:

Daily[out$Q, ]
 Date  wyrQ
4  1911-04-04 1990 5.097032
6  1911-04-06 1991 6.569508
9  1911-04-09 1992 4.445745
15 1911-04-16 1993 3.001586
18 1911-04-28 1994 3.369705

Another way to get that index would be to use by():

idx <- as.vector(by(Daily, Daily$wyr, function(x) rownames(x)[which.max(x$Q)]))
Daily[idx, ]

-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
Sent: Tuesday, June 6, 2017 9:16 PM
To: Morway, Eric 
Cc: R mailing list 
Subject: Re: [R] Determining which.max() within groups

cumsum() seems to be what you need.

This can probably be done more elegantly, but ...

out <- aggregate(Q ~ wyr, data = Daily, which.max)
tbl <- table(Daily$wyr)
out$Q <- out$Q + cumsum(c(0,tbl[-length(tbl)]))
out

## yields

   wyr  Q
1 1990  4
2 1991  6
3 1992  9
4 1993 15
5 1994 18

I leave the matter of Julian dates to you or others.

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, Jun 6, 2017 at 6:30 PM, Morway, Eric  wrote:
> Using the dataset below, I got close to what I'm after, but not quite all
> the way there.  Any suggestions appreciated:
>
> Daily <- read.table(textConnection(" Date  wyrQ
> 1911-04-01 1990 4.530695
> 1911-04-02 1990 4.700596
> 1911-04-03 1990 4.898814
> 1911-04-04 1990 5.097032
> 1911-04-05 1991 5.295250
> 1911-04-06 1991 6.569508
> 1911-04-07 1991 5.861587
> 1911-04-08 1991 5.153666
> 1911-04-09 1992 4.445745
> 1911-04-10 1992 3.737824
> 1911-04-11 1992 3.001586
> 1911-04-12 1992 3.001586
> 1911-04-13 1993 2.350298
> 1911-04-14 1993 2.661784
> 1911-04-16 1993 3.001586
> 1911-04-17 1993 2.661784
> 1911-04-19 1994 2.661784
> 1911-04-28 1994 3.369705
> 1911-04-29 1994 3.001586
> 1911-05-20 1994 2.661784"),header=TRUE)
>
> aggregate(Q ~ wyr, data = Daily, which.max)
>
> # gives:
> #wyr Q
> # 1 1990 4
> # 2 1991 2
> # 3 1992 1
> # 4 1993 3
> # 5 1994 2
>
> I can 'see' that it is returning the which.max() relative to each
> grouping.  Is there a way to instead return the absolute position (row) of
> the max value within each group.  i.e.:
>
> # Would instead like to have
> # wyr  Q
> # 1  1990  4
> # 2  1991  6
> # 3  1992  9
> # 4  1993  15
> # 5  1994  18
>
> The icing on the cake would be to get the Julien Day corresponding to the
> date on which each year's maximum occurs?
>
> [[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] Errors running spdplyr example

2017-06-07 Thread Michael Sumner
On Wed, 7 Jun 2017 at 17:29 Shige Song  wrote:

> Dear All,
>
> When I tried to run the following code (taken from the *spdplyr* package
> vignettes):
>
> library(spdplyr)
> library(maptools)
> data(wrld_simpl)
>
> worldcorner <- wrld_simpl %>%
>   mutate(lon = coordinates(wrld_simpl)[,1], lat =
> coordinates(wrld_simpl)[,2]) %>%
>   filter(lat < -20, lon > 60) %>%
>   dplyr::select(NAME)
>
>
> I got the following error messages:
>
> Error in (function (cl, name, valueClass)  :
>   c("assignment of an object of class “tbl_df” is not valid for @‘data’ in
> an object of class “SpatialPolygonsDataFrame”; is(value, \"data.frame\") is
> not TRUE", "assignment of an object of class “tbl” is not valid for @‘data’
> in an object of class “SpatialPolygonsDataFrame”; is(value, \"data.frame\")
> is not TRUE", "assignment of an object of class “data.frame” is not valid
> for @‘data’ in an object of class “SpatialPolygonsDataFrame”; is(value,
> \"data.frame\") is not TRUE")
>
>
Hi Shige,

I can't reproduce this, could you run 'sessionInfo()' and let me know?

I'm pretty sure you could workaround this by running

setOldClass( c("tbl_df", "tbl", "data.frame" ) )

but I don't understand why that's not already working, and it's not
something you want to rely on. (You are only the second report where I've
heard anyone seeing this, it's because sp is strict about only accepting
'data.frame' rather than anything inheriting from 'data.frame', as 'tbl_df'
does. )

Feel free to take this off-list and post directly to the Issues on Github
or email me.

 bug.report(package = "spdplyr")

Cheers, Mike.



> I am running R 3.3.3 with the latest CRAN version of *spdplyr* (0.1.3) on
> Windows 10.
>
> Thanks.
>
> Best,
> Shige
>
> [[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.

-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

[[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-es] mediana en el grafico box-plot

2017-06-07 Thread Jose Manuel Veiga del Baño
Hola a todos,

Estoy intentando poner sobre un gráfico box-plot el valor de la mediana,
pero no lo consigo. Las opciones de stackoverflow no consigo que funcionen.
Este sería el código que estoy intentando:

  require(ggplot2)
  require(reshape2)
  df2 <- melt(df[, 1:4])
  means <- aggregate(value ~  factor(variable), df2, mean)
  p<-ggplot(df2, aes(factor(variable), value)) + geom_boxplot(aes(fill =
TIPO))

Hasta aquí funciona perfectamente, pero en teoría para poner el valor de
la mediana sería:

p<-ggplot(df2, aes(factor(variable), value)) + geom_boxplot(aes(fill =
TIPO))+stat_summary(fun.y=mean, colour="darkred", geom="point", shape=18,
size=3,show_guide = FALSE) + geom_text(data = means, aes(label = value, y =
factor(variable) + 0.08))

Y me arroja el error. Error in factor(variable): objeto 'variable' no
encontrado.

El dataframe es una tabla con tres variables y lo único que se agrupan en
PACIENTE, PLACEBO.

Gracias

Dr. José M. Veiga
Dpt. Química Agrícola, Geología y Edafología.
Universidad de Murcia.

[[alternative HTML version deleted]]

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


Re: [R] Plot MArginal distribution in the correct place

2017-06-07 Thread Jim Lemon
Hi Pedro,
As a one-off, you just shove the coordinates around a bit:

par(mar=c(11,0,6,6))
barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray",
 ylim=c(0,24))

However, I don't think that this plot illustrates quite what you think it does.

Jim


On Wed, Jun 7, 2017 at 4:01 PM, Pedro páramo  wrote:
> Please, I'm trying to put the right plot higher and centered on the left
> values but I don't achive.
>
> I would appreciate so much your help
>
> El 6 jun. 2017 22:37, "Pedro páramo"  escribió:
>
>> Hi all,
>>
>> I have this code, but the marginal distribution plot doesn´t appear
>> aligned with the left plot.
>>
>>
>> I think could be something about layout or par() mar.
>>
>> The code was programmed by me time ago.
>>
>> Can anyone help me to get the marginal distribution on the center (more
>> higher centered)
>>
>> id.txt
>>
>> Could have this code:
>>
>> 05/01/2016;9335,200195
>> 06/01/2016;9197,400391
>> 07/01/2016;9059,299805
>> 08/01/2016;8909,200195
>> 11/01/2016;8886,099609
>> 12/01/2016;8915,400391
>> 13/01/2016;8934,5
>> 14/01/2016;8787,700195
>> 15/01/2016;8543,599609
>> 18/01/2016;8469,299805
>> 19/01/2016;8554,900391
>> 20/01/2016;8281,400391
>> 21/01/2016;8444,200195
>> 22/01/2016;8722,900391
>> 25/01/2016;8567,700195
>> 26/01/2016;8692,5
>> 27/01/2016;8741
>>
>>
>>
>> g<-read.table("id.txt", col.names=c("Dateh","LAST"), sep=";", dec=",")
>>
>> N=5000
>> B=24
>> ghy<-nrow(g)
>> r<-as.numeric(as.character(g$LAST[ghy]))
>>
>>
>> nf<-layout(matrix(c(1,1,1,1,2,2),1,6,byrow=TRUE))
>>
>> par(mar=c(6,6,6,0.5))
>>
>> A<-matrix(1:B,B,N);
>>
>>
>>
>> sigma<-0.06;
>>
>>
>>
>> mu<-0.00;
>>
>>
>> Z<-r*exp((mu-0.5*((sigma)^2)*A) +sigma*(sqrt(A))*matrix( rnorm(N*B,0,1),
>> B, N))
>>
>> real1<-g$LAST[1:nrow(g)]
>>
>> real2<-matrix(NA,nrow(g),N-1)
>>
>> real<-cbind(real1,real2)
>>
>>
>>
>>
>> Po<-r*matrix(1,1,N);
>>
>>
>>
>> Sim<-rbind(Po,Z)
>> Simulation<-rbind(real,Z)
>>
>>
>>
>>
>>
>>
>> par(mar=c(10,6,6,6))
>> matplot(Simulation,type="l",ylim=c(0,4))
>>
>> abline(h = 8000, lwd = 2, col = "black")
>>
>> abline(h = 12000, lwd = 2, col = "black")
>> title("Dinamic Montecarlo Simulation 2 years ahead",font=4)
>>
>> fhist<-hist(Simulation,plot=FALSE)
>> par(mar=c(6,0,6,6))
>> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray")
>> grid()
>> title("Marginal Distribution",font=4)
>>
>>
>> rect(0, 0, 0, 0) # transparent
>>
>>
>
> [[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] Getting forecast values using DCC GARCH fit

2017-06-07 Thread Dhivya Narayanasamy
Hi,
I am completely new to GARCH models and trying to fit a multivariate time
series model using DCC GARCH model and forecast it.

The data looks like this:

> head(datax)
x   vibration_x Speed
1 2017-05-16 17:53:00  -0.132  421.4189
2 2017-05-16 17:54:00  -0.296 1296.8882
3 2017-05-16 17:55:00  -0.5720.
4 2017-05-16 17:56:00  -0.736 1254.2695
5 2017-05-16 17:57:00   0.0000.
6 2017-05-16 17:58:00   0.0000.

> garch11.spec = ugarchspec(mean.model = list(armaOrder = c(1,1)),
   variance.model = list(garchOrder = c(1,1),
  model = "sGARCH"),
distribution.model = "norm")
> dcc.garch11.spec = dccspec(uspec = multispec( replicate(2, garch11.spec)
),
  dccOrder = c(1,1), distribution = "mvnorm")
> fit.a = dccfit(dcc.garch11.spec, data = datax[,c(2,3)], out.sample = 100,
 fit.control = list(eval.se=T))
> dcc.focast=dccforecast(fit.a, n.ahead = 100)

May I know how to get the forecast values from 'dcc.focast' ? when i plot
the model using,

> plot(dcc.focast, which = 1)

I get different plots such as.
Make a plot selection (or 0 to exit):

1:   Conditional Mean (vs Realized Returns)
2:   Conditional Sigma (vs Realized Absolute Returns)
3:   Conditional Covariance
4:   Conditional Correlation
5:   EW Portfolio Plot with conditional density VaR limits

May i know what i should do with "Conditional covariance" and "conditional
correlation" forecast. I know this is for volatility prediction. I am
interested to know what things i can interpret from this conditional
covariance ?

 Any help is much appreciated. Thanks.,

Regards
Dhivya

[[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] Sin mejoras con H2O

2017-06-07 Thread Carlos Ortega
Prueba a arrancar H2O asignádole un poco más de RAM...

De todas formas, para conjuntos como el de "iris" puede que no aprecies
mejora, H2O no es para modelizar sobre este tipo (por tamaño) de conjuntos.

Gracias,
Carlos.

El 7 de junio de 2017, 10:06, Jesús Para Fernández <
j.para.fernan...@hotmail.com> escribió:

> Buenas,
>
>
> Tras vuestra recomendación, estoy probando con H2O en local viendo las
> mejoras que me aporta. Con Sys.time controlo el comienzo y final de
> ejecución de los modelos, y haciendo la diferencia de tiempos obtengo el
> tiempo de ejecución.
>
>
> Con una simple prueba hago lo siguiente:
>
>
> iris
>
>
> inicio<-Sys.time()
>
> modelo<-randomForest(Species~.,data=iris,ntrees=500)
>
> fin<-Sys.time()
>
> fin-inio
>
>
> iris2<-as.h2o(iris)
>
> inicio<-Sys.time()
>
> modelo<-h2o.randomForest(x=1:4,y=5,iris2,ntrees=500)
>
> fin<-Sys.time()
>
>
> fin-inicio
>
>
> Y para mi sorpresa es más rápido R sin h2o. Analizando un poco la
> situación, creo que es por usarlo en local en una máquina poco potente:
>
>
> Estoy ejecutando R 64 bits en un equipo con windows7 con un i5 de
> procesador y 4 gigas de RAM. Al iniciar h2o, dejo la configuración por
> defecto h2o.init(), que crea el siguiente "nodo":
>
>
> H2O cluster total nodes:1
> H2O cluster total memory:   0.85 GB
> H2O cluster total cores:4
> H2O cluster allowed cores:  2
> H2O cluster healthy:TRUE
> H2O Connection ip:  localhost
> H2O Connection port:54321
> H2O Connection proxy:   NA
> H2O Internal Security:  FALSE
> R Version:  R version 3.3.2 (2016-10-31)
>
> Note:  As started, H2O is limited to the CRAN default of 2 CPUs.
>Shut down and restart H2O as shown below to use all your CPUs.
>
>
>
> ¿Alguna idea de porque crea el modelo más lento usando h20 que sin hacer
> uso de h20?
>
>
> Gracias
>
> [[alternative HTML version deleted]]
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[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] Operating on RC in a list

2017-06-07 Thread Mohan.Radhakrishnan
Hi,

I have a hierarchy of such classes. Subject has a list of measurements. Let 
assume I have a list of such 'Subject' RC's.

Can I use dplyr to navigate from Subject to the list of measurement RC's and 
filter and group data ? dplyr should
be able to call the methods on these RC's to operate on the data structure ?

I tried to coerce the list of RC's into a data frame unsuccessfully. But dplyr 
should be able to work with lists too. Right ?


Subject <- setRefClass("Subject",
fields = list( id = "numeric",
measurement = "Measurement",
location = "Location"),
methods=list(getmeasurement = function()
{
measurement
},
getid = function()
{
id
},
getlocation = function()
{
location
},
summary = function()#Implement other summary methods in appropriate objects as 
per their responsibilities
{
paste("Subject summary ID [",id,"] Location [",location$summary(),"]")
},show = function(){
cat("Subject summary ID [",id,"] Location [",location$summary(),"]\n")
})
)


Thanks,
Mohan
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.

[[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] Tablas en R

2017-06-07 Thread Carlos Ortega
Hola,

Hace poco vi este nuevo paquete "tangram", que busca aplicar el concepto de
"Grammar of Graphics" a las tablas...
La viñeta es muy ilustrativa de todo lo que se puede hacer:

https://cloud.r-project.org/web/packages/tangram/vignettes/example.html

Gracias,
Carlos Ortega
www.qualityexcellence.es

El 7 de junio de 2017, 9:15, 
escribió:

> Hola doblett.
>
> No sé si te lo han comentado ya, pero yo le echaría un ojo al paquete
> ReporteRs.
>
> Un saludo,
> Miguel.
>
>
>
>
> El 06/06/2017 a las 16:00, doblett escribió:
> > Muchas gracias a todos por las sugerencias y por la rápida respuesta.
> > Mi impresión es que no tenemos una solución cómoda para este tema y al
> > menos en mi día a día es muy útil.
> >
> > - Tables, funciona muy bien con latex y se pueden llegar a hacer
> tablas
> > muy completas. El problema no está en la tabla sino en el formato de
> > documento. Si en la oficina le doy el informe a mi jefe en latex se
> va a
> > quedar a cuadros. Necesitamos volcar la tabla a un documento que
> > posteriormente se pueda editar para incorporar texto.
> > - Stargazer, cuenta con similares prestaciones que tables y con las
> > similares carencias en cuanto al formato de salida del documento.
> >
> > Por lo que veo, salvo que alguien tenga otra forma de trabajar esto, lo
> > tenemos complicado. Sacar las tablas por pantalla no es tan difícil, el
> > problema lo tenemos para llevárnoslas a un documento fácilmente editable
> > tipo ODF. R markdown da muchas facilidades cuando se trata de texto,
> > podemos obtener el mismo documento en tres formatos diferentes (HTML,
> PDF y
> > ODF) casi sin esfuerzo, pero con tablas la cosa se complica.
> >
> > Si no es posible crear las tablas "al vuelo" en formatos "editables a
> > posteriori" y alguien tiene una forma de trabajar que pueda ser útil,
> > también será bienvenida.
> >
> >
> > Saludos.
> > doblett.
> >
>
> 
>
> Nota: A información contida nesta mensaxe e os seus posibles documentos
> adxuntos é privada e confidencial e está dirixida únicamente ó seu
> destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe,
> por favor elimínea. A distribución ou copia desta mensaxe non está
> autorizada.
>
> Nota: La información contenida en este mensaje y sus posibles documentos
> adjuntos es privada y confidencial y está dirigida únicamente a su
> destinatario/a. Si usted no es el/la destinatario/a original de este
> mensaje, por favor elimínelo. La distribución o copia de este mensaje no
> está autorizada.
>
> See more languages: http://www.sergas.es/aviso-confidencialidad
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[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] Errors running spdplyr example

2017-06-07 Thread Shige Song
Dear All,

When I tried to run the following code (taken from the *spdplyr* package
vignettes):

library(spdplyr)
library(maptools)
data(wrld_simpl)

worldcorner <- wrld_simpl %>%
  mutate(lon = coordinates(wrld_simpl)[,1], lat =
coordinates(wrld_simpl)[,2]) %>%
  filter(lat < -20, lon > 60) %>%
  dplyr::select(NAME)


I got the following error messages:

Error in (function (cl, name, valueClass)  :
  c("assignment of an object of class “tbl_df” is not valid for @‘data’ in
an object of class “SpatialPolygonsDataFrame”; is(value, \"data.frame\") is
not TRUE", "assignment of an object of class “tbl” is not valid for @‘data’
in an object of class “SpatialPolygonsDataFrame”; is(value, \"data.frame\")
is not TRUE", "assignment of an object of class “data.frame” is not valid
for @‘data’ in an object of class “SpatialPolygonsDataFrame”; is(value,
\"data.frame\") is not TRUE")

I am running R 3.3.3 with the latest CRAN version of *spdplyr* (0.1.3) on
Windows 10.

Thanks.

Best,
Shige

[[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] Tablas en R

2017-06-07 Thread miguel.angel.rodriguez.muinos
Hola doblett.

No sé si te lo han comentado ya, pero yo le echaría un ojo al paquete
ReporteRs.

Un saludo,
Miguel.




El 06/06/2017 a las 16:00, doblett escribió:
> Muchas gracias a todos por las sugerencias y por la rápida respuesta.
> Mi impresión es que no tenemos una solución cómoda para este tema y al
> menos en mi día a día es muy útil.
>
> - Tables, funciona muy bien con latex y se pueden llegar a hacer tablas
> muy completas. El problema no está en la tabla sino en el formato de
> documento. Si en la oficina le doy el informe a mi jefe en latex se va a
> quedar a cuadros. Necesitamos volcar la tabla a un documento que
> posteriormente se pueda editar para incorporar texto.
> - Stargazer, cuenta con similares prestaciones que tables y con las
> similares carencias en cuanto al formato de salida del documento.
>
> Por lo que veo, salvo que alguien tenga otra forma de trabajar esto, lo
> tenemos complicado. Sacar las tablas por pantalla no es tan difícil, el
> problema lo tenemos para llevárnoslas a un documento fácilmente editable
> tipo ODF. R markdown da muchas facilidades cuando se trata de texto,
> podemos obtener el mismo documento en tres formatos diferentes (HTML, PDF y
> ODF) casi sin esfuerzo, pero con tablas la cosa se complica.
>
> Si no es posible crear las tablas "al vuelo" en formatos "editables a
> posteriori" y alguien tiene una forma de trabajar que pueda ser útil,
> también será bienvenida.
>
>
> Saludos.
> doblett.
>



Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso-confidencialidad
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Plot MArginal distribution in the correct place

2017-06-07 Thread Pedro páramo
Please, I'm trying to put the right plot higher and centered on the left
values but I don't achive.

I would appreciate so much your help

El 6 jun. 2017 22:37, "Pedro páramo"  escribió:

> Hi all,
>
> I have this code, but the marginal distribution plot doesn´t appear
> aligned with the left plot.
>
>
> I think could be something about layout or par() mar.
>
> The code was programmed by me time ago.
>
> Can anyone help me to get the marginal distribution on the center (more
> higher centered)
>
> id.txt
>
> Could have this code:
>
> 05/01/2016;9335,200195
> 06/01/2016;9197,400391
> 07/01/2016;9059,299805
> 08/01/2016;8909,200195
> 11/01/2016;8886,099609
> 12/01/2016;8915,400391
> 13/01/2016;8934,5
> 14/01/2016;8787,700195
> 15/01/2016;8543,599609
> 18/01/2016;8469,299805
> 19/01/2016;8554,900391
> 20/01/2016;8281,400391
> 21/01/2016;8444,200195
> 22/01/2016;8722,900391
> 25/01/2016;8567,700195
> 26/01/2016;8692,5
> 27/01/2016;8741
>
>
>
> g<-read.table("id.txt", col.names=c("Dateh","LAST"), sep=";", dec=",")
>
> N=5000
> B=24
> ghy<-nrow(g)
> r<-as.numeric(as.character(g$LAST[ghy]))
>
>
> nf<-layout(matrix(c(1,1,1,1,2,2),1,6,byrow=TRUE))
>
> par(mar=c(6,6,6,0.5))
>
> A<-matrix(1:B,B,N);
>
>
>
> sigma<-0.06;
>
>
>
> mu<-0.00;
>
>
> Z<-r*exp((mu-0.5*((sigma)^2)*A) +sigma*(sqrt(A))*matrix( rnorm(N*B,0,1),
> B, N))
>
> real1<-g$LAST[1:nrow(g)]
>
> real2<-matrix(NA,nrow(g),N-1)
>
> real<-cbind(real1,real2)
>
>
>
>
> Po<-r*matrix(1,1,N);
>
>
>
> Sim<-rbind(Po,Z)
> Simulation<-rbind(real,Z)
>
>
>
>
>
>
> par(mar=c(10,6,6,6))
> matplot(Simulation,type="l",ylim=c(0,4))
>
> abline(h = 8000, lwd = 2, col = "black")
>
> abline(h = 12000, lwd = 2, col = "black")
> title("Dinamic Montecarlo Simulation 2 years ahead",font=4)
>
> fhist<-hist(Simulation,plot=FALSE)
> par(mar=c(6,0,6,6))
> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray")
> grid()
> title("Marginal Distribution",font=4)
>
>
> rect(0, 0, 0, 0) # transparent
>
>

[[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] Getting forecast values using DCC GARCH fit

2017-06-07 Thread Dhivya Narayanasamy
Hi,
I am trying to fit a multivariate time series model using DCC GARCH model
and forecast it.

The data looks like this:

> head(datax)
x   vibration_x Speed
1 2017-05-16 17:53:00  -0.132  421.4189
2 2017-05-16 17:54:00  -0.296 1296.8882
3 2017-05-16 17:55:00  -0.5720.
4 2017-05-16 17:56:00  -0.736 1254.2695
5 2017-05-16 17:57:00   0.0000.
6 2017-05-16 17:58:00   0.0000.

> garch11.spec = ugarchspec(mean.model = list(armaOrder = c(1,1)),
   variance.model = list(garchOrder = c(1,1),
  model = "sGARCH"),
distribution.model = "norm")
> dcc.garch11.spec = dccspec(uspec = multispec( replicate(2, garch11.spec)
),
  dccOrder = c(1,1), distribution = "mvnorm")
> fit.a = dccfit(dcc.garch11.spec, data = datax[,c(2,3)], out.sample = 500,
 fit.control = list(eval.se=T))
> dcc.focast=dccforecast(fit.a, n.ahead = 1, n.roll = 499)

May I know how to get the forecast values from 'dcc.focast' ?  I have given
500 as n.roll in rolling forecast. I mean where to find this 500 forecast
values? Any help is much appreciated as I am new to GARCH model.

Also when i plot the forecast model
> plot(dcc.focast, which = 1)

The graph shows weird x axis values starting from 2050 year. Is the graph
showing the forecast values? I have attached the graph as well for your
reference. Thanks in advance.





Regards| Mit freundlichen Grüßen,
> Dhivya Narayanasamy
__
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] Plot MArginal distribution in the correct place

2017-06-07 Thread Pedro páramo
Hi all,

I have this code, but the marginal distribution plot doesn´t appear aligned
with the left plot.


I think could be something about layout or par() mar.

The code was programmed by me time ago.

Can anyone help me to get the marginal distribution on the center (more
higher centered)

id.txt

Could have this code:

05/01/2016;9335,200195
06/01/2016;9197,400391
07/01/2016;9059,299805
08/01/2016;8909,200195
11/01/2016;8886,099609
12/01/2016;8915,400391
13/01/2016;8934,5
14/01/2016;8787,700195
15/01/2016;8543,599609
18/01/2016;8469,299805
19/01/2016;8554,900391
20/01/2016;8281,400391
21/01/2016;8444,200195
22/01/2016;8722,900391
25/01/2016;8567,700195
26/01/2016;8692,5
27/01/2016;8741



g<-read.table("id.txt", col.names=c("Dateh","LAST"), sep=";", dec=",")

N=5000
B=24
ghy<-nrow(g)
r<-as.numeric(as.character(g$LAST[ghy]))


nf<-layout(matrix(c(1,1,1,1,2,2),1,6,byrow=TRUE))

par(mar=c(6,6,6,0.5))

A<-matrix(1:B,B,N);



sigma<-0.06;



mu<-0.00;


Z<-r*exp((mu-0.5*((sigma)^2)*A) +sigma*(sqrt(A))*matrix( rnorm(N*B,0,1), B,
N))

real1<-g$LAST[1:nrow(g)]

real2<-matrix(NA,nrow(g),N-1)

real<-cbind(real1,real2)




Po<-r*matrix(1,1,N);



Sim<-rbind(Po,Z)
Simulation<-rbind(real,Z)






par(mar=c(10,6,6,6))
matplot(Simulation,type="l",ylim=c(0,4))

abline(h = 8000, lwd = 2, col = "black")

abline(h = 12000, lwd = 2, col = "black")
title("Dinamic Montecarlo Simulation 2 years ahead",font=4)

fhist<-hist(Simulation,plot=FALSE)
par(mar=c(6,0,6,6))
barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray")
grid()
title("Marginal Distribution",font=4)


rect(0, 0, 0, 0) # transparent

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