[R-es] Operaciones entre variables de un dataframe

2017-08-15 Thread David Contreras
Buenas noches a todos,

Estoy empezando con la programación en R y tengo un inconveniente que estoy
seguro ustedes lo resolverán muy fácil.

Tengo un data frame  y quiero calcular un nuevo campo dentro del mismo
frame que se llama "wryB03", con dos variables que se llaman "nEstCoordTMin"
y "nEstCoordTMax", quiero crear una variable nueva "nCoor3.1" de acuerdo a
la siguiente condición:

- Cuando "nEstCoordTMin" >0 & "nEstCoordTMax">0 que me haga la siguiente
operación en la variable "nCoor3.1"

-  "nEstCoordTMax" - "nEstCoordTMin"


En el código tengo algo como:

wryB03[(wryB03[,"nEstCoordTMin"]>0 & wryB03[,"nEstCoordTMax"]>0),
"nCoor3.1"] <- wryB03[(wryB03[,"nEstCoordTMin"]>0 &
wryB03[,"nEstCoordTMax"]>0),(wryB03[,"nEstCoordTMax"] -
wryB03[,"nEstCoordTMin"])]

El objetivo es crear una variable nueva "nCoor3.1" con la diferencia "
nEstCoordTMax"- "nEstCoordTMin " cuando se cumpla la condición.

Al ejecutar el código genera el siguiente error:

Warning message:
In `[<-.data.frame`(`*tmp*`, (wryB03[, "nEstCoordTMin"] > 0 & wryB03[,  :
  provided 65 variables to replace 1 variables


Agradezco su colaboración.

Saludos,

[[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] Statistical / data mining methods in R and not in SAS?

2017-08-15 Thread David Winsemius

> On Aug 14, 2017, at 12:22 PM, fs  wrote:
> 
> Hi, and sorry for asking such an unspecific question.
> 
> Does anybody know of statistical / data mining methods that are available in 
> R 
> that are not in SAS ? With SAS I mean the SAS System Version 9.4 and SAS 
> Enterprise Miner. I don't expect a complete list, just two or three examples 
> or hints where and what to look for.
> 
> I found some older comparisons, and the R methods mentioned there (GLMET, RF, 
> ADABoost) are now supported by SAS (at least to some degree).
> 
> And there exists a (massive) list of available models for the caret package 
> here: https://rdrr.io/cran/caret/man/models.html, but it's hard to analyze 
> the 
> complete list.
> 
> (I'm trying to answer a question of a colleague).

It wasn't clear whether it was statistical procedures themselves or connections 
to back-end data and machine learning packages might be the metric of 
comparison. I also thought the question would have been better posted on a SAS 
website, since the CRAN Task Views provide an even more complete listing and 
most of us are not current users of the SAS Enterprise Miner Suite. The SAS 
users might have a better notion of their capacities and limitations.

You might start by comparing:

1) 
https://www.sas.com/content/dam/SAS/en_us/doc/factsheet/sas-enterprise-miner-101369.pdf

... although that did not appear to be a comprehensive listing of available 
model types.

With:

2a) https://cran.r-project.org/web/views/MachineLearning.html
2b) https://cran.r-project.org/web/views/Bayesian.html
2c) https://cran.r-project.org/web/views/ExtremeValue.html
2d) https://cran.r-project.org/web/views/FunctionalData.html
2e) https://cran.r-project.org/web/views/Robust.html
2f) https://cran.r-project.org/web/views/SpatioTemporal.html
2g) https://cran.r-project.org/web/views/Spatial.html

Left out several Task Views since they might be probably too "ordinary", but 
you should look at all of them:
https://cran.r-project.org/web/views/


Other websites possibly outlining areas of possible difference:

https://tensorflow.rstudio.com/

https://blog.rstudio.com/2016/09/27/sparklyr-r-interface-for-apache-spark/

https://spark.rstudio.com/reference/sparklyr/latest/ml_multilayer_perceptron.html

https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/TensorFlow-MNIST/td-p/318708

https://thomaswdinsmore.com/2017/04/05/sas-peddles-open-source-fud/



-- 
David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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] Promedio elementos vector SOLUCIONADO

2017-08-15 Thread Manuel Máquez
Carlos, nuevamente te agradezco tu intervención; con la modificación que me
diste ya quedó solucionado mi problema.
Atentamente;
*MANOLO MÁRQUEZ P.*

[[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] Shiny install failed

2017-08-15 Thread William Dunlap via R-help
Does
   install.packages("shiny", type="binary")
work any better?

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Aug 15, 2017 at 10:12 AM, Zack Haney  wrote:

> Yes windows
>
> How can i install from zip?
>
> Here is my command
>
> > install.packages("shiny")
> Installing package into ‘C:/Users/Zack/Documents/R/win-library/3.4’
> (as ‘lib’ is unspecified)
>
>   There is a binary version available but the
>   source version is later:
>   binary source needs_compilation
> shiny  1.0.3  1.0.4 FALSE
>
> installing the source package ‘shiny’
>
> trying URL 'https://cran.rstudio.com/src/contrib/shiny_1.0.4.tar.gz'
> Content type 'application/x-gzip' length 2329723 bytes (2.2 MB)
> downloaded 2.2 MB
>
> Warning in install.packages :
>   running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l
> "C:\Users\Zack\Documents\R\win-library\3.4"
> C:\Users\Zack\AppData\Local\Temp\Rtmp27A7LV/downloaded_
> packages/shiny_1.0.4.tar.gz'
> had status 65535
> Warning in install.packages :
>   installation of package ‘shiny’ had non-zero exit status
>
> The downloaded source packages are in
> ‘C:\Users\Zack\AppData\Local\Temp\Rtmp27A7LV\downloaded_packages’
>
> On Tue, Aug 15, 2017 at 1:11 PM, Michael Dewey 
> wrote:
>
> > Dear Zack
> >
> > At a guess you are on Windows and instead of installing from the zip file
> > you are trying to install from source. If you do not grasp the difference
> > try posting again showing us exactly what command you used and confirm
> your
> > operating system Please also post in plain text not HTML as your message
> > may get scrambled in transit.
> >
> > On 15/08/2017 14:11, Zack Haney wrote:
> >
> >> Very New to R trying to get setup but when i try to install shiny i get
> >>
> >> trying URL 'http://cran.rstudio.com/src/contrib/shiny_1.0.4.tar.gz'
> >> Content type 'application/x-gzip' length 2329723 bytes (2.2 MB)
> >> downloaded 2.2 MB
> >>
> >> Warning in install.packages :
> >>   running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l
> >> "C:\Users\Zack\Documents\R\win-library\3.4"
> >> C:\Users\Zack\AppData\Local\Temp\RtmpYhM8h8/downloaded_packa
> >> ges/shiny_1.0.4.tar.gz'
> >> had status 65535
> >> Warning in install.packages :
> >>   installation of package ‘shiny’ had non-zero exit status
> >>
> >> [[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.
> >>
> >> ---
> >> This email has been checked for viruses by AVG.
> >> http://www.avg.com
> >>
> >>
> > --
> > Michael
> > http://www.dewey.myzen.co.uk/home.html
> >
>
> [[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.

[[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] Shiny install failed

2017-08-15 Thread Zack Haney
Yes windows

How can i install from zip?

Here is my command

> install.packages("shiny")
Installing package into ‘C:/Users/Zack/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)

  There is a binary version available but the
  source version is later:
  binary source needs_compilation
shiny  1.0.3  1.0.4 FALSE

installing the source package ‘shiny’

trying URL 'https://cran.rstudio.com/src/contrib/shiny_1.0.4.tar.gz'
Content type 'application/x-gzip' length 2329723 bytes (2.2 MB)
downloaded 2.2 MB

Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l
"C:\Users\Zack\Documents\R\win-library\3.4"
C:\Users\Zack\AppData\Local\Temp\Rtmp27A7LV/downloaded_packages/shiny_1.0.4.tar.gz'
had status 65535
Warning in install.packages :
  installation of package ‘shiny’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\Zack\AppData\Local\Temp\Rtmp27A7LV\downloaded_packages’

On Tue, Aug 15, 2017 at 1:11 PM, Michael Dewey 
wrote:

> Dear Zack
>
> At a guess you are on Windows and instead of installing from the zip file
> you are trying to install from source. If you do not grasp the difference
> try posting again showing us exactly what command you used and confirm your
> operating system Please also post in plain text not HTML as your message
> may get scrambled in transit.
>
> On 15/08/2017 14:11, Zack Haney wrote:
>
>> Very New to R trying to get setup but when i try to install shiny i get
>>
>> trying URL 'http://cran.rstudio.com/src/contrib/shiny_1.0.4.tar.gz'
>> Content type 'application/x-gzip' length 2329723 bytes (2.2 MB)
>> downloaded 2.2 MB
>>
>> Warning in install.packages :
>>   running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l
>> "C:\Users\Zack\Documents\R\win-library\3.4"
>> C:\Users\Zack\AppData\Local\Temp\RtmpYhM8h8/downloaded_packa
>> ges/shiny_1.0.4.tar.gz'
>> had status 65535
>> Warning in install.packages :
>>   installation of package ‘shiny’ had non-zero exit status
>>
>> [[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.
>>
>> ---
>> This email has been checked for viruses by AVG.
>> http://www.avg.com
>>
>>
> --
> Michael
> http://www.dewey.myzen.co.uk/home.html
>

[[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] Contar palabras sin tener en cuenta observaciones con NA

2017-08-15 Thread Javier Marcuzzi
Estimada Miriam Alzate

¿Puede explicar lo que desea y la herramienta?, en otros términos, si está 
realizando un text mining, con una herramienta para tal fin, o cuenta las 
variables donde cada palabra, punto o NA son factores, el factor palabra, el 
factor punto, el factor desconocido.

Una solución es usar expresiones regulares, pero siempre hay muchas formas de 
trabajo.

Javier Rubén Marcuzzi

De: miriam.alz...@unavarra.es
Enviado: martes, 15 de agosto de 2017 15:39
Para: r-help-es@r-project.org
Asunto: [R-es] Contar palabras sin tener en cuenta observaciones con NA

Buenas a todos,

Necesito crear una variable "Numero.palabras" que sea el número de
palabras de la variable "titulo". Al crearla, cuando en la variable
"titulo" aparece un NA, me cuenta como 1 palabra. Por otro lado, los
puntos o / también los cuenta como palabras. ¿Me podrías ayudar con el
comando que tengo que meter para que me de el resultado correcto?

Muchas gracias

___
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] Contar palabras sin tener en cuenta observaciones con NA

2017-08-15 Thread miriam . alzate
Buenas a todos,

Necesito crear una variable "Numero.palabras" que sea el número de
palabras de la variable "titulo". Al crearla, cuando en la variable
"titulo" aparece un NA, me cuenta como 1 palabra. Por otro lado, los
puntos o / también los cuenta como palabras. ¿Me podrías ayudar con el
comando que tengo que meter para que me de el resultado correcto?

Muchas gracias

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


Re: [R] Shiny install failed

2017-08-15 Thread Michael Dewey

Dear Zack

At a guess you are on Windows and instead of installing from the zip 
file you are trying to install from source. If you do not grasp the 
difference try posting again showing us exactly what command you used 
and confirm your operating system Please also post in plain text not 
HTML as your message may get scrambled in transit.


On 15/08/2017 14:11, Zack Haney wrote:

Very New to R trying to get setup but when i try to install shiny i get

trying URL 'http://cran.rstudio.com/src/contrib/shiny_1.0.4.tar.gz'
Content type 'application/x-gzip' length 2329723 bytes (2.2 MB)
downloaded 2.2 MB

Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l
"C:\Users\Zack\Documents\R\win-library\3.4"
C:\Users\Zack\AppData\Local\Temp\RtmpYhM8h8/downloaded_packages/shiny_1.0.4.tar.gz'
had status 65535
Warning in install.packages :
  installation of package ‘shiny’ had non-zero exit status

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

---
This email has been checked for viruses by AVG.
http://www.avg.com



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
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] Lattice Histogram Scaling

2017-08-15 Thread Richard M. Heiberger
The original was conditioning the entire histogram, not just the kernel
estimate, on bw.  I am assuming that the bw in the condition should be
bandwidths.

What you want is easily done by using the latticeExtra package.
This works from a new R session:


url <- "http://www.econ.uiuc.edu/~roger/research/ebayes/velo.d;
x <- scan(url,skip = 1)
bandwidths <- (1:4)*10

library(latticeExtra)

H <- histogram( ~ x, nint = 100, border = grey(.9), col = grey(.9),
   type = "density")

DD <- lapply(bandwidths, FUN=density, x=x)

DDplot <- lapply(DD, FUN=function(bw) xyplot(y ~ x, data=bw, type="l",
col="blue", lwd=1.5))
names(DDplot) <- bandwidths

do.call(c, DDplot) ## warning message that I am not chasing down

DDplot.together <- do.call(c, c(DDplot, list(x.same = TRUE, y.same = TRUE)))
DDplot.together + H  ## wrong plot on top

DDplot.together.H <- c(H+DDplot[[1]], H+DDplot[[2]], H+DDplot[[3]],
H+DDplot[[4]], x.same = TRUE, y.same = TRUE)
dimnames(DDplot.together.H)[[1]] <- as.character(bandwidths)
DDplot.together.H <- update(DDplot.together.H, strip=TRUE)
DDplot.together.H ## correct plot on top



On Tue, Aug 15, 2017 at 10:13 AM, Roger Koenker  wrote:
> My apologies,  the data can now be found at:
>
> url <- "http://www.econ.uiuc.edu/~roger/research/ebayes/velo.d;
> x <- scan(url,skip = 1)
>
> If I could get each of the histograms to mimic what is produced by
>
> hist(x, 100, freq = FALSE)
>
> I’ve experimented with xlim, ylim, without success so far...
>
> url:www.econ.uiuc.edu/~rogerRoger Koenker
> emailrkoen...@uiuc.eduDepartment of Economics
> vox: 217-333-4558University of Illinois
> fax:   217-244-6678Urbana, IL 61801
>
>> On Aug 14, 2017, at 8:36 PM, Richard M. Heiberger  wrote:
>>
>> Your example is not easily reproducible.
>> The REBayes requires Rmosek which requires a system command MOSEK.
>> Please try again with an example using data in base R.
>>
>> Meanwhile, my guess is that you will need to do something like
>> explicitly specifying xlim and ylim so all panels have the same
>> limits.
>>
>> On Mon, Aug 14, 2017 at 5:41 PM, Roger Koenker  wrote:
>>> I am trying to do some comparisons of density estimators using lattice.
>>> The code below attempts to plot the same histogram in each panel and
>>> then overplots a kernel estimate with different bandwidths. Finding
>>> packet.number() was a bit arduous, but seems to do what I want.  My
>>> concern now is that close examination of the 4 histograms reveals that
>>> they are different even though they use the same data, and use the
>>> same binning.  Can someone explain this, or better yet suggest a fix?
>>> Admittedly, the kernel estimates are rather silly, they are just standing
>>> in for something else that I would like to think is less silly.
>>>
>>> Many thanks,
>>> Roger
>>>
>>>
>>> require(REBayes)  # Source for the velo data
>>> require(lattice)
>>> x <- velo
>>> x <- x[!(x == 0)]
>>> bandwidths <- (1:4)*10
>>> lp <- histogram(~x|bw, nint = 100, border = grey(.9), col = grey(.9),
>>>type = "density", panel = function(x, bw = bandwidths, ...){
>>>panel.histogram(x, ...)
>>>f <- density(x, bw[packet.number()])
>>>panel.lines(f$x, f$y, col = "blue", lwd = 1.5)
>>>})
>>> print(lp)
>>>
>>>
>>> url:www.econ.uiuc.edu/~rogerRoger Koenker
>>> emailrkoen...@uiuc.eduDepartment of Economics
>>> vox: 217-333-4558University of Illinois
>>> fax:   217-244-6678Urbana, IL 61801
>>>
>>> __
>>> 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-es] Variables cuadráticas en modelos ZINB

2017-08-15 Thread miriam . alzate
Buenas tardes,

¿Se pueden introducir variables cuadráticas en modelos de binomiales
negativos de ceros inflados (ZINB)? He metido una y me da error, al
quitarla, el modelo va bien. Si no se puede, ¿cuál es la razón?

Muchas gracias!

Miriam

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


Re: [R] Statistical / data mining methods in R and not in SAS?

2017-08-15 Thread Zhang, Yuwei

This is very interesting.
Anyone else want to weigh in on this?

Thanks,

Yuwei Zhang
SAS Programmer
Office:  410-645-9256
E-mail:  yuwei.zh...@cvp.hcqis.org

CVP
3701 Pender Drive, Suite 200 | Fairfax, VA 22030
www.cvpcorp.com 
Named Top Workplaces 2017 in Washington Post 



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of fs
Sent: Monday, August 14, 2017 3:22 PM
To: r-help@r-project.org
Subject: [R] Statistical / data mining methods in R and not in SAS?

Hi, and sorry for asking such an unspecific question.

Does anybody know of statistical / data mining methods that are available in R 
that are not in SAS ? With SAS I mean the SAS System Version 9.4 and SAS 
Enterprise Miner. I don't expect a complete list, just two or three examples or 
hints where and what to look for.

I found some older comparisons, and the R methods mentioned there (GLMET, RF,
ADABoost) are now supported by SAS (at least to some degree).

And there exists a (massive) list of available models for the caret package
here: https://rdrr.io/cran/caret/man/models.html, but it's hard to analyze the 
complete list.

(I'm trying to answer a question of a colleague).

Thanks,
Friedrich

__
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] ANOVA test to decide whether to use multiple linear regression or linear mixed effects model

2017-08-15 Thread S Ellison
> I am trying to decide between using a multiple linear regression or a linear
> mixed effects model for my data:
> ... 
> but I keep getting the following error code:
> 
> Error in anova.lmlist (object, ...):
> 
> models were not all fitted to the same size of dataset

anova is defaulting to anova.lm, and that doesn't expect a mixed effects model.

Switch them round to put model2 first:

anova (model2, model1)


S Ellison



***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] Lattice Histogram Scaling

2017-08-15 Thread Roger Koenker
My apologies,  the data can now be found at:

url <- "http://www.econ.uiuc.edu/~roger/research/ebayes/velo.d;
x <- scan(url,skip = 1)

If I could get each of the histograms to mimic what is produced by

hist(x, 100, freq = FALSE)

I’ve experimented with xlim, ylim, without success so far...

url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Urbana, IL 61801

> On Aug 14, 2017, at 8:36 PM, Richard M. Heiberger  wrote:
> 
> Your example is not easily reproducible.
> The REBayes requires Rmosek which requires a system command MOSEK.
> Please try again with an example using data in base R.
> 
> Meanwhile, my guess is that you will need to do something like
> explicitly specifying xlim and ylim so all panels have the same
> limits.
> 
> On Mon, Aug 14, 2017 at 5:41 PM, Roger Koenker  wrote:
>> I am trying to do some comparisons of density estimators using lattice.
>> The code below attempts to plot the same histogram in each panel and
>> then overplots a kernel estimate with different bandwidths. Finding
>> packet.number() was a bit arduous, but seems to do what I want.  My
>> concern now is that close examination of the 4 histograms reveals that
>> they are different even though they use the same data, and use the
>> same binning.  Can someone explain this, or better yet suggest a fix?
>> Admittedly, the kernel estimates are rather silly, they are just standing
>> in for something else that I would like to think is less silly.
>> 
>> Many thanks,
>> Roger
>> 
>> 
>> require(REBayes)  # Source for the velo data
>> require(lattice)
>> x <- velo
>> x <- x[!(x == 0)]
>> bandwidths <- (1:4)*10
>> lp <- histogram(~x|bw, nint = 100, border = grey(.9), col = grey(.9),
>>type = "density", panel = function(x, bw = bandwidths, ...){
>>panel.histogram(x, ...)
>>f <- density(x, bw[packet.number()])
>>panel.lines(f$x, f$y, col = "blue", lwd = 1.5)
>>})
>> print(lp)
>> 
>> 
>> url:www.econ.uiuc.edu/~rogerRoger Koenker
>> emailrkoen...@uiuc.eduDepartment of Economics
>> vox: 217-333-4558University of Illinois
>> fax:   217-244-6678Urbana, IL 61801
>> 
>> __
>> 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] ANOVA test to decide whether to use multiple linear regression or linear mixed effects model

2017-08-15 Thread Lucy McMahon
R-help:


I am trying to decide between using a multiple linear regression or a linear 
mixed effects model for my data:


model1 <- lm (responsevariable ~ predictor1 + predictor2 + predictor3 + 
predictor4, data= data)

model2 <- lme (responsevariable ~ predictor1 + predictor2 + predictor3 + 
predictor4, random = ~1 | site, data= data)


anova (model1, model2)


but I keep getting the following error code:

Error in anova.lmlist (object, ...):

models were not all fitted to the same size of dataset


Any advice would be appreciated, thanks.



[[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] Shiny install failed

2017-08-15 Thread Zack Haney
Very New to R trying to get setup but when i try to install shiny i get

trying URL 'http://cran.rstudio.com/src/contrib/shiny_1.0.4.tar.gz'
Content type 'application/x-gzip' length 2329723 bytes (2.2 MB)
downloaded 2.2 MB

Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l
"C:\Users\Zack\Documents\R\win-library\3.4"
C:\Users\Zack\AppData\Local\Temp\RtmpYhM8h8/downloaded_packages/shiny_1.0.4.tar.gz'
had status 65535
Warning in install.packages :
  installation of package ‘shiny’ had non-zero exit status

[[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] Promedio elementos vector

2017-08-15 Thread Carlos Ortega
Hola Manuel,

No había visto que el resultado era una matriz traspuesta...
He modificado el código para corregirlo y para obtener un resultado con 5
decimales.

No se puede usar la función "rowsum()" porque es una función para calcular
sumas teniendo un criterio de agrupación que en este caso, no existe.
Tampoco la alternativa de "rowSums()" funcionaría porque trabaja sobre
data.frames y en la función solo se calcula la suma de una fila... Así que
en este caso, dejo el cálculo de la función como estaba inicialmente.

#--
datIn <- read.table("ContaC.csv", header = TRUE, sep =",", as.is = TRUE)
datIn$X <- NULL

myfun <- function(x) {
  val_sum <- sum(x)
  x_avg <- round(x/val_sum,5)
  return(x_avg)
}

datOut <- apply(datIn, 1, myfun)
datEnd <- as.data.frame(t(datOut))
#-

Saludos,
Carlos Ortega
www.qualityexcellence.es




El 15 de agosto de 2017, 4:19, Manuel Máquez 
escribió:

> Carlos, nuevamente muchas gracias, la solución que me diste quedó con una
> pequeña modificación; usé rowsum(x) en lugar de sum.
> Me quedan unas dudas:
> a) Los resultados me quedan en columnas y no en renglones ??.
> b) Me da 'Error in rowsum.default(x)  el argumento "group" está ausente,
> sin valor por omisión'. ¿Qué se debe corregir?
> c) ¿Es posible que los resultados queden en 5 decimales?
> Atentamente;
> *MANOLO MÁRQUEZ P.*
>
> [[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] [R-pkgs] OHPL - new package for group variable selection

2017-08-15 Thread Nan Xiao
Dear useRs,

- I am pleased to announce that the R package OHPL is now available on
CRAN (https://CRAN.R-project.org/package=OHPL).

The package implements the ordered homogeneity pursuit lasso (OHPL)
algorithm for group variable selection proposed in Lin et al. (2017)
. The OHPL method exploits the
homogeneity structure in high-dimensional data and enjoys the grouping
effect to select groups of important variables automatically. This
feature makes it particularly useful for high-dimensional datasets with
strongly correlated variables, such as spectroscopic data.

For more information, please see https://OHPL.io.

Cheers,
-Nan

-- 
https://nanx.me

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

__
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] ncdf4: Why are NAs converted to _FillValue when saving?

2017-08-15 Thread raphael.felber
Dear Dave

Thanks a lot for your answer. I agree that it is more an R issue than a package 
issue. But it's the first time I encountered such a problem.

For my R version (v3.4.1) on x86_64-w64-mingw32 the second part of your answer 
only holds for data_temp2; if I do any manipulation to data_temp2 before using 
ncvar_put(…, data_temp) then data_temp2 remains. However this doesn't hold for 
data_temp; after using ncvar_put(…, data_temp), the NAs in data_temp are 
converted to _FillValues (-999.99). For clarification I added two examples 
below.

Regards

Raphael


Examples:

> # *
> # without data manipulation
> # *
>
> # copy data
> data_temp2 <- data_temp
>
> # show what we have
> data_temp[1:5, 1:5, 1]
   [,1]   [,2]  [,3]   [,4]   [,5]
[1,] NA NANA 0.03887696 0.04786269
[2,] NA NANA 0.07736548 0.09524715
[3,] NA NANA 0.11508099 0.14167993
[4,] NA NANA 0.15164665 0.18669710
[5,] 0.04786269 0.09524715 0.1416799 0.18669710 0.22984885
>
> data_temp2[1:5, 1:5, 1]
   [,1]   [,2]  [,3]   [,4]   [,5]
[1,] NA NANA 0.03887696 0.04786269
[2,] NA NANA 0.07736548 0.09524715
[3,] NA NANA 0.11508099 0.14167993
[4,] NA NANA 0.15164665 0.18669710
[5,] 0.04786269 0.09524715 0.1416799 0.18669710 0.22984885
>
> # write to netCDF connection
> ncvar_put( ncid_new, var_temp, data_temp )
>
> # show what we have
> data_temp[1:5, 1:5, 1]
  [,1]  [,2] [,3]   [,4]   [,5]
[1,] -999.9900 -999.9900 -999.990 0.03887696 0.04786269
[2,] -999.9900 -999.9900 -999.990 0.07736548 0.09524715
[3,] -999.9900 -999.9900 -999.990 0.11508099 0.14167993
[4,] -999.9900 -999.9900 -999.990 0.15164665 0.18669710
[5,]0.047862690.095247150.1416799 0.18669710 0.22984885
>
> data_temp2[1:5, 1:5, 1]
  [,1]  [,2] [,3]   [,4]   [,5]
[1,] -999.9900 -999.9900 -999.990 0.03887696 0.04786269
[2,] -999.9900 -999.9900 -999.990 0.07736548 0.09524715
[3,] -999.9900 -999.9900 -999.990 0.11508099 0.14167993
[4,] -999.9900 -999.9900 -999.990 0.15164665 0.18669710
[5,]0.047862690.095247150.1416799 0.18669710 0.22984885




> # *
> # with data manipulation
> # *
>
> # show what we have
> data_temp[1:5, 1:5, 1]
   [,1]   [,2]  [,3]   [,4]   [,5]
[1,] NA NANA 0.03887696 0.04786269
[2,] NA NANA 0.07736548 0.09524715
[3,] NA NANA 0.11508099 0.14167993
[4,] NA NANA 0.15164665 0.18669710
[5,] 0.04786269 0.09524715 0.1416799 0.18669710 0.22984885
>
> data_temp2[1:5, 1:5, 1]
   [,1]   [,2]  [,3]   [,4]   [,5]
[1,] NA NANA 0.03887696 0.04786269
[2,] NA NANA 0.07736548 0.09524715
[3,] NA NANA 0.11508099 0.14167993
[4,] NA NANA 0.15164665 0.18669710
[5,] 0.04786269 0.09524715 0.1416799 0.18669710 0.22984885
>
> # do some manipulations
> data_temp <- data_temp * 1.0
> data_temp2 <- data_temp2 * 1.0
>
> # write to netCDF connection
> ncvar_put( ncid_new, var_temp, data_temp )
>
> # show what we have
> data_temp[1:5, 1:5, 1]
  [,1]  [,2] [,3]   [,4]   [,5]
[1,] -999.9900 -999.9900 -999.990 0.03887696 0.04786269
[2,] -999.9900 -999.9900 -999.990 0.07736548 0.09524715
[3,] -999.9900 -999.9900 -999.990 0.11508099 0.14167993
[4,] -999.9900 -999.9900 -999.990 0.15164665 0.18669710
[5,]0.047862690.095247150.1416799 0.18669710 0.22984885
>
> data_temp2[1:5, 1:5, 1]
   [,1]   [,2]  [,3]   [,4]   [,5]
[1,] NA NANA 0.03887696 0.04786269
[2,] NA NANA 0.07736548 0.09524715
[3,] NA NANA 0.11508099 0.14167993
[4,] NA NANA 0.15164665 0.18669710
[5,] 0.04786269 0.09524715 0.1416799 0.18669710 0.22984885
>
>
> # *
> # RESULT
> # with manipulation of data_temp2 the variable is copied and NAs remain NAs
> # but manipulation of data_temp doesn't help

Von: davidwilliampie...@gmail.com [mailto:davidwilliampie...@gmail.com] Im 
Auftrag von David W. Pierce
Gesendet: Montag, 14. August 2017 17:29
An: Felber Raphael Agroscope 
Cc: r-help@r-project.org
Betreff: Re: [R] ncdf4: Why are NAs converted to _FillValue when saving?

On Mon, Aug 14, 2017 at 5:29 AM, 

Re: [R] Help creating the IBM Randu function

2017-08-15 Thread Martin Maechler
> Richard M Heiberger 
> on Mon, 14 Aug 2017 14:36:40 -0400 writes:

> Please look at ?datasets::randu
> for David Donoho's translation of RANDU into R.

Thanks a lot, Rich,  for pointing to this:

Indeed, the RANDU  aka 'randu' data set has been part of R since
the last millennium (and hence before R reached version 1.0.0).
The help page does mention where we got the data set originally,
namely Dave Donoho.  However, I would bet he did not use R at
the time, and indeed it was Prof Brian Ripley who added the
R code to R sources in 1999


r5632 | ripley | 1999-08-27 08:59:05 +0200 (Fri, 27. Aug 1999)

improve clarity (I hope), add an R example to re-generate this


and yes, indeed

example(randu)

already creates the RANDU data set for you .. since 1999.

One curious thing:
Martin .. Pedersen's Wikipedia page (1) seems to make it clear it
stems from IBM whereas in R's help page   help(randu)
we only mention that we got it through VAX VMS code.


> On Mon, Aug 14, 2017 at 12:49 PM, Martin Møller Skarbiniks Pedersen
>  wrote:
>> Dear all,
>> 
>> I am trying to learn functions in R and 3D plotting so I decided to try
>> to plot
>> the famous bad PRNG Randu from IBM(1).
>> However something is not correct in the function I have created.
>> First I define the function RANDU like this:
>> 
>>> RANDU <-  function(num) { return (65539*num)%%(2^31) }
>> 
>> and test that it works for a seed of 1:
>>> RANDU(1)
>> [1] 65539
>> 
>> but if I want the next value in the sequence I get this number.
>>> (65539*65539)%%(2^31)
>> [1] 393225
>> 
>> However using the RANDU function twice doesn't give the same result as
>> above.
>> 
>>> RANDU(RANDU(1))
>> [1] 4295360521
>> 
>> I expect these two values to be the same but that is not the case.
>> 393225 should be the correct.
>> 
>> I guess it might be something with local vs. global environment ?!
>> 
>> Please advise and thanks.
>> 
>> Regards
>> Martin M. S. Pedersen
>> 
>> (1) https://en.wikipedia.org/wiki/RANDU
>> 
>> [[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.