Re: [R] Help me

2016-03-02 Thread Morteza Firouzi via R-help
 Moses,
If I understand correctly, you are installed R and Rstudio.Please do find the 
package(s) you would like to use.Once you run rstudio, you can search and 
install the package(s) using the bottom right corner menu:Packages> Install> 
install from Repository (Cran)> search the package you would like to use in the 
box below 'Packages',then select the package name, and do not forget to let the 
default settings for "install dependencies", since you're new the R, and 
finally Install the package.
Once the package is downloaded and installed, you can see the name of the 
installed package in the same window. To run it, you have to check the box to 
load the package.You may find the documentation for each package using 
'help()', help(type the package name).For the rest, instead of using "Help me" 
in the subject line, please mention the package name and your problem, and 
explain exactly what would you do in the body.
Good Luck.Morteza
 

On Thursday, March 3, 2016 2:12 PM, Moss Moss  wrote:
 

 Please, I need help from you. I am new to R.

I installed R, Rstudio and R Crans or packages that I will like to
use. Thanks for your help on that.

Right now, what do I do? Will I upload the CRAN packages already
installed, so that a GUI interface will come up.

I am working on Location Model and need some help.

Moses

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


  
[[alternative HTML version deleted]]

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

[R-es] Script con error SOLUCIONADO

2016-03-02 Thread Manuel Máquez
Gracias por la ayuda que me proporcionaron Luisfo Llador, Karel López
Quintero y Carlos Ortega ya está caminando el script; me queda sin embargo
una duda en su funcionamiento, que quedó de esta manera:
j <- 1
sma <- 0
dat <- read.csv('1A.csv')
for(i in 1:length(dat$d)){
 if(dat$d[i] > 5){
j <- j + 1
sma[j] <- 0}
 else{
sma[j] <- sma[j] + 1}
}
La duda consiste en que dat$d[i] tiene así los primeros 11 datos: 5, 3, 5,
7, 1, 1, 4, 2, 14, 10, 3 y sma me da 3, 4, 0, 1, 0, 0, 0, 6, 3, 3,1; pero
entonces entre 3 y 4 debería estar un 0; y después entre 4 y 1 debería
haber 0, 0 y no sólo 0.
Entonces pienso que probablemente 'metí la pata', pero no encuentro donde.
¿Me podrían hacer el favor de volverme a ayudar?
Nuevamente anticipo las gracias más cumplidas.

*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] Extract row form a dataframe by row names in another vector and factor . Need explanation

2016-03-02 Thread Jeff Newmiller
Posting in HTML makes a mess of your code... learn to post in plain text. 

Not sure what you thought you would accomplish by using as.vector... perhaps 
you should read the help file ?as.vector.

Did you look at str( dat1 )?

Factors are more closely akin to integers than to characters. Indexing with 
factors is the same as indexing with the integers that factors are implemented 
with (see the discussion of factors in the Introduction to R document that 
comes with R) than indexing with character strings. If you want character 
indexing,  use character vectors. 

Advice: 98% of the time making a data frame using a matrix causes more damage 
than help. Data frames are a list of columns, each of which potentially has its 
own storage mode. Matrices are all one type, implemented as a folded vector. 
Use named arguments to the data.frame function instead. Also use the 
stringsAsFactors = FALSE argument to data.frame unless you know you won't want 
character strings. 
-- 
Sent from my phone. Please excuse my brevity.

On March 2, 2016 6:05:37 PM PST, Mohammad Tanvir Ahamed via R-help 
 wrote:
>Hi,Here i have written an example to explain my problem
>## Data Generationdat<-data.frame(matrix(1:50,ncol=5))
>rownames(dat)<-letters[1:10]
>colnames(dat)<- c("SA1","SA2","SA3","SA4","SA5")
>
>dat1<-data.frame(matrix(letters[1:20],ncol=4))
>colnames(dat1)<-c("AA","BB","CC","DD")
>
>## Row names
>v1<-dat1[,"BB"]                   # Factor
>v2<-as.vector(dat1[,"BB"])  # Vector
>
>is(v1) # Factor
>is(v2) # Vector
>
># Result
>res1<-dat[v1,]
>res2<-dat[v2,]
>##i assumed
>res1 and res2 are same . but it is not . Can any body please explain
>why ? 
> 
> 
>Tanvir Ahamed 
>Göteborg, Sweden  | mashra...@yahoo.com
>   [[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] Plot multiple similar equations in r

2016-03-02 Thread Berend Hasselman

> On 2 Mar 2016, at 22:22, David L Carlson  wrote:
> 
> Another way would be to use matplot() or matlines():
> 
>> lx<-c(0.4, 0.5, 0.6, 0.7)
>> x <- seq(1, 8, length.out=100)
>> myfun <- function(x, k) {(log(k)-(0.37273*log(x)-1.79389))/0.17941}
>> y <- sapply(lx, function(k) myfun(x, k))
>> matplot(x, a, type="l", col="black", lty=1)
> 
> -

Shouldn't the "a" in the call of matplot  be "y"?

Berend

> 
> 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 Dalthorp, 
> Daniel
> Sent: Wednesday, March 2, 2016 1:05 PM
> To: Jinggaofu Shi
> Cc: r-help@R-project.org (r-help@r-project.org)
> Subject: Re: [R] Plot multiple similar equations in r
> 
> Or, if you want easy labels, you can play around with contour graphs.
> 
> ?contour # will give you info on how to make contour plots
> 
> The basic idea is to construct a matrix of z-values...one z for every
> combination of x and y
> contour(x,y,z)
> 
> The x's would then be the x-values you want in
> (0.37273*log(x)-1.79389))/0.17941 for whatever range of x's you want
> The y's would be values from -5 to 5 (or whatever range you want)
> The z's would be values like 0.4, 0.5, etc. or exp(y + x)
> 
> ?outer # will tell you how to create z from x and y
> 
> x<-seq(1,10,length=100) # values for x-axis
> y<-seq(2, 10, length=100) # values for y-axis
> z<-exp(outer((0.37273*log(x)-1.79389)/0.17941,y,"+"))
> contour(x,y,z,levels=seq(.1,1.1,by=.1))
> 
> -Dan
> 
> On Wed, Mar 2, 2016 at 9:03 AM, Jinggaofu Shi  wrote:
> 
>> Hi, there I am new on R. I want to plot a graph like this.
>> 
>> The curves are created by these equations :
>> (log(0.4)-(0.37273*log(x)-1.79389))/0.17941,
>> (log(0.5)-(0.37273*log(x)-1.79389))/0.17941,
>> (log(0.6)-(0.37273*log(x)-1.79389))/0.17941, etc. The equations are
>> similar, the only difference is the first log(XXX). I already manually draw
>> the graph by repeating plot() for each equation. But I think there must be
>> a way to just assign a simple variable like x<-c(0.4,0.5,0.6,0.7), and then
>> plot all the curves automatically. I tried to use data frame to make a set
>> of equations, but failed. Could somebody help me? Thank you very much!
>> 
>> __
>> 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.
>> 
> 
> 
> 
> -- 
> Dan Dalthorp, PhD
> USGS Forest and Rangeland Ecosystem Science Center
> Forest Sciences Lab, Rm 189
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> ph: 541-750-0953
> ddalth...@usgs.gov
> 
>   [[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.


[R] Help me

2016-03-02 Thread Moss Moss
Please, I need help from you. I am new to R.

I installed R, Rstudio and R Crans or packages that I will like to
use. Thanks for your help on that.

Right now, what do I do? Will I upload the CRAN packages already
installed, so that a GUI interface will come up.

I am working on Location Model and need some help.

Moses

__
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] problema al importar una BD que esta en formato de SPSS

2016-03-02 Thread Javier Marcuzzi
Estimado Eric

Recién veo este sitio, nunca importe SPSS, no puedo compartir experiencia al 
respecto más que enviarle el link por si lo cree útil.

https://github.com/hadley/haven

Javier Rubén Marcuzzi

De: eric
Enviado: lunes, 29 de febrero de 2016 14:51
Para: Lista R
Asunto: [R-es] problema al importar una BD que esta en formato de SPSS

Estimados, tengo que hacer un calculo muy simple, pero con una BD mas o 
menos grande (250mil filas x 500 columnas) ... esta BD esta en formato 
de SPSS y la importo asi:

library(foreign)
bdr <- read.spss("CASEN_2013_MN_B_Principal.sav", 
use.value.labels=FALSE, to.data.frame=TRUE)


luego, quiero transformar el DF en un data.tale pues el calculo requiere 
obtener promedios de acuerdo a ciertos criterios, lo que es muy facil 
especificar con DT y el calculo es bastante rapido tambien ...

pero al tratar de transformar bdr a data.table

bdr <- as.data.table(bdr)


me transforma las columnas con los datos numericos que debo usar, en 
characteres, y al tratar de volverlas a datos numericos con as.numeric() 
me reemplaza todos los datos con NA


que estoy haciendo mal ?

adjunto algunas filas del archivo, muchas gracias,


Eric.



-- 
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city 
standards for living

Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
lectores de correo.


[[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] Extract row form a dataframe by row names in another vector and factor . Need explanation

2016-03-02 Thread Mohammad Tanvir Ahamed via R-help
Hi,Here i have written an example to explain my problem
## Data Generationdat<-data.frame(matrix(1:50,ncol=5))
rownames(dat)<-letters[1:10]
colnames(dat)<- c("SA1","SA2","SA3","SA4","SA5")

dat1<-data.frame(matrix(letters[1:20],ncol=4))
colnames(dat1)<-c("AA","BB","CC","DD")

## Row names
v1<-dat1[,"BB"]                   # Factor
v2<-as.vector(dat1[,"BB"])  # Vector

is(v1) # Factor
is(v2) # Vector

# Result
res1<-dat[v1,]
res2<-dat[v2,]
##i assumed res1 and 
res2 are same . but it is not . Can any body please explain why ? 
 
 
Tanvir Ahamed 
Göteborg, Sweden  | mashra...@yahoo.com
[[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 with step.gam

2016-03-02 Thread sbihorel

Hi,

When very simple models are tested in step.gam, I have observed the some 
difference in the final output result based upon the version of the 
package tested.  Is this an expected behavior or a bug in the latest 
version of the gam package?


With gam 1.4:
> data(gam.data)
> gam.object <- gam(y~1, data=gam.data)
> step.object <- step.gam(gam.object, scope=list(x=c('1','x')))
Start:  y ~ 1; AIC= 232.8823
Trial:  y ~  x; AIC= 126.5148
Step :  y ~ x ; AIC= 126.5148
> step.object
Call:
gam(formula = y ~ x, data = gam.data, trace = FALSE)

Degrees of Freedom: 99 total; 98 Residual
Residual Deviance: 19.53955

With gam 1.9.1 or 1.12:
> data(gam.data)
> gam.object <- gam(y~1, data=gam.data)
> step.object <- step.gam(gam.object, scope=list(x=c('1','x')))
Start:  y ~ 1; AIC= 232.8823
Step:1 y ~ x ; AIC= 126.5148
> step.object
NULL

Thank you

Sebastien

__
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 installing packages: cannot open file '/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf'

2016-03-02 Thread David Winsemius

> On Mar 2, 2016, at 10:00 AM, John Hillier  wrote:
> 
> 
> Dear All,
> 
> 
> I am a relative newbie to R, and am struggling to install packages on my 
> laptop (although I have managed to on my desktop and a borrowed departmental 
> laptop).
> 

The words "my laptop" is rather uninformative. Based on the path below I 
guessing OSX.
> 
> I have tried various packages with the same result. Illustration for
> 
>> install.packages("outliers")
> 
> 
>  leads to .
> 
> 
> Error in file(con, "r") : cannot open the connection
> Calls:  -> sub -> grep -> readLines -> file
> In addition: Warning message:
> In file(con, "r") :
>  cannot open file 
> '/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf': No 
> such file or directory

Installing R inside /sw/.. directory is not a standard location. What does this 
return:

Sys.getenv( "R_HOME" )

On my version of OSX 10.11 with R installed from the "standard" binary 
installer package, it returns
[1] "/Library/Frameworks/R.framework/Resources"

> 
> I have tried in both the R environment on command line, and in RStudio, with 
> the same result, and reinstalled and updated both r-base and rstudio-desktop 
> via fink.

fink  That's probably the reason (again if this is a Mac.) The default 
installation location is not being chosen. I don't understand why you are not 
using the binary installer. I've never seen anyone use fink for installation on 
a Mac but have heard of attempts with MacPorts and homebrew. Simon Urbanek says 
if you use one of those package installers you are "on your own".  That's a 
route you should only consider if you have serious NIX-skills.

>  Both using a CRAN mirror and using a download (outliers_0.14.tar.gz) seem to 
> produce the same result, and I think they're both working as the output says 
> 'downloaded' (see below)
> 
> 
>> install.packages("outliers")
> Installing package into �
> (as � is unspecified)
> --- Please select a CRAN mirror for use in this session ---
> trying URL 'https://mirrors.ebi.ac.uk/CRAN/src/contrib/outliers_0.14.tar.gz'
> Content type 'application/x-gzip' length 15090 bytes (14 KB)
> ==
> downloaded 14 KB
> 
> 
>> From looking aroud on the web it seems that the message "In file(con, "r") : 
>> cannot open file" just means that R cannot find a file it thinks it needs. 
>> However, I've looked in 
>> /sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/ both on this 
>> machine and the other laptop that is able to install packages, and 
>> 'Makeconf' is not in ether of them.

I do have a copy of that program in:

/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf


> 
> 
> So, I'm thoroughly confused and have run out of ideas.

The correct place to post questions about Mac installations is:

r-sig-...@r-project.org

>Please help.
> 
> 
> I hope that this is something simple that I'm missing.  If so, a pointer to a 
> manual page or instructions would be gratefully received.

https://cran.rstudio.com/bin/macosx/

> 
> 
> John
> 
> 
> p.s - Full output in sequence in case it's useful.
> 
> 
>> install.packages("outliers")
> Installing package into �
> (as � is unspecified)
> --- Please select a CRAN mirror for use in this session ---
> trying URL 'https://mirrors.ebi.ac.uk/CRAN/src/contrib/outliers_0.14.tar.gz'
> Content type 'application/x-gzip' length 15090 bytes (14 KB)
> ==
> downloaded 14 KB
> 
> Error in file(con, "r") : cannot open the connection
> Calls:  -> sub -> grep -> readLines -> file
> In addition: Warning message:
> In file(con, "r") :
>  cannot open file 
> '/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf': No 
> such file or directory
> 
> The downloaded source packages are in
>�
> Warning message:
> In install.packages("outliers") :
>  installation of package � had non-zero exit status
> 
> 
> 
> 
> 
> -
> Dr John Hillier
> Senior Lecturer - Physical Geography
> Loughborough University
> 01509 223727
> 
>   [[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.

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] Ruofei Mo - How can I generate correlated data with non-normal distribution?

2016-03-02 Thread Ben Bolker
Ruofei Mo【莫若飞】 <911mruofei  tongji.edu.cn> writes:

> 
> Hi, All,
> 
> I have a question about how to generate correlated data with non-normal
> distribution? Basic, I have a variable a that follows a normal distribution,
> a ~ N(0,1), then I want to generate another variable b that follows a
> uniform distribution, b ~ U(0, 1). Most importantly, I want the correlation
> between a and b to be fixed at -.9, cor(a,b) = -.90
> 
> I tried the following code,
> 
> ### Correlation matrix rmvnorm() function ###
> 

  I don't know that there's a closed-form solution to this problem.
Here's an attempt to do it by brute force.  By eyeball, you need to
set the nominal rho to about -0.92 to get a realized rho of -0.9.

simfun <- function(rho,n=1) {
cormat <- matrix(c(1, rho, rho, 1), ncol = 2)
dd <- setNames(data.frame(MASS::mvrnorm(1000, mu=c(0,0), Sigma=cormat)),
   c("a","trans"))
dd <- transform(dd,
   b=pnorm(trans,mean(trans),sd(trans)))
dd[,c("a","b")]
}

cvec <- seq(-0.999,-0.85,length=51)
res <- expand.grid(rho=cvec,rep=1:10)
set.seed(101)
res$cor <- sapply(res$rho,
  function(r) cor(simfun(rho=r,n1e6))[1,2])

par(las=1,bty="l")
plot(cor~rho,data=res)
abline(a=0,b=1,col=2)
abline(h=-0.9,col=4)
abline(v=-0.92,col=4)
__
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] How to refer a variable in quotes

2016-03-02 Thread Jim Lemon
Hi Jinggaofu,
Try this:

for(u in 1:9) {
 pdffile<-paste(g[u],".pdf",sep="")
 pdf(pdffile)
...
mtext(g[u],side=4)

If you index the vector g, it will return one or more character strings.

Jim


On Thu, Mar 3, 2016 at 9:52 AM, Jinggaofu Shi  wrote:
> Hi, there
> I am new to R, here is an urgent question.
> I want to save several graphs by a for loop. But I don't know how to refer
> the variable in the quotes.
> Here is my code.
>
> g<-c("g1","g2","g3","g4","g5","g6","g7","g8","g9")
> for (u in 1:9) {pdf("g[u]".pdf")
> + plot(1,1, xlim=range(x), ylim=c(-5,5), type='n', xlab ="Femur length
> (mm)", ylab = "Z-Score")
> + mtext("g[u]", side = 4)
> + for (i in z) {
> + lines(x,(log(i)-(m[u]*log(x)+c[u]))/r[u])
> + miny<-(log(i)-(m[u]*log(max(x))+c[u]))/r[u]
> + maxx <- exp((log(i)-c[u]+5*r[u])/m[u]);
> + if (miny > -5) {text(max(x),miny+0.3,i)
> + }else {text(maxx+2, -5+0.3,i)}
> +  }
> + dev.off()
> + }
>
> In the second line, I want to refer the variable 'g[n]' to the file name
> and fifth line i also want to refer the variable as a note. How should I
> do? Thank you very much!
>
> --
> Sincerely,
> Jinggaofu Shi
> 4029 Spring Garden Street
> Philadelphia, PA 19104
> Email: shijingga...@gmail.com
> Phone: 215-847-9145
>
> [[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] How to refer a variable in quotes

2016-03-02 Thread Bert Gunter
1. Please spend some time with an R tutorial or two to become familiar
with R basics.

2. Please do not post in HTML. This is a plain text email list.

3. See e.g. ?sprintf  or ?paste  for your problem.

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, Mar 2, 2016 at 2:52 PM, Jinggaofu Shi  wrote:
> Hi, there
> I am new to R, here is an urgent question.
> I want to save several graphs by a for loop. But I don't know how to refer
> the variable in the quotes.
> Here is my code.
>
> g<-c("g1","g2","g3","g4","g5","g6","g7","g8","g9")
> for (u in 1:9) {pdf("g[u]".pdf")
> + plot(1,1, xlim=range(x), ylim=c(-5,5), type='n', xlab ="Femur length
> (mm)", ylab = "Z-Score")
> + mtext("g[u]", side = 4)
> + for (i in z) {
> + lines(x,(log(i)-(m[u]*log(x)+c[u]))/r[u])
> + miny<-(log(i)-(m[u]*log(max(x))+c[u]))/r[u]
> + maxx <- exp((log(i)-c[u]+5*r[u])/m[u]);
> + if (miny > -5) {text(max(x),miny+0.3,i)
> + }else {text(maxx+2, -5+0.3,i)}
> +  }
> + dev.off()
> + }
>
> In the second line, I want to refer the variable 'g[n]' to the file name
> and fifth line i also want to refer the variable as a note. How should I
> do? Thank you very much!
>
> --
> Sincerely,
> Jinggaofu Shi
> 4029 Spring Garden Street
> Philadelphia, PA 19104
> Email: shijingga...@gmail.com
> Phone: 215-847-9145
>
> [[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] Functional programming?

2016-03-02 Thread Roger Koenker
Thanks again to all.  This was highly educational for me.  As it turned out
Mikiko's suggestion turned out to be most easily adaptable to my real problem.
I’m not at all able to evaluate relative efficiency at this point, but 
fortunately this isn’t
an important factor (so far) in what I’m trying to do.

As always the knowledge and generosity of the R-help community is inspiring.


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 Mar 2, 2016, at 1:25 PM, Mikko Korpela  wrote:
> 
> On 02.03.2016 18:47, Roger Koenker wrote:
>> I have a (remarkably ugly!!) code snippet  (below) that, given
>> two simple functions, f and g,  generates
>> a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
>> vastly
>> better ways to do this.  I don’t particularly care about the returned list,
>> I’d be happy to have the final  h_K version of the function,
>> but I keep losing my way and running into the dreaded:
>> 
>> Error in h[[1]] : object of type 'closure' is not subsettable
>> or
>> Error: evaluation nested too deeply: infinite recursion / 
>> options(expressions=)?
>> 
>> Mainly I’d like to get rid of the horrible, horrible paste/parse/eval evils. 
>>  Admittedly
>> the f,g look a bit strange, so you may have to suspend disbelief to imagine 
>> that there is
>> something more sensible lurking beneath this minimal (toy)  example.
>> 
>>f <- function(u) function(x) u * x^2
>>g <- function(u) function(x) u * log(x)
>>set.seed(3)
>>a <- runif(5)
>>h <- list()
>>hit <- list()
>>h[[1]] <- f(a[1])
>>hit[[1]] <- f(a[1])
>>for(i in 2:5){
>>  ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
>>  h[[i]] <- eval(parse(text = ht))
>>  hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
>>  }
>>x <- 1:99/10
>>plot(x, h[[1]](x), type = "l")
>>for(i in 2:5)
>>  lines(x, h[[i]](x), col = i)
> 
> Here is my (ugly?) suggestion:
> 
> f <- function(u) function(x) u * x^2
> g <- function(u) function(x) u * log(x)
> set.seed(3)
> a <- runif(5)
> h <- f(a[1])
> for (i in 2:5) {
>body(h) <- call("*", body(h),
>as.call(list(do.call("g", list(a[i])), quote(x
> }
> 
> -- 
> Mikko Korpela
> Aalto University School of Science
> Department of Computer Science

__
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] Ruofei Mo - How can I generate correlated data with non-normal distribution?

2016-03-02 Thread Ruofei Mo【莫若飞】
Hi, All,

 

I have a question about how to generate correlated data with non-normal
distribution? Basic, I have a variable a that follows a normal distribution,
a ~ N(0,1), then I want to generate another variable b that follows a
uniform distribution, b ~ U(0, 1). Most importantly, I want the correlation
between a and b to be fixed at -.9, cor(a,b) = -.90

 

I tried the following code,

 

### Correlation matrix rmvnorm() function ###

  Cormat <- matrix(c(1, -.9, -.9, 1), ncol = 2)   # Here, I want to create 2
variables that have correlation -.9

  

  ### Theta-Transform-Guessing ###

  DataSet <- data.frame(rmvnorm(1000, mean=c(0, 0), sigma=Cormat))

  Names(DataSet) <- c("a", "trans")

  

  ### Using trans to be transformed into guessing parameters ###

  DataSet$b <- pnorm(DataSet$trans, mean=mean(DataSet$trans),
sd=sd(DataSet$trans)) # Here, I used the pnorm() function to transform one
variable to a U(0, 1)

 

However, the correlation is changed. Can anyone give me some suggestion that
how can I generate the data?

 

Thanks,

Ruofei


[[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] help in maximum likelihood

2016-03-02 Thread Alaa Sindi
Thank you very much prof. Ravi,

That was very helpful. Is there a way to get the t and p value for the 
coefficients?

Thanks 
Alaa
> On Mar 2, 2016, at 10:05 AM, Ravi Varadhan  wrote:
> 
> There is nothing wrong with the optimization.  It is a warning message.  
> However, this is a good example to show that one should not simply dismiss a 
> warning before understanding what it means.  The MLE parameters are also 
> large, indicating that there is something funky about the model or the data 
> or both.  In your case, there is one major problem with the data:  for the 
> highest dose (value of x), you have all subjects responding, i.e. y = n.  
> Even for the next lower dose, there is almost complete response.  Where do 
> these data come from? Are they real or fake (simulated) data?
>  
> Also, take a look at the eigenvalues of the hessian at the solution.  You 
> will see that there is some ill-conditioning, as the eigenvalues are widely 
> separated.
>  
> x <- c(1.6907, 1.7242, 1.7552, 1.7842, 1.8113, 1.8369, 1.8610, 1.8839)
> y <- c( 6, 13, 18, 28, 52, 53, 61, 60)
> n <- c(59, 60, 62, 56, 63, 59, 62, 60)
>  
> # note: there is no need to have the choose(n, y) term in the likelihood
> fn <- function(p)
> sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))) )
>  
> out <- nlm(fn, p = c(-50,20), hessian = TRUE)
>  
> out
>  
> eigen(out$hessian)
>  
>  
> Hope this is helpful,
> Ravi
>  
>  
>  
> Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
> Associate Professor,  Department of Oncology
> Division of Biostatistics & Bionformatics
> Sidney Kimmel Comprehensive Cancer Center
> Johns Hopkins University
> 550 N. Broadway, Suite -E
> Baltimore, MD 21205
> 410-502-2619
>  


[[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] How to refer a variable in quotes

2016-03-02 Thread Jinggaofu Shi
Hi, there
I am new to R, here is an urgent question.
I want to save several graphs by a for loop. But I don't know how to refer
the variable in the quotes.
Here is my code.

g<-c("g1","g2","g3","g4","g5","g6","g7","g8","g9")
for (u in 1:9) {pdf("g[u]".pdf")
+ plot(1,1, xlim=range(x), ylim=c(-5,5), type='n', xlab ="Femur length
(mm)", ylab = "Z-Score")
+ mtext("g[u]", side = 4)
+ for (i in z) {
+ lines(x,(log(i)-(m[u]*log(x)+c[u]))/r[u])
+ miny<-(log(i)-(m[u]*log(max(x))+c[u]))/r[u]
+ maxx <- exp((log(i)-c[u]+5*r[u])/m[u]);
+ if (miny > -5) {text(max(x),miny+0.3,i)
+ }else {text(maxx+2, -5+0.3,i)}
+  }
+ dev.off()
+ }

In the second line, I want to refer the variable 'g[n]' to the file name
and fifth line i also want to refer the variable as a note. How should I
do? Thank you very much!

-- 
Sincerely,
Jinggaofu Shi
4029 Spring Garden Street
Philadelphia, PA 19104
Email: shijingga...@gmail.com
Phone: 215-847-9145

[[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 installing packages: cannot open file '/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf'

2016-03-02 Thread John Hillier

Dear All,


I am a relative newbie to R, and am struggling to install packages on my laptop 
(although I have managed to on my desktop and a borrowed departmental laptop).


I have tried various packages with the same result. Illustration for

> install.packages("outliers")


 leads to .


Error in file(con, "r") : cannot open the connection
Calls:  -> sub -> grep -> readLines -> file
In addition: Warning message:
In file(con, "r") :
  cannot open file 
'/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf': No 
such file or directory

I have tried in both the R environment on command line, and in RStudio, with 
the same result, and reinstalled and updated both r-base and rstudio-desktop 
via fink.  Both using a CRAN mirror and using a download (outliers_0.14.tar.gz) 
seem to produce the same result, and I think they're both working as the output 
says 'downloaded' (see below)


> install.packages("outliers")
Installing package into �
(as � is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://mirrors.ebi.ac.uk/CRAN/src/contrib/outliers_0.14.tar.gz'
Content type 'application/x-gzip' length 15090 bytes (14 KB)
==
downloaded 14 KB


>From looking aroud on the web it seems that the message "In file(con, "r") : 
>cannot open file" just means that R cannot find a file it thinks it needs. 
>However, I've looked in 
>/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/ both on this 
>machine and the other laptop that is able to install packages, and 'Makeconf' 
>is not in ether of them.


So, I'm thoroughly confused and have run out of ideas.


Please help.


I hope that this is something simple that I'm missing.  If so, a pointer to a 
manual page or instructions would be gratefully received.


John


p.s - Full output in sequence in case it's useful.


> install.packages("outliers")
Installing package into �
(as � is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://mirrors.ebi.ac.uk/CRAN/src/contrib/outliers_0.14.tar.gz'
Content type 'application/x-gzip' length 15090 bytes (14 KB)
==
downloaded 14 KB

Error in file(con, "r") : cannot open the connection
Calls:  -> sub -> grep -> readLines -> file
In addition: Warning message:
In file(con, "r") :
  cannot open file 
'/sw/Library/Frameworks/R.framework/Versions/3.2/Resources/etc/Makeconf': No 
such file or directory

The downloaded source packages are in
�
Warning message:
In install.packages("outliers") :
  installation of package � had non-zero exit status





-
Dr John Hillier
Senior Lecturer - Physical Geography
Loughborough University
01509 223727

[[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] Seasonal Cointegration

2016-03-02 Thread John C Frain
tRY HEGY.test() in R package pdr.

John C Frain
3 Aranleigh Park
Rathfarnham
Dublin 14
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com

On 29 February 2016 at 19:14, Sarah Goslee  wrote:

> Checking Rseek.org turns up this discussion thread:
> http://blog.gmane.org/gmane.comp.lang.r.r-metrics/month=20130601
> which talks about the lack of that method in R.
>
> Sarah
>
> On Mon, Feb 29, 2016 at 2:08 PM, Rafael Costa
>  wrote:
> > Dear R users,
> >
> > Where can I find the codes to Seasonal Coitegration tests (known as EGHL
> > test)? This test was presented on paper “Seasonal Cointegration: The
> > Japanese Consumption Function.” (Engle, R.F., C.W.J. Granger, S.
> Hylleberg,
> > and H.S. Lee; 1993).
> >
> > I am looking forward  any help.
> >
> > Thanks in advance ,
> >
> > Rafael Costa.
> >
>
> __
> 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] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
Sorry, I was assuming your data was a matrix (as you indicated in your
question).

Try:

write.table(as.matrix(PRdist), file = 'clipboard', sep = '\t', row.names =
F, col.names = F)

-Dan

On Wed, Mar 2, 2016 at 1:01 PM, Michael  wrote:

> I got an error message.
>
>
> > write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F,
> col.names = F)
> Error in as.data.frame.default(x[[i]], optional = TRUE) :
>   cannot coerce class ""dist"" to a data.frame
>
> I think because my PRdist is a value, not a data frame.  However, I am not
> sure.  Any advice?
>
>
> Thanks for your help.
>
>
> Mike
>
>
> --
> *From:* Dalthorp, Daniel 
> *Sent:* Wednesday, March 2, 2016 3:50 PM
> *To:* Michael
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] output my results into Excel
>
> Hi Michael,
> If you are working in Windows:
>
> # You can put the matrix directly into the clipboard
> write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F,
> col.names = F)
>
> The "sep" argument tells what character to use for separating columns.
> Default for Excel is tab (i.e. '\t')
>
> Default for write.table on a matrix or 2-d array is to write column names
> (as "V1", "V2", etc.) and row names ("1", "2", etc.). If you don't want
> those added to your matrix, tell R via row.names = FALSE, col.names = FALSE
>
>
>
> -Dan
>
> On Wed, Mar 2, 2016 at 12:31 PM, Michael  wrote:
>
>> I can get R to calculate the distance that I want between my data
>> points.  However, I am stuck trying to get R to output the data so I can
>> paste it into Excel.  Instead, R outputs a matrix mess in the console.
>>
>> Below are the steps I am taking to calculate the distance between my
>> data.  Also, I have 42 different data points.
>>
>> # Calculate the Euclidean distance between each datapoint using
>> # the function dist()
>>
>> PRdist = dist(my_data) ;  PRdist
>>
>> I would greatly appreciate if someone can tell me how to output my matrix
>> from the dist function into something I can paste into Excel.
>>
>> Mike
>>
>>
>>
>>
>> [[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.
>>
>
>
>
> --
> Dan Dalthorp, PhD
> USGS Forest and Rangeland Ecosystem Science Center
> Forest Sciences Lab, Rm 189
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> ph: 541-750-0953
> ddalth...@usgs.gov
>
>


-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[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] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
Hi Michael,
If you are working in Windows:

# You can put the matrix directly into the clipboard
write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F,
col.names = F)

The "sep" argument tells what character to use for separating columns.
Default for Excel is tab (i.e. '\t')

Default for write.table on a matrix or 2-d array is to write column names
(as "V1", "V2", etc.) and row names ("1", "2", etc.). If you don't want
those added to your matrix, tell R via row.names = FALSE, col.names = FALSE



-Dan

On Wed, Mar 2, 2016 at 12:31 PM, Michael  wrote:

> I can get R to calculate the distance that I want between my data points.
> However, I am stuck trying to get R to output the data so I can paste it
> into Excel.  Instead, R outputs a matrix mess in the console.
>
> Below are the steps I am taking to calculate the distance between my
> data.  Also, I have 42 different data points.
>
> # Calculate the Euclidean distance between each datapoint using
> # the function dist()
>
> PRdist = dist(my_data) ;  PRdist
>
> I would greatly appreciate if someone can tell me how to output my matrix
> from the dist function into something I can paste into Excel.
>
> Mike
>
>
>
>
> [[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.
>



-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[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] output my results into Excel

2016-03-02 Thread Sarah Goslee
Hi Michael,

Googling "export R data to Excel" gives LOTS of advice, including
packages that can write your data directly to Excel spreadsheets.

I don't use Excel, so I haven't tried any of those, but using
write.csv() to export your data will create something that my
colleagues who use Excel have no trouble opening.

Printing to the console, as you did by typing the object name, is not
intended to be an export method.

Sarah

On Wed, Mar 2, 2016 at 3:31 PM, Michael  wrote:
> I can get R to calculate the distance that I want between my data points.  
> However, I am stuck trying to get R to output the data so I can paste it into 
> Excel.  Instead, R outputs a matrix mess in the console.
>
> Below are the steps I am taking to calculate the distance between my data.  
> Also, I have 42 different data points.
>
> # Calculate the Euclidean distance between each datapoint using
> # the function dist()
>
> PRdist = dist(my_data) ;  PRdist
>
> I would greatly appreciate if someone can tell me how to output my matrix 
> from the dist function into something I can paste into Excel.
>
> Mike
>
>
--

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


[R] output my results into Excel

2016-03-02 Thread Michael
I can get R to calculate the distance that I want between my data points.  
However, I am stuck trying to get R to output the data so I can paste it into 
Excel.  Instead, R outputs a matrix mess in the console.

Below are the steps I am taking to calculate the distance between my data.  
Also, I have 42 different data points.

# Calculate the Euclidean distance between each datapoint using
# the function dist()

PRdist = dist(my_data) ;  PRdist

I would greatly appreciate if someone can tell me how to output my matrix from 
the dist function into something I can paste into Excel.

Mike




[[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] Functional programming?

2016-03-02 Thread Bert Gunter
Thanks, Roger:

I think Duncan's approach is far more efficient, but I believe the
following replicates your result and may be a bit easier to
understand.

f <- function(u) function(x) u * x^2
g <- function(u) function(x) u * log(x)
set.seed(3)
a <- runif(5)
h <- list()
hit <- list()
h[[1]] <- f(a[1])
hit[[1]] <- f(a[1])
for(i in 2:5) h[[i]] <- eval(bquote(function(x)h[[.(i-1)]](x)*g(a[.(i)])(x)))
x <- 1:99/10
plot(x, h[[1]](x), type = "l")
for(i in 2:5){
  lines(x, h[[i]](x), col = i)
}

This uses recursion to "unwind" h[[i]] each time it's called, ergo
the inefficiency. But in that sense,anyway,  it seems to be more
"functional."

But certainly feel free to ignore.

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, Mar 2, 2016 at 10:40 AM, Roger Koenker  wrote:
> Thanks, Duncan and Bert,
>
> Duncan’s version does replicate my result, Bert’s does something a bit 
> different,
> now I just need some time to digest what you have done, and try to see how
> and why.  Many thanks!!!
>
> Roger
>
> 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 Mar 2, 2016, at 12:23 PM, Duncan Murdoch  wrote:
>>
>> On 02/03/2016 11:47 AM, Roger Koenker wrote:
>>> I have a (remarkably ugly!!) code snippet  (below) that, given
>>> two simple functions, f and g,  generates
>>> a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
>>> vastly
>>> better ways to do this.  I don’t particularly care about the returned list,
>>> I’d be happy to have the final  h_K version of the function,
>>> but I keep losing my way and running into the dreaded:
>>>
>>> Error in h[[1]] : object of type 'closure' is not subsettable
>>> or
>>> Error: evaluation nested too deeply: infinite recursion / 
>>> options(expressions=)?
>>>
>>> Mainly I’d like to get rid of the horrible, horrible paste/parse/eval 
>>> evils.  Admittedly
>>> the f,g look a bit strange, so you may have to suspend disbelief to imagine 
>>> that there is
>>> something more sensible lurking beneath this minimal (toy)  example.
>>>
>>> f <- function(u) function(x) u * x^2
>>> g <- function(u) function(x) u * log(x)
>>> set.seed(3)
>>> a <- runif(5)
>>> h <- list()
>>> hit <- list()
>>> h[[1]] <- f(a[1])
>>> hit[[1]] <- f(a[1])
>>> for(i in 2:5){
>>>  ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
>>>  h[[i]] <- eval(parse(text = ht))
>>>  hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
>>>  }
>>> x <- 1:99/10
>>> plot(x, h[[1]](x), type = "l")
>>> for(i in 2:5)
>>>  lines(x, h[[i]](x), col = i)
>>
>> I don't understand what "hit" is for, but something like this should do it:
>>
>>
>> hlist <- function(maxk, f,g,a) {
>>   h <- list()
>>   h[[1]] <- f(a[1])
>>   for (j in 2:maxk) {
>> h[[j]] <- local({
>>   k <- j
>>   function(x) {
>> result <- h[[1]](x)
>> for (i in 2:k) {
>>   result <- result*g(a[i])(x)
>> }
>> result
>>   }
>> })
>>   }
>>   h
>> }
>>
>> f <- function(u) function(x) u * x^2
>> g <- function(u) function(x) u * log(x)
>> set.seed(3)
>> a <- runif(5)
>> h <- hlist(5, f, g, 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] Functional programming?

2016-03-02 Thread Mikko Korpela
On 02.03.2016 18:47, Roger Koenker wrote:
> I have a (remarkably ugly!!) code snippet  (below) that, given
> two simple functions, f and g,  generates
> a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
> vastly
> better ways to do this.  I don’t particularly care about the returned list,
> I’d be happy to have the final  h_K version of the function,
> but I keep losing my way and running into the dreaded:
> 
> Error in h[[1]] : object of type 'closure' is not subsettable
> or
> Error: evaluation nested too deeply: infinite recursion / 
> options(expressions=)?
> 
> Mainly I’d like to get rid of the horrible, horrible paste/parse/eval evils.  
> Admittedly
> the f,g look a bit strange, so you may have to suspend disbelief to imagine 
> that there is
> something more sensible lurking beneath this minimal (toy)  example.
> 
> f <- function(u) function(x) u * x^2
> g <- function(u) function(x) u * log(x)
> set.seed(3)
> a <- runif(5)
> h <- list()
> hit <- list()
> h[[1]] <- f(a[1])
> hit[[1]] <- f(a[1])
> for(i in 2:5){
>   ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
>   h[[i]] <- eval(parse(text = ht))
>   hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
>   }
> x <- 1:99/10
> plot(x, h[[1]](x), type = "l")
> for(i in 2:5)
>   lines(x, h[[i]](x), col = i)

Here is my (ugly?) suggestion:

f <- function(u) function(x) u * x^2
g <- function(u) function(x) u * log(x)
set.seed(3)
a <- runif(5)
h <- f(a[1])
for (i in 2:5) {
body(h) <- call("*", body(h),
as.call(list(do.call("g", list(a[i])), quote(x
}

-- 
Mikko Korpela
Aalto University School of Science
Department of Computer Science

__
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] Functional programming?

2016-03-02 Thread Gabor Grothendieck
This manufactures the functions without using eval by using substitute
to substitute i-1 and a[i] into an expression for the body which is
then assigned to the body of the function:

hh <- vector("list", 5)
hh[[1]] <- f(a[1])
for(i in 2:5) {
 hh[[i]] <- hh[[1]]
 body(hh[[i]]) <- substitute(hh[[iprev]](x) * g(ai)(x), list(iprev
= i-1, ai = a[i]))
}
all.equal(h[[5]](.5), hh[[5]](.5)) # test
## [1] TRUE



This uses quote to define the body of h[[i]] as a call object and then
substitutes in the values of i-1 and a[i] assigning the result to the
body of h[[i]].

h <- vector("list", 5)
h[[1]] <- f(a[1])
for(i in 2:5) {
 h[[i]] <- h[[1]]
 body(hh[[i]]) <- do.call(substitute,
   list(quote(hh[[iprev]](x) *
g(ai)(x)),
   list(iprev = i-1, ai = a[i])))
}



On Wed, Mar 2, 2016 at 11:47 AM, Roger Koenker  wrote:
> I have a (remarkably ugly!!) code snippet  (below) that, given
> two simple functions, f and g,  generates
> a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
> vastly
> better ways to do this.  I don’t particularly care about the returned list,
> I’d be happy to have the final  h_K version of the function,
> but I keep losing my way and running into the dreaded:
>
> Error in h[[1]] : object of type 'closure' is not subsettable
> or
> Error: evaluation nested too deeply: infinite recursion / 
> options(expressions=)?
>
> Mainly I’d like to get rid of the horrible, horrible paste/parse/eval evils.  
> Admittedly
> the f,g look a bit strange, so you may have to suspend disbelief to imagine 
> that there is
> something more sensible lurking beneath this minimal (toy)  example.
>
> f <- function(u) function(x) u * x^2
> g <- function(u) function(x) u * log(x)
> set.seed(3)
> a <- runif(5)
> h <- list()
> hit <- list()
> h[[1]] <- f(a[1])
> hit[[1]] <- f(a[1])
> for(i in 2:5){
> ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
> h[[i]] <- eval(parse(text = ht))
> hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
> }
> x <- 1:99/10
> plot(x, h[[1]](x), type = "l")
> for(i in 2:5)
> lines(x, h[[i]](x), col = i)
>
> Thanks,
> Roger
>
> __
> 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.



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread Dalthorp, Daniel
Or, if you want easy labels, you can play around with contour graphs.

?contour # will give you info on how to make contour plots

The basic idea is to construct a matrix of z-values...one z for every
combination of x and y
contour(x,y,z)

The x's would then be the x-values you want in
(0.37273*log(x)-1.79389))/0.17941 for whatever range of x's you want
The y's would be values from -5 to 5 (or whatever range you want)
The z's would be values like 0.4, 0.5, etc. or exp(y + x)

?outer # will tell you how to create z from x and y

x<-seq(1,10,length=100) # values for x-axis
y<-seq(2, 10, length=100) # values for y-axis
z<-exp(outer((0.37273*log(x)-1.79389)/0.17941,y,"+"))
contour(x,y,z,levels=seq(.1,1.1,by=.1))

-Dan

On Wed, Mar 2, 2016 at 9:03 AM, Jinggaofu Shi  wrote:

> Hi, there I am new on R. I want to plot a graph like this.
>
> The curves are created by these equations :
> (log(0.4)-(0.37273*log(x)-1.79389))/0.17941,
> (log(0.5)-(0.37273*log(x)-1.79389))/0.17941,
> (log(0.6)-(0.37273*log(x)-1.79389))/0.17941, etc. The equations are
> similar, the only difference is the first log(XXX). I already manually draw
> the graph by repeating plot() for each equation. But I think there must be
> a way to just assign a simple variable like x<-c(0.4,0.5,0.6,0.7), and then
> plot all the curves automatically. I tried to use data frame to make a set
> of equations, but failed. Could somebody help me? Thank you very much!
>
> __
> 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.
>



-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[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] Functional programming?

2016-03-02 Thread Roger Koenker
Thanks, Duncan and Bert,

Duncan’s version does replicate my result, Bert’s does something a bit 
different,
now I just need some time to digest what you have done, and try to see how
and why.  Many thanks!!!

Roger

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 Mar 2, 2016, at 12:23 PM, Duncan Murdoch  wrote:
> 
> On 02/03/2016 11:47 AM, Roger Koenker wrote:
>> I have a (remarkably ugly!!) code snippet  (below) that, given
>> two simple functions, f and g,  generates
>> a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
>> vastly
>> better ways to do this.  I don’t particularly care about the returned list,
>> I’d be happy to have the final  h_K version of the function,
>> but I keep losing my way and running into the dreaded:
>> 
>> Error in h[[1]] : object of type 'closure' is not subsettable
>> or
>> Error: evaluation nested too deeply: infinite recursion / 
>> options(expressions=)?
>> 
>> Mainly I’d like to get rid of the horrible, horrible paste/parse/eval evils. 
>>  Admittedly
>> the f,g look a bit strange, so you may have to suspend disbelief to imagine 
>> that there is
>> something more sensible lurking beneath this minimal (toy)  example.
>> 
>> f <- function(u) function(x) u * x^2
>> g <- function(u) function(x) u * log(x)
>> set.seed(3)
>> a <- runif(5)
>> h <- list()
>> hit <- list()
>> h[[1]] <- f(a[1])
>> hit[[1]] <- f(a[1])
>> for(i in 2:5){
>>  ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
>>  h[[i]] <- eval(parse(text = ht))
>>  hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
>>  }
>> x <- 1:99/10
>> plot(x, h[[1]](x), type = "l")
>> for(i in 2:5)
>>  lines(x, h[[i]](x), col = i)
> 
> I don't understand what "hit" is for, but something like this should do it:
> 
> 
> hlist <- function(maxk, f,g,a) {
>   h <- list()
>   h[[1]] <- f(a[1])
>   for (j in 2:maxk) {
> h[[j]] <- local({
>   k <- j
>   function(x) {
> result <- h[[1]](x)
> for (i in 2:k) {
>   result <- result*g(a[i])(x)
> }
> result
>   }
> })
>   }
>   h
> }
> 
> f <- function(u) function(x) u * x^2
> g <- function(u) function(x) u * log(x)
> set.seed(3)
> a <- runif(5)
> h <- hlist(5, f, g, 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] Functional programming?

2016-03-02 Thread Duncan Murdoch

On 02/03/2016 11:47 AM, Roger Koenker wrote:

I have a (remarkably ugly!!) code snippet  (below) that, given
two simple functions, f and g,  generates
a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
vastly
better ways to do this.  I don’t particularly care about the returned list,
I’d be happy to have the final  h_K version of the function,
but I keep losing my way and running into the dreaded:

Error in h[[1]] : object of type 'closure' is not subsettable
or
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

Mainly I’d like to get rid of the horrible, horrible paste/parse/eval evils.  
Admittedly
the f,g look a bit strange, so you may have to suspend disbelief to imagine 
that there is
something more sensible lurking beneath this minimal (toy)  example.

 f <- function(u) function(x) u * x^2
 g <- function(u) function(x) u * log(x)
 set.seed(3)
 a <- runif(5)
 h <- list()
 hit <- list()
 h[[1]] <- f(a[1])
 hit[[1]] <- f(a[1])
 for(i in 2:5){
ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
h[[i]] <- eval(parse(text = ht))
hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
}
 x <- 1:99/10
 plot(x, h[[1]](x), type = "l")
 for(i in 2:5)
lines(x, h[[i]](x), col = i)


I don't understand what "hit" is for, but something like this should do it:


hlist <- function(maxk, f,g,a) {
  h <- list()
  h[[1]] <- f(a[1])
  for (j in 2:maxk) {
h[[j]] <- local({
  k <- j
  function(x) {
result <- h[[1]](x)
for (i in 2:k) {
  result <- result*g(a[i])(x)
}
result
  }
})
  }
  h
}

f <- function(u) function(x) u * x^2
g <- function(u) function(x) u * log(x)
set.seed(3)
a <- runif(5)
h <- hlist(5, f, g, 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] Functional programming?

2016-03-02 Thread Bert Gunter
Does this do what you want:

f <- function(u) function(x) u * x^2
g <- function(u) function(x) u * log(x)
set.seed(3)
a <- runif(5)
h <- list()
hit <- list()
h[[1]] <- f(a[1])
hit[[1]] <- f(a[1])
for(i in 2:5)h[[i]] <- eval(bquote(function(x).(h[[i-1]])(x) * g(a[i])(x)))
x <- 1:99/10
plot(x, h[[1]](x), type = "l")
for(i in 2:5){
  i
  lines(x, h[[i]](x), col = i)
}

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, Mar 2, 2016 at 8:47 AM, Roger Koenker  wrote:
> I have a (remarkably ugly!!) code snippet  (below) that, given
> two simple functions, f and g,  generates
> a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
> vastly
> better ways to do this.  I don’t particularly care about the returned list,
> I’d be happy to have the final  h_K version of the function,
> but I keep losing my way and running into the dreaded:
>
> Error in h[[1]] : object of type 'closure' is not subsettable
> or
> Error: evaluation nested too deeply: infinite recursion / 
> options(expressions=)?
>
> Mainly I’d like to get rid of the horrible, horrible paste/parse/eval evils.  
> Admittedly
> the f,g look a bit strange, so you may have to suspend disbelief to imagine 
> that there is
> something more sensible lurking beneath this minimal (toy)  example.
>
> f <- function(u) function(x) u * x^2
> g <- function(u) function(x) u * log(x)
> set.seed(3)
> a <- runif(5)
> h <- list()
> hit <- list()
> h[[1]] <- f(a[1])
> hit[[1]] <- f(a[1])
> for(i in 2:5){
> ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
> h[[i]] <- eval(parse(text = ht))
> hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
> }
> x <- 1:99/10
> plot(x, h[[1]](x), type = "l")
> for(i in 2:5)
> lines(x, h[[i]](x), col = i)
>
> Thanks,
> Roger
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

Re: [R] Plot multiple similar equations in r

2016-03-02 Thread Dalthorp, Daniel
A simple solution that will give you an idea of some of the plot parameters:

x<-seq(1,10,length=1000) # values for x-axis
x0<-c(0.4,0.5,0.6,0.7)
miny<-(log(min(x0))-(0.37273*log(max(x))-1.79389))/0.17941 # minimum
y-value to show on graph
maxy<-(log(max(x0))-(0.37273*log(min(x))-1.79389))/0.17941 # maximum
y-value to show on graph
plot(1,1, xlim=range(x), ylim=c(miny,maxy), type='n') # a blank figure to
put lines on
for (i in x0) lines(x,(log(i)-(0.37273*log(x)-1.79389))/0.17941) # putting
the lines on


On Wed, Mar 2, 2016 at 9:03 AM, Jinggaofu Shi  wrote:

> Hi, there I am new on R. I want to plot a graph like this.
>
> The curves are created by these equations :
> (log(0.4)-(0.37273*log(x)-1.79389))/0.17941,
> (log(0.5)-(0.37273*log(x)-1.79389))/0.17941,
> (log(0.6)-(0.37273*log(x)-1.79389))/0.17941, etc. The equations are
> similar, the only difference is the first log(XXX). I already manually draw
> the graph by repeating plot() for each equation. But I think there must be
> a way to just assign a simple variable like x<-c(0.4,0.5,0.6,0.7), and then
> plot all the curves automatically. I tried to use data frame to make a set
> of equations, but failed. Could somebody help me? Thank you very much!
>
> __
> 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.
>



-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[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] Plot multiple similar equations in r

2016-03-02 Thread Jinggaofu Shi
Hi, there I am new on R. I want to plot a graph like this.

The curves are created by these equations :
(log(0.4)-(0.37273*log(x)-1.79389))/0.17941,
(log(0.5)-(0.37273*log(x)-1.79389))/0.17941,
(log(0.6)-(0.37273*log(x)-1.79389))/0.17941, etc. The equations are
similar, the only difference is the first log(XXX). I already manually draw
the graph by repeating plot() for each equation. But I think there must be
a way to just assign a simple variable like x<-c(0.4,0.5,0.6,0.7), and then
plot all the curves automatically. I tried to use data frame to make a set
of equations, but failed. Could somebody help me? Thank you very much!
__
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] Functional programming?

2016-03-02 Thread Roger Koenker
I have a (remarkably ugly!!) code snippet  (below) that, given
two simple functions, f and g,  generates
a list of new functions h_{k+1} =  h_k * g, k= 1, …, K.  Surely, there are 
vastly
better ways to do this.  I don’t particularly care about the returned list,
I’d be happy to have the final  h_K version of the function,
but I keep losing my way and running into the dreaded:

Error in h[[1]] : object of type 'closure' is not subsettable
or
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

Mainly I’d like to get rid of the horrible, horrible paste/parse/eval evils.  
Admittedly
the f,g look a bit strange, so you may have to suspend disbelief to imagine 
that there is
something more sensible lurking beneath this minimal (toy)  example.

f <- function(u) function(x) u * x^2
g <- function(u) function(x) u * log(x)
set.seed(3)
a <- runif(5)
h <- list()
hit <- list()
h[[1]] <- f(a[1])
hit[[1]] <- f(a[1])
for(i in 2:5){
ht <- paste("function(x) h[[", i-1, "]](x) * g(", a[i], ")(x)")
h[[i]] <- eval(parse(text = ht))
hit[[i]] <- function(x) {force(i); return(h[[i]] (x))}
}
x <- 1:99/10
plot(x, h[[1]](x), type = "l")
for(i in 2:5)
lines(x, h[[i]](x), col = i)

Thanks,
Roger

__
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] plotting spline term when frailty term is included

2016-03-02 Thread Therneau, Terry M., Ph.D.



On 03/02/2016 05:00 AM, r-help-requ...@r-project.org wrote:

I'd very much appreciate your help in resolving a problem that I'm having with 
plotting a spline term.

I have a Cox PH model including a smoothing spline and a frailty term as 
follows:

fit<-coxph(Surv(start,end,exit) ~ x + pspline(z) + frailty(a))

When I run a model without a frailty term, I use the following in order to plot 
the splines:

termplot(fit, term = 2, se = TRUE, ylab = "Log Hazard", rug=TRUE, xlab = 
"z_name")

However, when the frailty term is included, it gives this error:

Error in pred[, first] : subscript out of bounds

What am I doing wrong here? Or is it the case that termplot does not work when 
splines and frailty are included?


There are 3 parts to the answer.
 1. The first is a warning: wrt to mixed effects Cox models, I shifted my energy to coxme 
over 10 years ago.  The "penalized add on to coxph" approach of the frailty function was 
an ok first pass, but is just too limited for any but the simplest models.  I'm unlikely 
fix issues, since there are others much higher on my priority list.


 2. As Dave W. pointed out, the key issue is that predict(type='terms') does not work 
with for a model with two penalized terms, when one is frailty and the other pspline. 
Termplot depends on predict.


 3. Again, as Dave W pointed out, the whole issue of what the "correct" answer would be 
gets much more complicated when one adds random effects to the mix; some things have not 
done because it is not clear where to go.  (Survival curves for a mixed effects model only 
recently got added to my "todo" list, even though it has been on the wish list forever, 
because I finally have a notion of what a good approach would be.)


In your case I'd advise an end run: fit the model using ns() instead of pspline.  I like 
smoothing splines better than regression splines, but the fact is that for most data sets 
they result in nearly identical answers.


Terry T

__
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] problema al importar una BD que esta en formato de SPSS

2016-03-02 Thread eric
Estimados, gracias por sus sugerencias  no estoy seguro de las 
razones del problema al importar a R la BD en formato spss, pero por la 
solucion que encontre, parece que fuera un problema de los importadores 
(probe importando con todos los paquetes que aparecen mencionados en el 
la internet) ...


al final el problema se resolvio instalando PSPP (en Debian/linux) y 
usando la utilidad pspp-convert para transformar el archivo *.sav en 
*.csv y luego lei eso sin problemas en R. (nunca entre en PSPP por si 
acaso, no lei el archivo y luego lo exporte, si no que lo transfore 
directamente en .csv)


Eso, por si a alguien le sirve.

Muchas gracias,

Eric.





On 02/29/2016 04:22 PM, Ruben Bermad wrote:

Hola Eric,

Lo mas probable es que tengas algun registro que no sea numerico, y te
este modificando la clase de la columna.
Haz un chequeo rapido con unique() o con levels(). Al tener tantos
registros si es un caracter deberia de aparecerte al principio o al
final de unique() por lo que puedes probar a buscarlo ordenando el
resultado de unique() de mayor a menor y de menor a mayor. Asi lo veras
rapidamente.

Si se te ha transformado en factor lo que tienes que hacer es eliminar
ese error (asumo que solo deberia haber registros numericos), y
transformarlo en numerico mediante: " as.numeric(levels(columna))[columna]".

Si no tienes ningun registro raro y no numerico prueba a transformar la
columan con as.integer() directamente.

A ver si eso te funciona



From: ericconchamu...@gmail.com
To: r-help-es@r-project.org
Date: Mon, 29 Feb 2016 14:50:27 -0300
Subject: [R-es] problema al importar una BD que esta en formato de SPSS

Estimados, tengo que hacer un calculo muy simple, pero con una BD mas o
menos grande (250mil filas x 500 columnas) ... esta BD esta en formato
de SPSS y la importo asi:

library(foreign)
bdr <- read.spss("CASEN_2013_MN_B_Principal.sav",
use.value.labels=FALSE, to.data.frame=TRUE)


luego, quiero transformar el DF en un data.tale pues el calculo requiere
obtener promedios de acuerdo a ciertos criterios, lo que es muy facil
especificar con DT y el calculo es bastante rapido tambien ...

pero al tratar de transformar bdr a data.table

bdr <- as.data.table(bdr)


me transforma las columnas con los datos numericos que debo usar, en
characteres, y al tratar de volverlas a datos numericos con as.numeric()
me reemplaza todos los datos con NA


que estoy haciendo mal ?

adjunto algunas filas del archivo, muchas gracias,


Eric.



--
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city
standards for living

Nota: Las tildes se han omitido para asegurar compatibilidad con algunos
lectores de correo.


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


--
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city 
standards for living


Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
lectores de correo.


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


[R] discriminant analysis lda under MASS

2016-03-02 Thread Jens Koch
Hello all,

I'd like to run a simple discriminant analysis to jump into the topic with the 
following dataset provided by a textbook:

Gruppe Einwohner Kosten
1 1642 478,2
1 2418 247,3
1 1417 223,6
1 2761 505,6
1 3991 399,3
1 2500 276
1 6261 542,5
1 3260 308,9
1 2516 453,6
1 4451 430,2
1 3504 413,8
1 5431 379,7
1 3523 400,5
1 5471 404,1
2 7172 499,4
2 9419 674,9
2 8780 468,6
2 5070 601,5
2 5780 578,8
2 8630 641,5

The coefficients according to the textbook need to be -0.00170 and -0.01237.

If I put the data into the lda function under MASS, my result is:

Call:
lda(Gruppe ~ Einwohner + Kosten, data = data)

Prior probabilities of groups:
  1   2
0.7 0.3

Group means:
  Einwohner   Kosten
1  3510.429 390.2357
2  7475.167 577.4500

Coefficients of linear discriminants:
                   LD1
Einwohner 0.0004751092
Kosten    0.0050994964

I also tried to solve it by an another software package, but there is also not 
the result I have expected. I know now, that the solution for the coefficients 
is standardized by R and the discrimination power is not different at the end 
of the day.

But: How can I get (calculate) the results printed in the textbook with R?

Thanks in advance,

Jens.

__
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] help in maximum likelihood

2016-03-02 Thread Ravi Varadhan
There is nothing wrong with the optimization.  It is a warning message.  
However, this is a good example to show that one should not simply dismiss a 
warning before understanding what it means.  The MLE parameters are also large, 
indicating that there is something funky about the model or the data or both.  
In your case, there is one major problem with the data:  for the highest dose 
(value of x), you have all subjects responding, i.e. y = n.  Even for the next 
lower dose, there is almost complete response.  Where do these data come from? 
Are they real or fake (simulated) data?

Also, take a look at the eigenvalues of the hessian at the solution.  You will 
see that there is some ill-conditioning, as the eigenvalues are widely 
separated.

x <- c(1.6907, 1.7242, 1.7552, 1.7842, 1.8113, 1.8369, 1.8610, 1.8839)
y <- c( 6, 13, 18, 28, 52, 53, 61, 60)
n <- c(59, 60, 62, 56, 63, 59, 62, 60)

# note: there is no need to have the choose(n, y) term in the likelihood
fn <- function(p)
sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))) )

out <- nlm(fn, p = c(-50,20), hessian = TRUE)

out

eigen(out$hessian)


Hope this is helpful,
Ravi



Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
Associate Professor,  Department of Oncology
Division of Biostatistics & Bionformatics
Sidney Kimmel Comprehensive Cancer Center
Johns Hopkins University
550 N. Broadway, Suite -E
Baltimore, MD 21205
410-502-2619


[[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] Change the location of R

2016-03-02 Thread Loris Bennett
Hi Carol,

carol white via R-help  writes:

> Hi,I have R v 3.0 installed /usr/... and the new version R-3.2.3 in my
> home under ubuntu. Is it correct to copy the R-3.2.3 directory into
> /usr/local/lib/R/ or should I reconfig and remake into
> /usr/local/lib/R/?
> Regards,
> Carol

The standard way is just to use the --prefix option of configure to
point to the directory in which you want to install R.  However, you can
probably just move the directory as well.  Either way, you need to
ensure that R is found.  For that you will have to do add something like

export R_HOME=/path/to/R/3.2.3/lib64/R 
export PATH=/path/to/R/3.2.3/bin:$PATH

to your .bashrc file (e.g. /home/carol/.bashrc).

HTH

Loris

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de

__
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] Uso excesivo de CPU de RStudio

2016-03-02 Thread Carlos J. Gil Bellosta
Hola, ¿qué tal?

Ya está solucionado. Se trataba de una presentación en RMarkdown que había
quedado abierta en segundo plano (al lado de las pestañas con etiquetas
"History" y "Environment"). Al cerrar la pestaña, bajó el uso de la CPU
casi a cero.

¡A saber qué estaría tratando de hacer RStudio por detrás!

Un saludo,

Carlos J. Gil Bellosta
http://www.datanalytics.com

El 1 de marzo de 2016, 23:42, Carlos J. Gil Bellosta 
escribió:

> Hola, ¿qué tal?
>
> No sé si alguien ha encontrado (¿y solucionado?) el mismo problema que yo.
> El proceso rstudio (no me refiero a la rsession que levanta), incluso sin
> hacer nada con RStudio, sin que corra código, sin gráficos abiertos, aunque
> quede en segundo plano, con el "environment" vacío, consume casi al 100%
> una de mis cuatro CPUs.
>
> Sospecho que podrían ser los diagnósticos de código que se han introducido
> en las nuevas versiones, pero no lo he podido confirmar.
>
> Estoy usando la última versión de RStudio (0.99.891) en un Xubuntu 14.04.
>
> Un saludo y muchas gracias,
>
> Carlos J. Gil Bellosta
> http://www.datanalytics.com
>

[[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] nueva distribución de R y problema solucionado

2016-03-02 Thread Carlos J. Gil Bellosta
Hola, ¿qué tal?

Sobre

El 2 de marzo de 2016, 11:06, 
escribió:
>
> Que Microsoft tenga su propia versión de R y (si es el caso) su propia
> versión de los paquetes... con lo dados que han sido en el pasado a
> "tirar por su cuenta".. no sé yo...
>
> Opiniones?


creo que, en primer lugar, deberíamos felicitarnos con que el superpoderoso
Microsoft se haya fijado en R.  ¡Quién nos lo iba a decir hace 10 o 12 años!

Tiene otra ventaja. Ayer mismo hablaba con una gente de un banco y me
contaban las pegas (reales o potenciales) que ponía el Banco de España a
modelos de riesgos desarrollados en R. Ahora se le puede decir al regulador
que se está usando código bajado del mismo sitio que sus actualizaciones
del sistema operativo.

Finalmente, creo que mientras no se pruebe lo contrario, Microsoft está
haciendo un uso tal vez inhabitual pero permitido de la GPL y licencias de
uso. La GPL en concreto no prohíbe el uso comercial del código. NI siquiera
venderlo por tanto dinero como esté dispuesto a pagar un tercero. Solo
tienes que redistribuir el código fuente. Si Microsoft consigue hacer
dinero vendiendo R, mejor para él. Si alguien quiere darle dinero a
Microsoft por algo que puede conseguir gratis en otra parte, peor para él.

El único riesgo sería no tanto un "fork" --que estaría cubierto por la GPL
y tendría que ser libre-- como una reimplementación de cero parecida pero
no 100% compatible con R. Sería un caso parecido al de las diversas
máquinas virtuales de Java o compiladores de C. Si esa reimplementación no
fuese libre pero funcionase mejor que la habitual, tendríamos un problema.

Mientras tanto, creo que no hay motivo para preocuparse.

Un saludo,

Carlos J. Gil Bellosta
http://www.datanalytics.com

[[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] nueva distribución de R y problema solucionado

2016-03-02 Thread miguel.angel.rodriguez.muinos
Hola Javier.

Disculpa por haber utilizado un localismo en esa frase hecha.
Me refiero, como le he comentado a Carlos Ortega, a que "adaptar (ojo, no 
adoptar) estándares en propio beneficio aprovechando la posición dominante para 
imponer un modelo" no es algo que sea de mi agrado.

Un Saludo,
Miguel.




El 02/03/2016 a las 14:53, Javier Marcuzzi escribió:
Estimado Miguel Muinos

El problema con neuralnet fue resuelto.

Hay personas que apostaron por R, desarrollaron paquetes, usaron librerías 
optimizadas (como las de INTEL) a un costo económico. Microsoft decidió apostar 
por R y si R es código abierto algunos motivos tenían para comprar la empresa 
anterior.

Es ¿todo mejor?, no tengo ni la menor idea, pero si no lo pruebo yo mismo me 
excluyo.

CRAN vs MRAM, desconozco la cantidad como posibles diferencias, en 
mantenimiento, compilación, etc. Pero se me ocurrió abrir un archivo viejo de 
MCMCglmm, la librería se encontraba en la versión “vieja” de R que desinstalé 
antes de instalar la de Microsoft, el análisis corrió sin problema, por lo cuál 
uno podría utilizar el repositorio de librerías que prefiera.

“tirar por su cuenta”, desconozco el significado, es una frase idiomática que 
en esta región no se utiliza, pero yo usé Linux, mac y ahora Windows, todos los 
sistemas con R y hay puntos fuertes y problemáticos en cada sistema, mi mejor 
experiencia con R fue en mac, pero estoy hablando de unos 8 años atrás, hoy no 
lo sé.


Javier Rubén Marcuzzi









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

[[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] nueva distribución de R y problema solucionado

2016-03-02 Thread miguel.angel.rodriguez.muinos
Gracias por la aclaración, Carlos.

Mis temores iban en caminados a sospechar si MS empezaría a compilar sus 
propias versiones de los paquetes del CRAN.

En el pasado han tendido (en determinados casos) a "modificar las cosas a su 
imagen y semejanza" y ya conocemos algunos de los resultados.

Un saludo,
Miguel.



El 02/03/2016 a las 15:06, Carlos Ortega escribió:
Hola,

Microsoft mantiene una versión propia de "R", que es la distribución de 
Revolutions Analytics que compró el año pasado.
Esta distribución de "R" incluye ventajas para el uso de "R" en empresas: 
procesado en paralelo,  tratamiento de BigData donde R en su distribución 
normal no termina de funcionar de una manera fluida. Para ello han modificado 
desde la estructura de sus data.frames (a un formato propietario xdf), y la 
modificación de algunos algoritmos para hacer regresiones lineales y modelos 
generalizados.

Otra de las mejoras que han introducido y está disponible como paquete para 
todos, es el uso de un repositorio fiable. Algo que para las empresas que tenga 
R en Producción es muy interesante. Con esta funcionalidad, te permite tener 
una versión congelada de los paquetes disponibles en CRAN y que son compatibles 
con tu versión "Microsoft" de R. Así garantizas las reproducibilidad y evitas 
los grandes problemas que todos hemos tenido de que cambias de versión del 
paquete y muchas cosas dejan de funcionar.

No es que Microsoft mantenga versiones de cada paquete para hacerlo compatible 
con su solución... Son los mismos paquetes de CRAN. Pero con la opción de que 
con ese paquete ("checkpoint") puedas llevar un mejor control de los paquetes 
que son compatibles con tu versión de "R".

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 2 de marzo de 2016, 11:06, 
>
 escribió:
Hola Javier.

En el CRAN, ahora mismo hay 8016 packages y en el repositorio de MRAM
hay 8011.
Sería bueno saber si es un "mirror" o lo mantienen por su cuenta (cosa
que no me he parado a verificar).

Que Microsoft tenga su propia versión de R y (si es el caso) su propia
versión de los paquetes... con lo dados que han sido en el pasado a
"tirar por su cuenta".. no sé yo...

Opiniones?

Un Saludo,

--
Miguel Ángel Rodríguez Muíños
Dirección Xeral de Saúde Pública
Consellería de Sanidade
Xunta de Galicia
http://dxsp.sergas.es



El 01/03/2016 a las 23:25, Javier Marcuzzi escribió:
> Estimados
>
> Hace un tiempo pregunte por un problema con neuralnet, hoy instale R desde 
>  https://mran.revolutionanalytics.com/ 
> y el problema anterior fue solucionado por sus desarrolladores, pero me 
> asombre por un cambio en la velocidad (no use un test con muchos datos como 
> para ser objetivos pero la experiencia de usuario es fluida).
>
> Simplemente comparto el link por si a alguno le interesa usar esa opción de R.
>
> Javier Rubén Marcuzzi
>
>
>   [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es








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


--
Miguel Ángel Rodríguez Muíños
Asesoramento en Informática
Dirección Xeral de Saúde Pública
Consellería de Sanidade
Xunta de Galicia
http://dxsp.sergas.es








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 

Re: [R-es] nueva distribución de R y problema solucionado

2016-03-02 Thread Carlos Ortega
Hola,

Microsoft mantiene una versión propia de "R", que es la distribución de
Revolutions Analytics que compró el año pasado.
Esta distribución de "R" incluye ventajas para el uso de "R" en empresas:
procesado en paralelo,  tratamiento de BigData donde R en su distribución
normal no termina de funcionar de una manera fluida. Para ello han
modificado desde la estructura de sus data.frames (a un formato propietario
xdf), y la modificación de algunos algoritmos para hacer regresiones
lineales y modelos generalizados.

Otra de las mejoras que han introducido y está disponible como paquete para
todos, es el uso de un repositorio fiable. Algo que para las empresas que
tenga R en Producción es muy interesante. Con esta funcionalidad, te
permite tener una versión congelada de los paquetes disponibles en CRAN y
que son compatibles con tu versión "Microsoft" de R. Así garantizas las
reproducibilidad y evitas los grandes problemas que todos hemos tenido de
que cambias de versión del paquete y muchas cosas dejan de funcionar.

No es que Microsoft mantenga versiones de cada paquete para hacerlo
compatible con su solución... Son los mismos paquetes de CRAN. Pero con la
opción de que con ese paquete ("checkpoint") puedas llevar un mejor control
de los paquetes que son compatibles con tu versión de "R".

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 2 de marzo de 2016, 11:06, 
escribió:

> Hola Javier.
>
> En el CRAN, ahora mismo hay 8016 packages y en el repositorio de MRAM
> hay 8011.
> Sería bueno saber si es un "mirror" o lo mantienen por su cuenta (cosa
> que no me he parado a verificar).
>
> Que Microsoft tenga su propia versión de R y (si es el caso) su propia
> versión de los paquetes... con lo dados que han sido en el pasado a
> "tirar por su cuenta".. no sé yo...
>
> Opiniones?
>
> Un Saludo,
>
> --
> Miguel Ángel Rodríguez Muíños
> Dirección Xeral de Saúde Pública
> Consellería de Sanidade
> Xunta de Galicia
> http://dxsp.sergas.es
>
>
>
> El 01/03/2016 a las 23:25, Javier Marcuzzi escribió:
> > Estimados
> >
> > Hace un tiempo pregunte por un problema con neuralnet, hoy instale R
> desde https://mran.revolutionanalytics.com/ y el problema anterior fue
> solucionado por sus desarrolladores, pero me asombre por un cambio en la
> velocidad (no use un test con muchos datos como para ser objetivos pero la
> experiencia de usuario es fluida).
> >
> > Simplemente comparto el link por si a alguno le interesa usar esa opción
> de R.
> >
> > Javier Rubén Marcuzzi
> >
> >
> >   [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
>
>
>
>
> 
>
> 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] Change the location of R

2016-03-02 Thread carol white via R-help
Hi,I have R v 3.0 installed /usr/... and the new version R-3.2.3 in my home 
under ubuntu. Is it correct to copy the R-3.2.3 directory into 
/usr/local/lib/R/ or should I reconfig and remake into /usr/local/lib/R/?
Regards,
Carol

[[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] nueva distribución de R y problema solucionado

2016-03-02 Thread Javier Marcuzzi
Estimado Miguel Muinos

El problema con neuralnet fue resuelto.

Hay personas que apostaron por R, desarrollaron paquetes, usaron librerías 
optimizadas (como las de INTEL) a un costo económico. Microsoft decidió apostar 
por R y si R es código abierto algunos motivos tenían para comprar la empresa 
anterior.

Es ¿todo mejor?, no tengo ni la menor idea, pero si no lo pruebo yo mismo me 
excluyo.

CRAN vs MRAM, desconozco la cantidad como posibles diferencias, en 
mantenimiento, compilación, etc. Pero se me ocurrió abrir un archivo viejo de 
MCMCglmm, la librería se encontraba en la versión “vieja” de R que desinstalé 
antes de instalar la de Microsoft, el análisis corrió sin problema, por lo cuál 
uno podría utilizar el repositorio de librerías que prefiera.

“tirar por su cuenta”, desconozco el significado, es una frase idiomática que 
en esta región no se utiliza, pero yo usé Linux, mac y ahora Windows, todos los 
sistemas con R y hay puntos fuertes y problemáticos en cada sistema, mi mejor 
experiencia con R fue en mac, pero estoy hablando de unos 8 años atrás, hoy no 
lo sé. 


Javier Rubén Marcuzzi

De: miguel.angel.rodriguez.mui...@sergas.es
Enviado: miércoles, 2 de marzo de 2016 7:06
Para: javier.ruben.marcu...@gmail.com; R-help-es@r-project.org
Asunto: Re: [R-es] nueva distribución de R y problema solucionado

Hola Javier.

En el CRAN, ahora mismo hay 8016 packages y en el repositorio de MRAM
hay 8011.
Sería bueno saber si es un "mirror" o lo mantienen por su cuenta (cosa
que no me he parado a verificar).

Que Microsoft tenga su propia versión de R y (si es el caso) su propia
versión de los paquetes... con lo dados que han sido en el pasado a
"tirar por su cuenta".. no sé yo...

Opiniones?

Un Saludo,

--
Miguel Ángel Rodríguez Muíños
Dirección Xeral de Saúde Pública
Consellería de Sanidade
Xunta de Galicia



El 01/03/2016 a las 23:25, Javier Marcuzzi escribió:
> Estimados
>
> Hace un tiempo pregunte por un problema con neuralnet, hoy instale R desde 
> https://mran.revolutionanalytics.com/ y el problema anterior fue solucionado 
> por sus desarrolladores, pero me asombre por un cambio en la velocidad (no 
> use un test con muchos datos como para ser objetivos pero la experiencia de 
> usuario es fluida).
>
> Simplemente comparto el link por si a alguno le interesa usar esa opción de R.
>
> Javier Rubén Marcuzzi
>
>
>   [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es








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


[[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] Consulta r studio no funciona

2016-03-02 Thread Carlos Guadián Orta
Hola Amalia, mira el siguiente artículo en el que citan los problemas más
habituales para que RStudio no inicie sesión en Windows, espero que te
sirva de ayuda.

https://support.rstudio.com/hc/en-us/articles/200488508-RStudio-Will-Not-Start

Saludos,


[image: carlos-guadian-avatar-firma.png]

Carlos Guadián Orta

Mi Twitter es @carlosguadian 

Mi blog es K-Government 

Mi perfil profesional en LinkedIn 

Trabajo en Autoritas Consulting 

Coordino #oGov 

El 2 de marzo de 2016, 11:55, Amalia Carolina Guaymas Canavire <
acarolin...@gmail.com> escribió:

> Hola, si lo tengo instalado.
>
> *Lic. Amalia Carolina Guaymás Canavire*
>
> *Especialista en Data mining *
>
>
>
> El 1 de marzo de 2016, 23:54, Jorge I Velez 
> escribió:
>
> > Amalia,
> > Instalaste R?  Necesitas R para que RStudio funcione.
> > Saludos,
> > Jorge.-
> >
> >
> >
> > 2016-03-01 21:45 GMT-05:00 Amalia Carolina Guaymas Canavire <
> > acarolin...@gmail.com>:
> >
> >> Hola les escribo porque R studio en windows 8 no me funciona y no sé
> como
> >> solucionarlo. El error que arroja es que R no puede iniciar, la sección
> de
> >> environment  no se carga, aparece como procesando y cuando deseo probar
> >> algo en la consola la misma no devuelve resultado.
> >> Re instale R studio y aún persiste el error.
> >> Gracias por su ayuda.
> >>
> >> [[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
>

[[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] Uso excesivo de CPU de RStudio

2016-03-02 Thread Pedro Concejero Cerezo
Me parece que ya esta mencionado en el hilo previo, RStudio parece que en 
ocasiones no consigue terminar adecuadamente un proceso o rsession en algunas 
versiones de linux.
Yo solo he usado RStudio-server sobre CentOs en remoto (desde navegador, va 
fenomenal) pero he tenido que matarlo y de hecho limpiar el workspace porque se 
queda un proceso zombi. Y por ejemplo en ejecuciones en paralelo con foreach, 
incluso despues de haber cerrado RStudio he tenido que ir matando los procesos 
que por lo que sea han quedado lanzados.
Pero una vez limpiado workspace y reiniciado no lo ha vuelto a hacer.

El 02/03/2016 a las 12:00, 
r-help-es-requ...@r-project.org 
escribi�:

Re: Uso excesivo de CPU de RStudio (Jorge Ayuso Rejas)


--
Pedro Concejero
E-mail: 
pedro.concejerocer...@telefonica.com
skype: pedro.concejero
twitter @ConcejeroPedro
linkedin pedroconcejero
Entusiasta R, me encontrar�is aqu� gRupo R madRid 



Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede 
contener informaci�n privilegiada o confidencial y es para uso exclusivo de la 
persona o entidad de destino. Si no es usted. el destinatario indicado, queda 
notificado de que la lectura, utilizaci�n, divulgaci�n y/o copia sin 
autorizaci�n puede estar prohibida en virtud de la legislaci�n vigente. Si ha 
recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente 
por esta misma v�a y proceda a su destrucci�n.

The information contained in this transmission is privileged and confidential 
information intended only for the use of the individual or entity named above. 
If the reader of this message is not the intended recipient, you are hereby 
notified that any dissemination, distribution or copying of this communication 
is strictly prohibited. If you have received this transmission in error, do not 
read it. Please immediately reply to the sender that you have received this 
communication in error and then delete it.

Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinat�rio, pode 
conter informa��o privilegiada ou confidencial e � para uso exclusivo da pessoa 
ou entidade de destino. Se n�o � vossa senhoria o destinat�rio indicado, fica 
notificado de que a leitura, utiliza��o, divulga��o e/ou c�pia sem autoriza��o 
pode estar proibida em virtude da legisla��o vigente. Se recebeu esta mensagem 
por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e 
proceda a sua destrui��o

[[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] Consulta r studio no funciona

2016-03-02 Thread Amalia Carolina Guaymas Canavire
Hola, si lo tengo instalado.

*Lic. Amalia Carolina Guaymás Canavire*

*Especialista en Data mining *



El 1 de marzo de 2016, 23:54, Jorge I Velez 
escribió:

> Amalia,
> Instalaste R?  Necesitas R para que RStudio funcione.
> Saludos,
> Jorge.-
>
>
>
> 2016-03-01 21:45 GMT-05:00 Amalia Carolina Guaymas Canavire <
> acarolin...@gmail.com>:
>
>> Hola les escribo porque R studio en windows 8 no me funciona y no sé como
>> solucionarlo. El error que arroja es que R no puede iniciar, la sección de
>> environment  no se carga, aparece como procesando y cuando deseo probar
>> algo en la consola la misma no devuelve resultado.
>> Re instale R studio y aún persiste el error.
>> Gracias por su ayuda.
>>
>> [[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


Re: [R-es] nueva distribución de R y problema solucionado

2016-03-02 Thread miguel.angel.rodriguez.muinos
Hola Javier.

En el CRAN, ahora mismo hay 8016 packages y en el repositorio de MRAM
hay 8011.
Sería bueno saber si es un "mirror" o lo mantienen por su cuenta (cosa
que no me he parado a verificar).

Que Microsoft tenga su propia versión de R y (si es el caso) su propia
versión de los paquetes... con lo dados que han sido en el pasado a
"tirar por su cuenta".. no sé yo...

Opiniones?

Un Saludo,

--
Miguel Ángel Rodríguez Muíños
Dirección Xeral de Saúde Pública
Consellería de Sanidade
Xunta de Galicia
http://dxsp.sergas.es



El 01/03/2016 a las 23:25, Javier Marcuzzi escribió:
> Estimados
>
> Hace un tiempo pregunte por un problema con neuralnet, hoy instale R desde 
> https://mran.revolutionanalytics.com/ y el problema anterior fue solucionado 
> por sus desarrolladores, pero me asombre por un cambio en la velocidad (no 
> use un test con muchos datos como para ser objetivos pero la experiencia de 
> usuario es fluida).
>
> Simplemente comparto el link por si a alguno le interesa usar esa opción de R.
>
> Javier Rubén Marcuzzi
>
>
>   [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es








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] path + name of the running R file

2016-03-02 Thread PIKAL Petr
Hi Jean

As I said I am not a programmer, although I made some stuff with old languages 
like Basic (not Visual) or some kind of assembly language from late 80s.
So your questions are out of my depth.

I hope others can give you better insight.

Cheers
Petr


> -Original Message-
> From: MAURICE Jean - externe [mailto:jean-externe.maur...@edf.fr]
> Sent: Wednesday, March 02, 2016 9:03 AM
> To: PIKAL Petr; r-help@r-project.org
> Subject: RE: path + name of the running R file
>
> Hi Petr,
>
> I am an old FORTRAN programmer and new to R. The 'philosophy' of R is
> very very far from FORTRAN ! So, may be I am wrong but :
>
> I want to test 3 projects. In fact, these 3 projects are identical but
> not in the same directory : one within Git (a source management), one
> on the server and the last one on my local machine. When I run the one
> in Git, R bombs (and I have no error code, line number, ...). I try to
> detect what is wrong. So I add cat(), browser() ... to try to 'narrow'
> the fault (is that clear ?) and the "source()" command is in my target.
> So I change the current project every 5 minutes ... So when I launch
> (start ?) the execution of one project and in some functions , I'd like
> to have the path + name of the .R file being used (perhaps the 'main'
> file of Git project is doing a source() on a file on the server instead
> of the one on the Git directory : do you see what I am looking for ?).
> In other words, I am not sure 100% of the "source()" command and I want
> to verify it ...
>
> Jean
>
>
>
> Ce message et toutes les pièces jointes (ci-après le 'Message') sont
> établis à l'intention exclusive des destinataires et les informations
> qui y figurent sont strictement confidentielles. Toute utilisation de
> ce Message non conforme à sa destination, toute diffusion ou toute
> publication totale ou partielle, est interdite sauf autorisation
> expresse.
>
> Si vous n'êtes pas le destinataire de ce Message, il vous est interdit
> de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout
> ou partie. Si vous avez reçu ce Message par erreur, merci de le
> supprimer de votre système, ainsi que toutes ses copies, et de n'en
> garder aucune trace sur quelque support que ce soit. Nous vous
> remercions également d'en avertir immédiatement l'expéditeur par retour
> du message.
>
> Il est impossible de garantir que les communications par messagerie
> électronique arrivent en temps utile, sont sécurisées ou dénuées de
> toute erreur ou virus.
> 
>
> This message and any attachments (the 'Message') are intended solely
> for the addressees. The information contained in this Message is
> confidential. Any use of information contained in this Message not in
> accord with its purpose, any dissemination or disclosure, either whole
> or partial, is prohibited except formal approval.
>
> If you are not the addressee, you may not copy, forward, disclose or
> use any part of it. If you have received this message in error, please
> delete it and all copies from your system and notify the sender
> immediately by return message.
>
> E-mail communication cannot be guaranteed to be timely secure, error or
> virus-free.


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

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

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, 

Re: [R] how to get the 'starting directory'

2016-03-02 Thread MAURICE Jean - externe
Hi Martin,

And you forgot Git !

So for now, I gave up (abandonned ?) Git

And if Rstudio annoys me once more, I'll abandon it (skip it ?)

I like when things are simple and when I error occurs I like to have a message 
...

Jean
PS I know something complicated that is very simple to use : SBB CFF FFS !

-Message d'origine-
De : maech...@stat.math.ethz.ch [mailto:maech...@stat.math.ethz.ch] 
Envoyé : mercredi 2 mars 2016 10:40
À : MAURICE Jean - externe
Cc : jdnew...@dcn.davis.ca.us; r-help@r-project.org
Objet : Re: [R] how to get the 'starting directory'

> MAURICE Jean <- externe >
> on Wed, 2 Mar 2016 08:50:50 + writes:

> The message with the bomb is R session .. see picture
> Jean

> De : jdnew...@dcn.davis.ca.us [mailto:jdnew...@dcn.davis.ca.us]
> Envoyé : mercredi 2 mars 2016 09:10
> À : MAURICE Jean - externe; petr.pi...@precheza.cz; r-help@r-project.org
> Objet : Re: [R] how to get the 'starting directory'

> I am guessing that it is RStudio that bombs... I have seen that bomb 
dialog from RStudio but never from R. However, this is not the RStudio support 
forum... you should be asking someone involved with that software.
> --

> x[DELETED ATTACHMENT Capture_bombe_R.PNG, PNG image]

Indeed, as Petr guessed correctly, this is what  Rstudio produces for you.

and, indeed #2, Jean,  you (and many others!) should learn to distinguish 
between R and  Rstudio+R ( or ESS+R or StatET+R ).

The more sophisticated these GUIs become, the more often we have to make this 
distinction, unfortunately, as the price for sophistication unfortunately is 
typically paid by more bugs.
This is not just the case for Rstudio but ESS as well (says a long time ESS 
project maintainer).

Martin Maechler, ETH Zurich



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.

__
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] how to get the 'starting directory'

2016-03-02 Thread Martin Maechler
> MAURICE Jean <- externe >
> on Wed, 2 Mar 2016 08:50:50 + writes:

> The message with the bomb is R session .. see picture
> Jean

> De : jdnew...@dcn.davis.ca.us [mailto:jdnew...@dcn.davis.ca.us]
> Envoyé : mercredi 2 mars 2016 09:10
> À : MAURICE Jean - externe; petr.pi...@precheza.cz; r-help@r-project.org
> Objet : Re: [R] how to get the 'starting directory'

> I am guessing that it is RStudio that bombs... I have seen that bomb 
dialog from RStudio but never from R. However, this is not the RStudio support 
forum... you should be asking someone involved with that software.
> --

> x[DELETED ATTACHMENT Capture_bombe_R.PNG, PNG image]

Indeed, as Petr guessed correctly, this is what  Rstudio
produces for you.

and, indeed #2, Jean,  you (and many others!) should learn to
distinguish between R and  Rstudio+R ( or ESS+R or StatET+R ).

The more sophisticated these GUIs become, the more often we have
to make this distinction, unfortunately, as the price for
sophistication unfortunately is typically paid by more bugs.
This is not just the case for Rstudio but ESS as well (says a
long time ESS project maintainer).

Martin Maechler, ETH Zurich

__
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] path + name of the running R file

2016-03-02 Thread MAURICE Jean - externe
> from late 80s

The good old time 

Jean

-Message d'origine-
De : petr.pi...@precheza.cz [mailto:petr.pi...@precheza.cz] 
Envoyé : mercredi 2 mars 2016 09:51
À : MAURICE Jean - externe; r-help@r-project.org
Objet : RE: path + name of the running R file

Hi Jean

As I said I am not a programmer, although I made some stuff with old languages 
like Basic (not Visual) or some kind of assembly language from late 80s.
So your questions are out of my depth.

I hope others can give you better insight.

Cheers
Petr



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.
__
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] how to get the 'starting directory'

2016-03-02 Thread MAURICE Jean - externe
The message with the bomb is R session .. see picture

Jean

De : jdnew...@dcn.davis.ca.us [mailto:jdnew...@dcn.davis.ca.us]
Envoyé : mercredi 2 mars 2016 09:10
À : MAURICE Jean - externe; petr.pi...@precheza.cz; r-help@r-project.org
Objet : Re: [R] how to get the 'starting directory'

I am guessing that it is RStudio that bombs... I have seen that bomb dialog 
from RStudio but never from R. However, this is not the RStudio support 
forum... you should be asking someone involved with that software.
--
Sent from my phone. Please excuse my brevity.



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.
__
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] ggplot2-theme(panel.border)

2016-03-02 Thread Aashish Jain
You can write "fill = NA" in the argument of element_rect(), that should
solve your problem.

On Tue, Mar 1, 2016 at 3:46 PM, Hoji, Akihiko  wrote:

> A quick question.  How come data points disappear when
> “theme(panel.border=element_rect()) is used and how could I get those
> points back on the plot ?
>
> Thanks in advance.
>
> AH
> __
> 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] path + name of the running R file

2016-03-02 Thread MAURICE Jean - externe
I suppose (think) that, in RStudio the shorcut alt+ctrl+R is converted to a 
source command so it can work : I try.

Thanks
Jean

-Message d'origine-
De : drjimle...@gmail.com [mailto:drjimle...@gmail.com] 
Envoyé : mercredi 2 mars 2016 09:13
À : MAURICE Jean - externe; r-help@r-project.org
Objet : Re: [R] path + name of the running R file

Hi Maurice,
If you have used "source" to run an R script, perhaps you could try something 
like this:

get.running.file<-function(pattern="source",...) {
 file1 <- tempfile("Rrawhist")
 savehistory(file1)
 rawhist <- readLines(file1)
 unlink(file1)
 last.source<-grep(pattern,rev(rawhist),value=TRUE)[1]
 sourced.file<-unlist(strsplit(last.source,'"'))[2]
 return(sourced.file)
}

This is taken from the "history" function and tries to find the last "source" 
command in the command history and extract the name of the sourced file. It is 
very rough, but it does work as long as the first argument to the "source" 
function is the quoted name of the sourced file.

Jim



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.
__
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] how to get the 'starting directory'

2016-03-02 Thread MAURICE Jean - externe
I didn’t know that Rstudio was a separate tool ! So now, I have a new field to 
manage  !

Thanks
Jean



De : jdnew...@dcn.davis.ca.us [mailto:jdnew...@dcn.davis.ca.us]
Envoyé : mercredi 2 mars 2016 09:10
À : MAURICE Jean - externe; petr.pi...@precheza.cz; r-help@r-project.org
Objet : Re: [R] how to get the 'starting directory'

I am guessing that it is RStudio that bombs... I have seen that bomb dialog 
from RStudio but never from R. However, this is not the RStudio support 
forum... you should be asking someone involved with that software.
--
Sent from my phone. Please excuse my brevity.



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.

[[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] path + name of the running R file

2016-03-02 Thread Jim Lemon
Hi Maurice,
If you have used "source" to run an R script, perhaps you could try
something like this:

get.running.file<-function(pattern="source",...) {
 file1 <- tempfile("Rrawhist")
 savehistory(file1)
 rawhist <- readLines(file1)
 unlink(file1)
 last.source<-grep(pattern,rev(rawhist),value=TRUE)[1]
 sourced.file<-unlist(strsplit(last.source,'"'))[2]
 return(sourced.file)
}

This is taken from the "history" function and tries to find the last
"source" command in the command history and extract the name of the
sourced file. It is very rough, but it does work as long as the first
argument to the "source" function is the quoted name of the sourced
file.

Jim


On Wed, Mar 2, 2016 at 6:01 PM, MAURICE Jean - externe
 wrote:
> Hi,
>
> Is it possible to get the path and name of the running R file ?
>
> Jean
>
>
>
>
> Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis 
> à l'intention exclusive des destinataires et les informations qui y figurent 
> sont strictement confidentielles. Toute utilisation de ce Message non 
> conforme à sa destination, toute diffusion ou toute publication totale ou 
> partielle, est interdite sauf autorisation expresse.
>
> Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
> copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. 
> Si vous avez reçu ce Message par erreur, merci de le supprimer de votre 
> système, ainsi que toutes ses copies, et de n'en garder aucune trace sur 
> quelque support que ce soit. Nous vous remercions également d'en avertir 
> immédiatement l'expéditeur par retour du message.
>
> Il est impossible de garantir que les communications par messagerie 
> électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
> erreur ou virus.
> 
>
> This message and any attachments (the 'Message') are intended solely for the 
> addressees. The information contained in this Message is confidential. Any 
> use of information contained in this Message not in accord with its purpose, 
> any dissemination or disclosure, either whole or partial, is prohibited 
> except formal approval.
>
> If you are not the addressee, you may not copy, forward, disclose or use any 
> part of it. If you have received this message in error, please delete it and 
> all copies from your system and notify the sender immediately by return 
> message.
>
> E-mail communication cannot be guaranteed to be timely secure, error or 
> virus-free.
>
> __
> 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] how to get the 'starting directory'

2016-03-02 Thread Jeff Newmiller
I am guessing that it is RStudio that bombs... I have seen that bomb dialog 
from RStudio but never from R. However,  this is not the RStudio support 
forum... you should be asking someone involved with that software.
-- 
Sent from my phone. Please excuse my brevity.

On March 1, 2016 11:38:00 PM PST, MAURICE Jean - externe 
 wrote:
>Thanks Petr,
>
>ALT + CTRL + R is a shortcut in RSTUDIO to RUN ALL
>
>As I shall work with another developer, I installed GIT (a source
>manager) but now R 'bombs'. I have 3 versions of my R sources (in fact
>a file with the 'master' and one with all the functions) : one project
>within Git, one project on a server and the last project on my local
>machine.
>
>Having the starting directory can give me, in the console or in a text
>file, the project being used.
>
>In other words I start RStudio in a directory and change projects, each
>being in its own directory
>
>Is that more clear ?
>
>Jean
>
>
>
>Ce message et toutes les pièces jointes (ci-après le 'Message') sont
>établis à l'intention exclusive des destinataires et les informations
>qui y figurent sont strictement confidentielles. Toute utilisation de
>ce Message non conforme à sa destination, toute diffusion ou toute
>publication totale ou partielle, est interdite sauf autorisation
>expresse.
>
>Si vous n'êtes pas le destinataire de ce Message, il vous est interdit
>de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout
>ou partie. Si vous avez reçu ce Message par erreur, merci de le
>supprimer de votre système, ainsi que toutes ses copies, et de n'en
>garder aucune trace sur quelque support que ce soit. Nous vous
>remercions également d'en avertir immédiatement l'expéditeur par retour
>du message.
>
>Il est impossible de garantir que les communications par messagerie
>électronique arrivent en temps utile, sont sécurisées ou dénuées de
>toute erreur ou virus.
>
>
>This message and any attachments (the 'Message') are intended solely
>for the addressees. The information contained in this Message is
>confidential. Any use of information contained in this Message not in
>accord with its purpose, any dissemination or disclosure, either whole
>or partial, is prohibited except formal approval.
>
>If you are not the addressee, you may not copy, forward, disclose or
>use any part of it. If you have received this message in error, please
>delete it and all copies from your system and notify the sender
>immediately by return message.
>
>E-mail communication cannot be guaranteed to be timely secure, error or
>virus-free.
>__
>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] path + name of the running R file

2016-03-02 Thread MAURICE Jean - externe
Hi Petr,

I am an old FORTRAN programmer and new to R. The 'philosophy' of R is very very 
far from FORTRAN ! So, may be I am wrong but :

I want to test 3 projects. In fact, these 3 projects are identical but not in 
the same directory : one within Git (a source management), one on the server 
and the last one on my local machine. When I run the one in Git, R bombs (and I 
have no error code, line number, ...). I try to detect what is wrong. So I add 
cat(), browser() ... to try to 'narrow' the fault (is that clear ?) and the 
"source()" command is in my target. So I change the current project every 5 
minutes ... So when I launch (start ?) the execution of one project and in some 
functions , I'd like to have the path + name of the .R file being used (perhaps 
the 'main' file of Git project is doing a source() on a file on the server 
instead of the one on the Git directory : do you see what I am looking for ?). 
In other words, I am not sure 100% of the "source()" command and I want to 
verify it ...

Jean



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.
__
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.