Re: [R] how to show percentage of individuals for two groups on histogram?

2020-05-21 Thread Eric Berger
Hi Ana,
This is a very common question about ggplot.
A quick search turns up lots of hits that answer your question. Here
are a couple
https://community.rstudio.com/t/trouble-scaling-y-axis-to-percentages-from-counts/42999
https://stackoverflow.com/questions/3695497/show-instead-of-counts-in-charts-of-categorical-variables

>From reading those discussions, the following should work (untested)

ggplot(a, aes(x = HBA1C, fill=pheno)) + geom_histogram(aes(y =
stat(density)), binwidth = 0.5) +
  scale_y_continuous(labels = scales::percent_format())

HTH,
Eric


On Fri, May 22, 2020 at 7:18 AM Jim Lemon  wrote:
>
> Hi Ana,
> Just noticed a typo from a hasty cut-paste. Two lines should read:
>
> casehist<-table(cut(aafd$HBAIC[aafd$pheno=="case"],breaks=0:15))
> controlhist<-table(cut(aafd$HBAIC[aafd$pheno=="control"],breaks=0:15))
>
> Jim
>
> On Fri, May 22, 2020 at 2:08 PM Jim Lemon  wrote:
> >
> > Hi Ana,
> > My apologies for the pedestrian graphics, but it may help.
> >
> > # a bit of fake data
> > aafd<-data.frame(FID=paste0("fam",1000:2739),
> >  IID=paste0("G",1000,2739),FLASER=rep(1,1740),
> >  PLASER=c(rep(1,892),rep(2,848)),
> >  DIABDUR=sample(10:50,1740,TRUE),
> >  HBAIC=rnorm(1740,mean=7.45,sd=2),ESRD=rep(1,1740),
> >  pheno=c(rep("control",892),rep("case",848)))
> > par(mfrow=c(2,1))
> > casepct<-table(cut(aafd$HBAIC[aafd$pheno=="case"],breaks=0:15))
> > controlpct<-table(cut(aafd$HBAIC[aafd$pheno=="control"],breaks=0:15))
> > par(mar=c(0,4,1,2))
> > barpos=barplot(100*casehist,names.arg=names(casepct),col="orange",
> >  space=0,ylab="Percentage",xaxt="n",ylim=c(0,25))
> > text(mean(barpos),23,
> >  "Cases: n=848, nulls=26, median=7.3, mean=7.45, sd=1.96")
> > box()
> > par(mar=c(3,4,0,2))
> > barplot(100*controlhist,names.arg=names(controlpct),
> >  space=0,ylab="Percentage",col="orange",ylim=c(0,25))
> > text(mean(barpos),23,
> >  "Controls: n=892, nulls=7, median=7.3, mean=7.45, sd=1.12")
> > box()
> >
> > Jim
> >
> > On Fri, May 22, 2020 at 9:08 AM Ana Marija  
> > wrote:
> > >
> > > the result would basically look something like this on in attach or
> > > the overlay of those two plots
> > >
> > >
> > > On Thu, May 21, 2020 at 5:23 PM Ana Marija  
> > > wrote:
> > > >
> > > > Hello,
> > > >
> > > > I have a data frame like this:
> > > > > head(a)
> > > >  FID   IID FLASER PLASER DIABDUR HBA1C ESRD   pheno
> > > > 1 fam1000-03 G1000  1  1  38  10.21 control
> > > > 2 fam1001-03 G1001  1  1  15   7.31 control
> > > > 3 fam1003-03 G1003  1  2  17   7.01case
> > > > 4 fam1005-03 G1005  1  1  36   7.71 control
> > > > 5 fam1009-03 G1009  1  1  23   7.61 control
> > > > 6 fam1052-03 G1052  1  1  32   7.31 control
> > > >
> > > > > dim(a)
> > > > [1] 16988
> > > >
> > > > I am doing histogram plot via:
> > > > ggplot(a, aes(x=HBA1C, fill=pheno)) + geom_histogram(binwidth=.5,
> > > > position="dodge")
> > > >
> > > > there is 848 who have "case" in pheno column and 892 who have
> > > > "control" in pheno column.
> > > >
> > > > I would like to have on y-axis shown percentage of individuals which
> > > > have either "case" or "control" in pheno instead of count.
> > > >
> > > > Please advise,
> > > > Ana
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide 
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] how to show percentage of individuals for two groups on histogram?

2020-05-21 Thread Jim Lemon
Hi Ana,
Just noticed a typo from a hasty cut-paste. Two lines should read:

casehist<-table(cut(aafd$HBAIC[aafd$pheno=="case"],breaks=0:15))
controlhist<-table(cut(aafd$HBAIC[aafd$pheno=="control"],breaks=0:15))

Jim

On Fri, May 22, 2020 at 2:08 PM Jim Lemon  wrote:
>
> Hi Ana,
> My apologies for the pedestrian graphics, but it may help.
>
> # a bit of fake data
> aafd<-data.frame(FID=paste0("fam",1000:2739),
>  IID=paste0("G",1000,2739),FLASER=rep(1,1740),
>  PLASER=c(rep(1,892),rep(2,848)),
>  DIABDUR=sample(10:50,1740,TRUE),
>  HBAIC=rnorm(1740,mean=7.45,sd=2),ESRD=rep(1,1740),
>  pheno=c(rep("control",892),rep("case",848)))
> par(mfrow=c(2,1))
> casepct<-table(cut(aafd$HBAIC[aafd$pheno=="case"],breaks=0:15))
> controlpct<-table(cut(aafd$HBAIC[aafd$pheno=="control"],breaks=0:15))
> par(mar=c(0,4,1,2))
> barpos=barplot(100*casehist,names.arg=names(casepct),col="orange",
>  space=0,ylab="Percentage",xaxt="n",ylim=c(0,25))
> text(mean(barpos),23,
>  "Cases: n=848, nulls=26, median=7.3, mean=7.45, sd=1.96")
> box()
> par(mar=c(3,4,0,2))
> barplot(100*controlhist,names.arg=names(controlpct),
>  space=0,ylab="Percentage",col="orange",ylim=c(0,25))
> text(mean(barpos),23,
>  "Controls: n=892, nulls=7, median=7.3, mean=7.45, sd=1.12")
> box()
>
> Jim
>
> On Fri, May 22, 2020 at 9:08 AM Ana Marija  
> wrote:
> >
> > the result would basically look something like this on in attach or
> > the overlay of those two plots
> >
> >
> > On Thu, May 21, 2020 at 5:23 PM Ana Marija  
> > wrote:
> > >
> > > Hello,
> > >
> > > I have a data frame like this:
> > > > head(a)
> > >  FID   IID FLASER PLASER DIABDUR HBA1C ESRD   pheno
> > > 1 fam1000-03 G1000  1  1  38  10.21 control
> > > 2 fam1001-03 G1001  1  1  15   7.31 control
> > > 3 fam1003-03 G1003  1  2  17   7.01case
> > > 4 fam1005-03 G1005  1  1  36   7.71 control
> > > 5 fam1009-03 G1009  1  1  23   7.61 control
> > > 6 fam1052-03 G1052  1  1  32   7.31 control
> > >
> > > > dim(a)
> > > [1] 16988
> > >
> > > I am doing histogram plot via:
> > > ggplot(a, aes(x=HBA1C, fill=pheno)) + geom_histogram(binwidth=.5,
> > > position="dodge")
> > >
> > > there is 848 who have "case" in pheno column and 892 who have
> > > "control" in pheno column.
> > >
> > > I would like to have on y-axis shown percentage of individuals which
> > > have either "case" or "control" in pheno instead of count.
> > >
> > > Please advise,
> > > Ana
> > __
> > 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 show percentage of individuals for two groups on histogram?

2020-05-21 Thread Jim Lemon
Hi Ana,
My apologies for the pedestrian graphics, but it may help.

# a bit of fake data
aafd<-data.frame(FID=paste0("fam",1000:2739),
 IID=paste0("G",1000,2739),FLASER=rep(1,1740),
 PLASER=c(rep(1,892),rep(2,848)),
 DIABDUR=sample(10:50,1740,TRUE),
 HBAIC=rnorm(1740,mean=7.45,sd=2),ESRD=rep(1,1740),
 pheno=c(rep("control",892),rep("case",848)))
par(mfrow=c(2,1))
casepct<-table(cut(aafd$HBAIC[aafd$pheno=="case"],breaks=0:15))
controlpct<-table(cut(aafd$HBAIC[aafd$pheno=="control"],breaks=0:15))
par(mar=c(0,4,1,2))
barpos=barplot(100*casehist,names.arg=names(casepct),col="orange",
 space=0,ylab="Percentage",xaxt="n",ylim=c(0,25))
text(mean(barpos),23,
 "Cases: n=848, nulls=26, median=7.3, mean=7.45, sd=1.96")
box()
par(mar=c(3,4,0,2))
barplot(100*controlhist,names.arg=names(controlpct),
 space=0,ylab="Percentage",col="orange",ylim=c(0,25))
text(mean(barpos),23,
 "Controls: n=892, nulls=7, median=7.3, mean=7.45, sd=1.12")
box()

Jim

On Fri, May 22, 2020 at 9:08 AM Ana Marija  wrote:
>
> the result would basically look something like this on in attach or
> the overlay of those two plots
>
>
> On Thu, May 21, 2020 at 5:23 PM Ana Marija  
> wrote:
> >
> > Hello,
> >
> > I have a data frame like this:
> > > head(a)
> >  FID   IID FLASER PLASER DIABDUR HBA1C ESRD   pheno
> > 1 fam1000-03 G1000  1  1  38  10.21 control
> > 2 fam1001-03 G1001  1  1  15   7.31 control
> > 3 fam1003-03 G1003  1  2  17   7.01case
> > 4 fam1005-03 G1005  1  1  36   7.71 control
> > 5 fam1009-03 G1009  1  1  23   7.61 control
> > 6 fam1052-03 G1052  1  1  32   7.31 control
> >
> > > dim(a)
> > [1] 16988
> >
> > I am doing histogram plot via:
> > ggplot(a, aes(x=HBA1C, fill=pheno)) + geom_histogram(binwidth=.5,
> > position="dodge")
> >
> > there is 848 who have "case" in pheno column and 892 who have
> > "control" in pheno column.
> >
> > I would like to have on y-axis shown percentage of individuals which
> > have either "case" or "control" in pheno instead of count.
> >
> > Please advise,
> > Ana
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R-es] Tipo de gráfico idóneo

2020-05-21 Thread Carlos Ortega
Hola,

Si quieres resaltar diferencias, que es lo que entendido que buscas, estos
gráficos me parece especialmente interesantes para ello:


   - https://www.r-graph-gallery.com/303-lollipop-plot-with-2-values.html
   -
   
https://cran.r-project.org/web/packages/interactions/vignettes/interactions.html#simple_slopes_analysis_and_johnson-neyman_intervals


Gracias,
Carlos Ortega
www.qualityexcellence.es

El jue., 21 may. 2020 a las 19:15, Manuel Mendoza (<
mmend...@fulbrightmail.org>) escribió:

> Esta vez no es un problema, pero quizás podáis aconsejarme sobre qué
> gráfico elegir, pues hice algunas pruebas y no queda muy bien.
> Quiero comparar 9 rectas (o lo que sea) hechas de tan solo dos puntos.
> Para 9 grupos de especies distintos tengo un dato para 2050 y otro para
> 2070, y pretendo que se aprecie bien la evolución (de tan solo dos fechas)
> de cada uno de los 9 grupos, y las diferencias entre grupos. Podría ser en
> un mismo gráfico o un gráfico para cada grupo, pero que permita visualizar
> las diferencias.
> Gracias, como siempre,
> Manuel
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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


Re: [R] R hangs when attempting open existing *.R file

2020-05-21 Thread Jeff Newmiller
R does not exactly "open R files" the way you phrased it... on most platforms 
you use a text editor for that. R App is a bit of a special case... ergo, you 
should probably be asking on the specialized list.

On May 21, 2020 3:47:18 PM PDT, John Helly  wrote:
>MacOSX R App.  Am I missing something about using that GUI?
>
>J.
>
>On 5/21/20 15:43, Jeff Newmiller wrote:
>> What do you mean by "open an existing R file"... did you try to load
>it with the source function or the MacOSX R App? If the latter you may
>be better off reading the archives of and/or asking in R-sig-mac...
>>
>> On May 21, 2020 3:35:13 PM PDT, John Helly via R-help
> wrote:
>>> Aloha.
>>>
>>> Just installed 'Arbor day' and what was an occasional problem is now
>>> preventing me from loading even a script I was routinely running the
>>> day
>>> before.
>>>
>>> Anyone have any idea what might be wrong now?  I just get a
>beachball
>>> and Force Quit tells me R is not responding.
>>>
>>> Thank you.
>>> J.

-- 
Sent from my phone. Please excuse my brevity.

__
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] R hangs when attempting open existing *.R file

2020-05-21 Thread John Helly via R-help
Ok. Thanks. I will do that.  Sorry for the confusion.
J.

On 5/21/20 15:53, Jeff Newmiller wrote:
> R does not exactly "open R files" the way you phrased it... on most platforms 
> you use a text editor for that. R App is a bit of a special case... ergo, you 
> should probably be asking on the specialized list.
>
> On May 21, 2020 3:47:18 PM PDT, John Helly  wrote:
>> MacOSX R App.  Am I missing something about using that GUI?
>>
>> J.
>>
>> On 5/21/20 15:43, Jeff Newmiller wrote:
>>> What do you mean by "open an existing R file"... did you try to load
>> it with the source function or the MacOSX R App? If the latter you may
>> be better off reading the archives of and/or asking in R-sig-mac...
>>> On May 21, 2020 3:35:13 PM PDT, John Helly via R-help
>>  wrote:
 Aloha.

 Just installed 'Arbor day' and what was an occasional problem is now
 preventing me from loading even a script I was routinely running the
 day
 before.

 Anyone have any idea what might be wrong now?  I just get a
>> beachball
 and Force Quit tells me R is not responding.

 Thank you.
 J.

-- 
John Helly, University of California, San Diego / San Diego Supercomputer 
Center / Scripps Institution of Oceanography / 760 840 8660 mobile / 
http://www.sdsc.edu/~hellyj
ORCID ID: orcid.org/-0002-3779-0603

__
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 show percentage of individuals for two groups on histogram?

2020-05-21 Thread Ana Marija
the result would basically look something like this on in attach or
the overlay of those two plots


On Thu, May 21, 2020 at 5:23 PM Ana Marija  wrote:
>
> Hello,
>
> I have a data frame like this:
> > head(a)
>  FID   IID FLASER PLASER DIABDUR HBA1C ESRD   pheno
> 1 fam1000-03 G1000  1  1  38  10.21 control
> 2 fam1001-03 G1001  1  1  15   7.31 control
> 3 fam1003-03 G1003  1  2  17   7.01case
> 4 fam1005-03 G1005  1  1  36   7.71 control
> 5 fam1009-03 G1009  1  1  23   7.61 control
> 6 fam1052-03 G1052  1  1  32   7.31 control
>
> > dim(a)
> [1] 16988
>
> I am doing histogram plot via:
> ggplot(a, aes(x=HBA1C, fill=pheno)) + geom_histogram(binwidth=.5,
> position="dodge")
>
> there is 848 who have "case" in pheno column and 892 who have
> "control" in pheno column.
>
> I would like to have on y-axis shown percentage of individuals which
> have either "case" or "control" in pheno instead of count.
>
> Please advise,
> Ana
__
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] R hangs when attempting open existing *.R file

2020-05-21 Thread John Helly via R-help
MacOSX R App.  Am I missing something about using that GUI?

J.

On 5/21/20 15:43, Jeff Newmiller wrote:
> What do you mean by "open an existing R file"... did you try to load it with 
> the source function or the MacOSX R App? If the latter you may be better off 
> reading the archives of and/or asking in R-sig-mac...
>
> On May 21, 2020 3:35:13 PM PDT, John Helly via R-help  
> wrote:
>> Aloha.
>>
>> Just installed 'Arbor day' and what was an occasional problem is now
>> preventing me from loading even a script I was routinely running the
>> day
>> before.
>>
>> Anyone have any idea what might be wrong now?  I just get a beachball
>> and Force Quit tells me R is not responding.
>>
>> Thank you.
>> J.

-- 
John Helly, University of California, San Diego / San Diego Supercomputer 
Center / Scripps Institution of Oceanography / 760 840 8660 mobile / 
http://www.sdsc.edu/~hellyj
ORCID ID: orcid.org/-0002-3779-0603

__
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] R hangs when attempting open existing *.R file

2020-05-21 Thread Jeff Newmiller
What do you mean by "open an existing R file"... did you try to load it with 
the source function or the MacOSX R App? If the latter you may be better off 
reading the archives of and/or asking in R-sig-mac...

On May 21, 2020 3:35:13 PM PDT, John Helly via R-help  
wrote:
>Aloha.
>
>Just installed 'Arbor day' and what was an occasional problem is now
>preventing me from loading even a script I was routinely running the
>day
>before.
>
>Anyone have any idea what might be wrong now?  I just get a beachball
>and Force Quit tells me R is not responding.
>
>Thank you.
>J.

-- 
Sent from my phone. Please excuse my brevity.

__
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] R hangs when attempting open existing *.R file

2020-05-21 Thread John Helly via R-help
Aloha.

Just installed 'Arbor day' and what was an occasional problem is now
preventing me from loading even a script I was routinely running the day
before.

Anyone have any idea what might be wrong now?  I just get a beachball
and Force Quit tells me R is not responding.

Thank you.
J.

-- 
John Helly, University of California, San Diego / San Diego Supercomputer 
Center / Scripps Institution of Oceanography / 760 840 8660 mobile / 
http://www.sdsc.edu/~hellyj
ORCID ID: orcid.org/-0002-3779-0603

__
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 show percentage of individuals for two groups on histogram?

2020-05-21 Thread Ana Marija
Hello,

I have a data frame like this:
> head(a)
 FID   IID FLASER PLASER DIABDUR HBA1C ESRD   pheno
1 fam1000-03 G1000  1  1  38  10.21 control
2 fam1001-03 G1001  1  1  15   7.31 control
3 fam1003-03 G1003  1  2  17   7.01case
4 fam1005-03 G1005  1  1  36   7.71 control
5 fam1009-03 G1009  1  1  23   7.61 control
6 fam1052-03 G1052  1  1  32   7.31 control

> dim(a)
[1] 16988

I am doing histogram plot via:
ggplot(a, aes(x=HBA1C, fill=pheno)) + geom_histogram(binwidth=.5,
position="dodge")

there is 848 who have "case" in pheno column and 892 who have
"control" in pheno column.

I would like to have on y-axis shown percentage of individuals which
have either "case" or "control" in pheno instead of count.

Please advise,
Ana

__
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 with Parallel Processing

2020-05-21 Thread Jeff Newmiller
More specifically, read the vignettes. Actually, always start with the package 
vignettes if any are available.

On May 21, 2020 1:51:48 PM PDT, Ista Zahn  wrote:
>Hi Ravi,
>
>Please read the ?future documentation, the answers to all your
>questions are explained there.
>
>Best,
>Ista
>
>On Thu, May 21, 2020 at 3:20 PM Ravi Jeyaraman 
>wrote:
>>
>> Dear Friends,
>>
>>
>>
>> I'm trying to run a bunch of tasks in parallel using 'Future' package
>and
>> for some reason, it's not able to find the data frames that I want it
>to
>> find.  I've created the below sample program to show what I'm doing. 
>Should
>> I be exporting the Global data to each child process?  I am not doing
>that
>> currently because I read somewhere that it's automatically done when
>using
>> the multisession plan.  Any idea what I'm doing wrong?
>>
>>
>>
>> Thanks
>>
>> Ravi
>>
>>
>>
>>
>>
>> if(!require('sqldf')) install.packages('sqldf')
>>
>> if(!require('future')) install.packages('future')
>>
>> if(!require('doFuture')) install.packages('doFuture')
>>
>> if(!require('future.apply')) install.packages('future.apply')
>>
>>
>>
>> library('sqldf')
>>
>> library('future')
>>
>> library("doFuture")
>>
>> library("future.apply")
>>
>>
>>
>> registerDoFuture()
>>
>> plan(multisession, globals = TRUE, workers=5)
>>
>> options(future.globals.maxSize=+Inf)
>>
>>
>>
>> DATA_ASIA <- data.frame(c('NAME1', 'NAME2'))
>>
>> DATA_EUROPE <- data.frame(c('NAME1', 'NAME2', 'NAME3'))
>>
>> DATA_USA <- data.frame(c('NAME1', 'NAME2', 'NAME3', 'NAME4'))
>>
>> DATA_AFRICA <- data.frame(c('NAME1'))
>>
>>
>>
>> LEVEL <- c('ASIA_LEVEL', 'EUROPE_LEVEL', 'USA_LEVEL', 'AFRICA_LEVEL')
>>
>> R_PROG <- c('SELECT COUNT(*) as COUNT FROM DATA_ASIA',
>>
>> 'SELECT COUNT(*) as COUNT FROM DATA_EUROPE',
>>
>> 'SELECT COUNT(*) as COUNT FROM DATA_USA',
>>
>> 'SELECT COUNT(*) as COUNT FROM DATA_AFRICA')
>>
>>
>>
>> RULES_ALL <- data.frame(LEVEL, R_PROG)
>>
>>
>>
>> RULES_ASIA <- subset(RULES_ALL, LEVEL == 'ASIA_LEVEL')
>>
>> RESULT_ASIA <-
>future(data.table::rbindlist(lapply(1:nrow(RULES_ASIA),
>> function(x) sqldf(RULES_ASIA$R_PROG[x])), use.names = TRUE,
>fill=TRUE))
>>
>>
>>
>> RULES_EUROPE <- subset(RULES_ALL, LEVEL == 'EUROPE_LEVEL')
>>
>> RESULT_EUROPE <-
>future(data.table::rbindlist(lapply(1:nrow(RULES_EUROPE),
>> function(x) sqldf(RULES_EUROPE$R_PROG[x])), use.names = TRUE,
>fill=TRUE))
>>
>>
>>
>> RULES_USA <- subset(RULES_ALL, LEVEL == 'USA_LEVEL')
>>
>> RESULT_USA <- future(data.table::rbindlist(lapply(1:nrow(RULES_USA),
>> function(x) sqldf(RULES_USA$R_PROG[x])), use.names = TRUE,
>fill=TRUE))
>>
>>
>>
>> RULES_AFRICA <- subset(RULES_ALL, LEVEL == 'AFRICA_LEVEL')
>>
>> RESULTS_AFRICA <-
>future(data.table::rbindlist(lapply(1:nrow(RULES_AFRICA),
>> function(x) sqldf(RULES_AFRICA$R_PROG[x])), use.names = TRUE,
>fill=TRUE))
>>
>>
>>
>> RESULT_ASIA <- value(RESULT_ASIA)
>>
>> RESULT_EUROPE <- value(RESULT_EUROPE)
>>
>> RESULT_USA <- value(RESULT_USA)
>>
>> RESULTS_AFRICA <- value(RESULTS_AFRICA)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> This email has been checked for viruses by AVG.
>> https://www.avg.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@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.

-- 
Sent from my phone. Please excuse my brevity.

__
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 factor in the ID of the imported subtable to R table?

2020-05-21 Thread David Winsemius



On 5/21/20 9:24 AM, YANJUN CHEN via R-help wrote:

Dear R community,

I am new to R—did some online tutorials and exercises in R playground. I was 
wondering if I could seek guidance on the following matter.

I have a set of 403 .csv files. Each.csv file contains the same layouts and 
distinguished by subject ID and date in the file name. The dataset looks like 
this:

Sub1-20170305.csv
Sub2-20180214.csv
…
Sub403-20191109.csv



Something along the lines of:

?regex ; ?sub

?read.table

?data.frame

?do.call

?rbind

myfiles <- lapply( list.files(your_path) , # each file name will be 
passed to anonymous function


   function(nm) data.frame( subID = sub("-.+", 
"",  nm), # remove chars after "-"


date=sub("^.+-(.{8})[.]csv", "\\1", nm), #extract date as capture class

    #assuming all files have 
same number of columns with no headers


    read.table( 
paste0(your_path, nm) )


big_file <- do.call(rbind, myfiles)



I will use rbind function to combine 403 csv files in a single file (myFile). I 
will create two new variables (use mutate function) in myFile (subject ID and 
date). Is there a way to subtract subject ID (shown as “Sub1, 2,,,403”) and 
date from the name of the csv file and then place them in “subject ID” and 
“date” in myFile?

Any info on the issue itself or where to look for will be appreciated.



If you search StackOverflow or Rseek with topic terms " stacking 
multiple data files" you should find many worked examples.



Thanks,

CJ






[[alternative HTML version deleted]]



You should now read the Posting Guide which will explain why you should 
NOT post in HTML.



Best;

David.


__
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] Help with Parallel Processing

2020-05-21 Thread Ista Zahn
Hi Ravi,

Please read the ?future documentation, the answers to all your
questions are explained there.

Best,
Ista

On Thu, May 21, 2020 at 3:20 PM Ravi Jeyaraman  wrote:
>
> Dear Friends,
>
>
>
> I'm trying to run a bunch of tasks in parallel using 'Future' package and
> for some reason, it's not able to find the data frames that I want it to
> find.  I've created the below sample program to show what I'm doing.  Should
> I be exporting the Global data to each child process?  I am not doing that
> currently because I read somewhere that it's automatically done when using
> the multisession plan.  Any idea what I'm doing wrong?
>
>
>
> Thanks
>
> Ravi
>
>
>
>
>
> if(!require('sqldf')) install.packages('sqldf')
>
> if(!require('future')) install.packages('future')
>
> if(!require('doFuture')) install.packages('doFuture')
>
> if(!require('future.apply')) install.packages('future.apply')
>
>
>
> library('sqldf')
>
> library('future')
>
> library("doFuture")
>
> library("future.apply")
>
>
>
> registerDoFuture()
>
> plan(multisession, globals = TRUE, workers=5)
>
> options(future.globals.maxSize=+Inf)
>
>
>
> DATA_ASIA <- data.frame(c('NAME1', 'NAME2'))
>
> DATA_EUROPE <- data.frame(c('NAME1', 'NAME2', 'NAME3'))
>
> DATA_USA <- data.frame(c('NAME1', 'NAME2', 'NAME3', 'NAME4'))
>
> DATA_AFRICA <- data.frame(c('NAME1'))
>
>
>
> LEVEL <- c('ASIA_LEVEL', 'EUROPE_LEVEL', 'USA_LEVEL', 'AFRICA_LEVEL')
>
> R_PROG <- c('SELECT COUNT(*) as COUNT FROM DATA_ASIA',
>
> 'SELECT COUNT(*) as COUNT FROM DATA_EUROPE',
>
> 'SELECT COUNT(*) as COUNT FROM DATA_USA',
>
> 'SELECT COUNT(*) as COUNT FROM DATA_AFRICA')
>
>
>
> RULES_ALL <- data.frame(LEVEL, R_PROG)
>
>
>
> RULES_ASIA <- subset(RULES_ALL, LEVEL == 'ASIA_LEVEL')
>
> RESULT_ASIA <- future(data.table::rbindlist(lapply(1:nrow(RULES_ASIA),
> function(x) sqldf(RULES_ASIA$R_PROG[x])), use.names = TRUE, fill=TRUE))
>
>
>
> RULES_EUROPE <- subset(RULES_ALL, LEVEL == 'EUROPE_LEVEL')
>
> RESULT_EUROPE <- future(data.table::rbindlist(lapply(1:nrow(RULES_EUROPE),
> function(x) sqldf(RULES_EUROPE$R_PROG[x])), use.names = TRUE, fill=TRUE))
>
>
>
> RULES_USA <- subset(RULES_ALL, LEVEL == 'USA_LEVEL')
>
> RESULT_USA <- future(data.table::rbindlist(lapply(1:nrow(RULES_USA),
> function(x) sqldf(RULES_USA$R_PROG[x])), use.names = TRUE, fill=TRUE))
>
>
>
> RULES_AFRICA <- subset(RULES_ALL, LEVEL == 'AFRICA_LEVEL')
>
> RESULTS_AFRICA <- future(data.table::rbindlist(lapply(1:nrow(RULES_AFRICA),
> function(x) sqldf(RULES_AFRICA$R_PROG[x])), use.names = TRUE, fill=TRUE))
>
>
>
> RESULT_ASIA <- value(RESULT_ASIA)
>
> RESULT_EUROPE <- value(RESULT_EUROPE)
>
> RESULT_USA <- value(RESULT_USA)
>
> RESULTS_AFRICA <- value(RESULTS_AFRICA)
>
>
>
>
>
>
>
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.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@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 with checks on R/4.0.0

2020-05-21 Thread Jeff Newmiller
Do read the Posting Guide... you are on the wrong mailing list for this 
question.

On May 20, 2020 6:46:01 PM PDT, Simon Michnowicz via R-help 
 wrote:
>Dear R Group,
>I can build a simple R/4.0.0 OK using   gcc/8.1.0, but when I tried to
>link
>it with  the Intel MKL,  'make check' produced this error
>
>tail tests/reg-tests-1d.Rout.fail
>
>> (m <- cbind(0, c(NA, 0), 0:-1))
> [,1] [,2] [,3]
>[1,]0   NA0
>[2,]00   -1
>> nTypes <- eval(formals(base::norm)$type) # "O" "I" "F" "M" "2"
>> stopifnot(is.na( print(vapply(nTypes, norm, 0., x = m)) )) # print():
>show NA *or* NaN
> O  I  F  M  2
>NA NA  1 NA NA
>Error: is.na(print(vapply(nTypes, norm, 0, x = m))) are not all TRUE
>Execution halted
>
>Is this a significant error?
>There may be differences in how NaN are treated between GNU and MKL
>that
>caused this.
>
>regards
>
>
>*---Simon Michnowicz *
>Senior Application Specialist,  High-Performance Computing
>
>*Research Support Services - eSolutions*
>*Monash eResearch Centre*
>Monash University
>15 Innovation Walk, Building 75, Clayton Campus
>Wellington Road, VIC 3800
>Australia
>
>T:  +61 3 9902 0794
>M: +61 3 0418 302 046
>E: simon.michnow...@monash.edu
>monash.edu
>
>   [[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.

-- 
Sent from my phone. Please excuse my brevity.

__
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 factor in the ID of the imported subtable to R table?

2020-05-21 Thread YANJUN CHEN via R-help
Dear R community,

I am new to R—did some online tutorials and exercises in R playground. I was 
wondering if I could seek guidance on the following matter.

I have a set of 403 .csv files. Each.csv file contains the same layouts and 
distinguished by subject ID and date in the file name. The dataset looks like 
this:

Sub1-20170305.csv
Sub2-20180214.csv
…
Sub403-20191109.csv

I will use rbind function to combine 403 csv files in a single file (myFile). I 
will create two new variables (use mutate function) in myFile (subject ID and 
date). Is there a way to subtract subject ID (shown as “Sub1, 2,,,403”) and 
date from the name of the csv file and then place them in “subject ID” and 
“date” in myFile?

Any info on the issue itself or where to look for will be appreciated.

Thanks,

CJ






[[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 with checks on R/4.0.0

2020-05-21 Thread Simon Michnowicz via R-help
Dear R Group,
I can build a simple R/4.0.0 OK using   gcc/8.1.0, but when I tried to link
it with  the Intel MKL,  'make check' produced this error

tail tests/reg-tests-1d.Rout.fail

> (m <- cbind(0, c(NA, 0), 0:-1))
 [,1] [,2] [,3]
[1,]0   NA0
[2,]00   -1
> nTypes <- eval(formals(base::norm)$type) # "O" "I" "F" "M" "2"
> stopifnot(is.na( print(vapply(nTypes, norm, 0., x = m)) )) # print():
show NA *or* NaN
 O  I  F  M  2
NA NA  1 NA NA
Error: is.na(print(vapply(nTypes, norm, 0, x = m))) are not all TRUE
Execution halted

Is this a significant error?
 There may be differences in how NaN are treated between GNU and MKL that
caused this.

regards


*---Simon Michnowicz *
Senior Application Specialist,  High-Performance Computing

*Research Support Services - eSolutions*
*Monash eResearch Centre*
Monash University
15 Innovation Walk, Building 75, Clayton Campus
Wellington Road, VIC 3800
Australia

T:  +61 3 9902 0794
M: +61 3 0418 302 046
E: simon.michnow...@monash.edu
monash.edu

[[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 Parallel Processing

2020-05-21 Thread Ravi Jeyaraman
Dear Friends,

 

I'm trying to run a bunch of tasks in parallel using 'Future' package and
for some reason, it's not able to find the data frames that I want it to
find.  I've created the below sample program to show what I'm doing.  Should
I be exporting the Global data to each child process?  I am not doing that
currently because I read somewhere that it's automatically done when using
the multisession plan.  Any idea what I'm doing wrong?  

 

Thanks

Ravi

 

 

if(!require('sqldf')) install.packages('sqldf')

if(!require('future')) install.packages('future')

if(!require('doFuture')) install.packages('doFuture')

if(!require('future.apply')) install.packages('future.apply')

 

library('sqldf')

library('future')

library("doFuture")

library("future.apply")

 

registerDoFuture()

plan(multisession, globals = TRUE, workers=5)

options(future.globals.maxSize=+Inf)

 

DATA_ASIA <- data.frame(c('NAME1', 'NAME2'))

DATA_EUROPE <- data.frame(c('NAME1', 'NAME2', 'NAME3'))

DATA_USA <- data.frame(c('NAME1', 'NAME2', 'NAME3', 'NAME4'))

DATA_AFRICA <- data.frame(c('NAME1'))

 

LEVEL <- c('ASIA_LEVEL', 'EUROPE_LEVEL', 'USA_LEVEL', 'AFRICA_LEVEL')

R_PROG <- c('SELECT COUNT(*) as COUNT FROM DATA_ASIA', 

'SELECT COUNT(*) as COUNT FROM DATA_EUROPE', 

'SELECT COUNT(*) as COUNT FROM DATA_USA', 

'SELECT COUNT(*) as COUNT FROM DATA_AFRICA')

 

RULES_ALL <- data.frame(LEVEL, R_PROG)

 

RULES_ASIA <- subset(RULES_ALL, LEVEL == 'ASIA_LEVEL')

RESULT_ASIA <- future(data.table::rbindlist(lapply(1:nrow(RULES_ASIA),
function(x) sqldf(RULES_ASIA$R_PROG[x])), use.names = TRUE, fill=TRUE))

 

RULES_EUROPE <- subset(RULES_ALL, LEVEL == 'EUROPE_LEVEL')

RESULT_EUROPE <- future(data.table::rbindlist(lapply(1:nrow(RULES_EUROPE),
function(x) sqldf(RULES_EUROPE$R_PROG[x])), use.names = TRUE, fill=TRUE))

 

RULES_USA <- subset(RULES_ALL, LEVEL == 'USA_LEVEL')

RESULT_USA <- future(data.table::rbindlist(lapply(1:nrow(RULES_USA),
function(x) sqldf(RULES_USA$R_PROG[x])), use.names = TRUE, fill=TRUE))

 

RULES_AFRICA <- subset(RULES_ALL, LEVEL == 'AFRICA_LEVEL')

RESULTS_AFRICA <- future(data.table::rbindlist(lapply(1:nrow(RULES_AFRICA),
function(x) sqldf(RULES_AFRICA$R_PROG[x])), use.names = TRUE, fill=TRUE))

 

RESULT_ASIA <- value(RESULT_ASIA)

RESULT_EUROPE <- value(RESULT_EUROPE)

RESULT_USA <- value(RESULT_USA)

RESULTS_AFRICA <- value(RESULTS_AFRICA)

 

 

 



-- 
This email has been checked for viruses by AVG.
https://www.avg.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.


Re: [R] Attribute Combinations

2020-05-21 Thread Ista Zahn
Another one just for fun:

prop.table(table(interaction(x)))

or possibly

prop.table(table(droplevels(interaction(x

Best,
Ista


On Thu, May 21, 2020 at 1:22 PM Jeff Reichman  wrote:
>
> R-help forum
>
>
>
> Looking for a function or some guidance for obtaining the percentage of
> attribute combinations, for example
>
>
>
> V1   V2   V3
>
> A A B
>
> A B C
>
> A A D
>
> A A B
>
> A A B
>
> A B C
>
> A C B
>
> A C B
>
> A B C
>
> A C C
>
>
>
> Results
>
> A,A,B 0.30
>
> A,B,C 0.30
>
> A,A,D0.10
>
> A,C,B 0.20 etc
>
>
>
> Sincerely
>
>
>
> Jeff Reichman
>
> (314) 457-1966
>
>
>
>
> [[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] Attribute Combinations

2020-05-21 Thread John Kane
One possible way
library(tidyr)

dat1  <-  structure(list(V1 = c("A", "A", "A", "A", "A", "A", "A", "A",
"A", "A"), V2 = c("A", "B", "A", "A", "A", "B", "C", "C", "B",
"C"), V3 = c("B", "C", "D", "B", "B", "C", "B", "B", "C", "C"
)), class = "data.frame", row.names = c(NA, -10L))

dat2  <-  unite(dat1, att, V1, V2, V3, sep = ",")

prop.table(table(dat2$att))

A,A,B A,A,D A,B,C A,C,B A,C,C
  0.3   0.1   0.3   0.2   0.1

On Thu, 21 May 2020 at 13:22, Jeff Reichman  wrote:

> R-help forum
>
>
>
> Looking for a function or some guidance for obtaining the percentage of
> attribute combinations, for example
>
>
>
> V1   V2   V3
>
> A A B
>
> A B C
>
> A A D
>
> A A B
>
> A A B
>
> A B C
>
> A C B
>
> A C B
>
> A B C
>
> A C C
>
>
>
> Results
>
> A,A,B 0.30
>
> A,B,C 0.30
>
> A,A,D0.10
>
> A,C,B 0.20 etc
>
>
>
> Sincerely
>
>
>
> Jeff Reichman
>
> (314) 457-1966
>
>
>
>
> [[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.
>


-- 
John Kane
Kingston ON Canada

[[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] [EXTERNAL] Attribute Combinations

2020-05-21 Thread Dalthorp, Daniel via R-help
# assuming your data frame is named "x", you can get the counts of each combo:

table(do.call(paste0, x)) 

# and to get the proportions:

table(do.call(paste0, x))/nrow(x)


-Original Message-
From: R-help  On Behalf Of Jeff Reichman
Sent: Thursday, May 21, 2020 10:22 AM
To: R-help@r-project.org
Subject: [EXTERNAL] [R] Attribute Combinations

R-help forum

 

Looking for a function or some guidance for obtaining the percentage of 
attribute combinations, for example

 

V1   V2   V3

A A B

A B C

A A D 

A A B

A A B

A B C

A C B 

A C B

A B C

A C C

 

Results

A,A,B 0.30

A,B,C 0.30

A,A,D0.10

A,C,B 0.20 etc

 

Sincerely

 

Jeff Reichman

(314) 457-1966

 


[[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] Attribute Combinations

2020-05-21 Thread Jeff Reichman
R-help forum

 

Looking for a function or some guidance for obtaining the percentage of
attribute combinations, for example

 

V1   V2   V3

A A B

A B C

A A D 

A A B

A A B

A B C

A C B 

A C B

A B C

A C C

 

Results

A,A,B 0.30

A,B,C 0.30

A,A,D0.10

A,C,B 0.20 etc

 

Sincerely

 

Jeff Reichman

(314) 457-1966

 


[[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] Tipo de gráfico idóneo

2020-05-21 Thread Manuel Mendoza
Esta vez no es un problema, pero quizás podáis aconsejarme sobre qué
gráfico elegir, pues hice algunas pruebas y no queda muy bien.
Quiero comparar 9 rectas (o lo que sea) hechas de tan solo dos puntos.
Para 9 grupos de especies distintos tengo un dato para 2050 y otro para
2070, y pretendo que se aprecie bien la evolución (de tan solo dos fechas)
de cada uno de los 9 grupos, y las diferencias entre grupos. Podría ser en
un mismo gráfico o un gráfico para cada grupo, pero que permita visualizar
las diferencias.
Gracias, como siempre,
Manuel

[[alternative HTML version deleted]]

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


[R] [R-pkgs] statespacer: State Space Modelling in 'R'

2020-05-21 Thread Dylan Beijers
Dear All,

The statespacer package is now on CRAN (
https://cran.r-project.org/package=statespacer). This package provides
functionality for modelling and forecasting time series using state space
techniques. For more info, please see
https://dylanb95.github.io/statespacer/

Best,
Dylan Beijers

[[alternative HTML version deleted]]

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

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


Re: [R] survival anaylsis with tabulated data

2020-05-21 Thread John Kane
 http://adv-r.had.co.nz/Reproducibility.html

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example



On Thu, 21 May 2020 at 09:16, PIKAL Petr  wrote:

> Hallo
>
> I am not private consultant so please keep your messages on help list.
>
> From help page I understand that the function survtab_ag needs to have
> **specially prepared** data as input. We could only guess if your data are
> in correct format and most probably they are not.
>
> Without knowing details I wonder if anybody is able to help you.
>
> Cheers
> Petr
>
> From: Ergin Artun 
> Sent: Thursday, May 21, 2020 3:08 PM
> To: PIKAL Petr 
> Subject: Re: [R] survival anaylsis with tabulated data
>
> Dear Pical,
> I'm also not  an expert and had a typo error while translating colum names
> at code.
>
> At my data set time(as day), at.risk(people), from0to1(as people with
> event), from0to0(censored values for the function) are integers, Country,
> and the other two columns are charecter strings.
>
> Best regards...
> Tanju
>
> PIKAL Petr , 21 May 2020 Per, 12:53
> tarihinde şunu yazdı:
> Hi
>
> I am not an expert and cannot give you canned solution, but here are few
> comments:
>
> Without knowing data structure it is hard to decipher where is the problem.
> So posting result of
> str(yourata) or at least part of it hardly anybody could help.
> Cuntry is typo?
> The error could by result of typo or not properly structured data.
>
> This is plain text mail list, please do not use HTML formating.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help  On Behalf Of Ergin
> Artun
> > Sent: Wednesday, May 20, 2020 2:01 PM
> > To: mailto:r-help@r-project.org
> > Subject: [R] survival anaylsis with tabulated data
> >
> >   Dear R Friends,
> >
> > I'm a medical doctor with some knowledge about statistic and programming.
> > I want to analysis and compare data of different countries with survival
> or
> > popEpi tools in R.
> > I couldn't able to make tables with one row for every people of countries
> > without illness. I can made a data table look like as:
> >
> > time
> > country at.risk from0to1 sk zf from0to0
> > 1 AFG 40363639 1 K F 0
> >
> > I try to prepare for analysis with survtab_ag function of Epi package.
> When
> > I run
> > st <- survtab_ag(time ~ cuntry, data = , surv.type =
> > "surv.obs",surv.breaks=list($time),
> > +  surv.method = "lifetable",
> > +  d = "from0to1")
> > I see just the error message:
> > Error in http://sort.int(x, na.last = na.last, decreasing = decreasing,
> ...) :
> >   'x' must be atomic
> >
> > Can any body help me for preparing this kind tabulated data without
> surv()
> > to other survival functions?
> > Best regards from Turkey
> >
> > Tanju Aktug
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > mailto: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.
>


-- 
John Kane
Kingston ON Canada

[[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: [ESS] ess-eval-region Does Not Echo Highlighted Code Into the R Buffer?

2020-05-21 Thread Marc Schwartz via ESS-help
Hi Martin,

Thanks for your additional comments.

Perhaps my use case is in the minority, but after almost 20 years of using R, 
primarily with Emacs/ESS on Windows, Linux and macOS over that time frame, I 
never found the prior default behavior to be an issue for me. Thus, I had no 
motivation to modify it.

That being said, I fully understand the differing views that have led to the 
recent change in the default.

Regards,

Marc


> On May 21, 2020, at 9:41 AM, Martin Maechler  
> wrote:
> 
> I've also had 'nowait  as my personal default for many years.I
> find it also more appropriate when showing ESS to others, e.g. when
> teaching etc.
> 
> Very importantly in practice:  Keep in mind that  prefixing i.e.   C-u
> <...>  switches to visible (momentarily)  which is also handy when
> demo-ing, teaching, ...
> 
> Martin
> 
> On Wed, May 20, 2020 at 2:01 PM Marc Schwartz via ESS-help
>  wrote:
>> 
>> Hi Alex,
>> 
>> Thanks for the clarification. Given that information, I found the related 
>> issue report on Github:
>> 
>>  https://github.com/emacs-ess/ESS/issues/998
>> 
>> reviewed the discussion there and ultimately, found the related commit.
>> 
>> I have modified the value to 'nowait for now, which seems to be a compromise 
>> of sorts, given the issues raised.
>> 
>> Thanks,
>> 
>> Marc
>> 
>> 
>>> On May 19, 2020, at 6:05 PM, Alex Branham  wrote:
>>> 
>>> The default value of ess-eval-visibly recently changed. You probably want 
>>> to customize it to t or nowait.
>>> 
>>> Alex
>>> 
>>> On Tue, May 19, 2020, 5:08 PM Marc Schwartz via ESS-help 
>>>  wrote:
>>> Hi,
>>> 
>>> A clarification, that when I do run the command, on a *single* line in the 
>>> R buffer, I am getting '>' characters for each line of R code in the region 
>>> passed, and I get '+' characters if there is a multiline region of code 
>>> passed.
>>> 
>>> Thus, I might see the following single lines of output in the R buffer, as 
>>> examples:
>>> 
>>> 
>>> 
>>> or
>>> 
>>> +>>
>>> 
>>> after the command is run on a region of R code.
>>> 
>>> Regards,
>>> 
>>> Marc
>>> 
>>> 
 On May 19, 2020, at 4:51 PM, Marc Schwartz  wrote:
 
 Hi All,
 
 I just updated my ESS/Polymode installation today via melpa, and unless I 
 am missing something, I noticed that the use of ess-eval-region via "C-c 
 C-r" does not seem to echo the highlighted R code region into the R 
 buffer, which it had been doing until now.
 
 The code does execute, confirmed when I check for the resultant object.
 
 Am I missing new behavior, or perhaps a setting that changed someplace, or 
 that I introduced a conflict with the updates today?
 
 Thanks,
 
 Marc Schwartz
 
>>> 
>>> __
>>> ESS-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/ess-help
>> 
>> __
>> ESS-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help
> 
> 
> 
> -- 
> Martin   https://stat.ethz.ch/~maechler
> Seminar für Statistik, ETH Zürich  HG G 16  Rämistrasse 101
> CH-8092 Zurich, SWITZERLAND
> phone: +41-44-632-3408   fax: ...-1228  <><

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] ess-eval-region Does Not Echo Highlighted Code Into the R Buffer?

2020-05-21 Thread Martin Maechler via ESS-help
I've also had 'nowait  as my personal default for many years.I
find it also more appropriate when showing ESS to others, e.g. when
teaching etc.

Very importantly in practice:  Keep in mind that  prefixing i.e.   C-u
<...>  switches to visible (momentarily)  which is also handy when
demo-ing, teaching, ...

Martin

On Wed, May 20, 2020 at 2:01 PM Marc Schwartz via ESS-help
 wrote:
>
> Hi Alex,
>
> Thanks for the clarification. Given that information, I found the related 
> issue report on Github:
>
>   https://github.com/emacs-ess/ESS/issues/998
>
> reviewed the discussion there and ultimately, found the related commit.
>
> I have modified the value to 'nowait for now, which seems to be a compromise 
> of sorts, given the issues raised.
>
> Thanks,
>
> Marc
>
>
> > On May 19, 2020, at 6:05 PM, Alex Branham  wrote:
> >
> > The default value of ess-eval-visibly recently changed. You probably want 
> > to customize it to t or nowait.
> >
> > Alex
> >
> > On Tue, May 19, 2020, 5:08 PM Marc Schwartz via ESS-help 
> >  wrote:
> > Hi,
> >
> > A clarification, that when I do run the command, on a *single* line in the 
> > R buffer, I am getting '>' characters for each line of R code in the region 
> > passed, and I get '+' characters if there is a multiline region of code 
> > passed.
> >
> > Thus, I might see the following single lines of output in the R buffer, as 
> > examples:
> >
> > 
> >
> > or
> >
> > +>>
> >
> > after the command is run on a region of R code.
> >
> > Regards,
> >
> > Marc
> >
> >
> > > On May 19, 2020, at 4:51 PM, Marc Schwartz  wrote:
> > >
> > > Hi All,
> > >
> > > I just updated my ESS/Polymode installation today via melpa, and unless I 
> > > am missing something, I noticed that the use of ess-eval-region via "C-c 
> > > C-r" does not seem to echo the highlighted R code region into the R 
> > > buffer, which it had been doing until now.
> > >
> > > The code does execute, confirmed when I check for the resultant object.
> > >
> > > Am I missing new behavior, or perhaps a setting that changed someplace, 
> > > or that I introduced a conflict with the updates today?
> > >
> > > Thanks,
> > >
> > > Marc Schwartz
> > >
> >
> > __
> > ESS-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/ess-help
>
> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



-- 
Martin   https://stat.ethz.ch/~maechler
Seminar für Statistik, ETH Zürich  HG G 16  Rämistrasse 101
CH-8092 Zurich, SWITZERLAND
phone: +41-44-632-3408   fax: ...-1228  <><

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] survival anaylsis with tabulated data

2020-05-21 Thread PIKAL Petr
Hallo

I am not private consultant so please keep your messages on help list.

>From help page I understand that the function survtab_ag needs to have 
>**specially prepared** data as input. We could only guess if your data are in 
>correct format and most probably they are not.

Without knowing details I wonder if anybody is able to help you.

Cheers
Petr

From: Ergin Artun  
Sent: Thursday, May 21, 2020 3:08 PM
To: PIKAL Petr 
Subject: Re: [R] survival anaylsis with tabulated data

Dear Pical,
I'm also not  an expert and had a typo error while translating colum names at 
code.

At my data set time(as day), at.risk(people), from0to1(as people with event), 
from0to0(censored values for the function) are integers, Country, and the other 
two columns are charecter strings.

Best regards...
Tanju   

PIKAL Petr , 21 May 2020 Per, 12:53 tarihinde 
şunu yazdı:
Hi

I am not an expert and cannot give you canned solution, but here are few
comments:

Without knowing data structure it is hard to decipher where is the problem.
So posting result of 
str(yourata) or at least part of it hardly anybody could help.
Cuntry is typo?
The error could by result of typo or not properly structured data.

This is plain text mail list, please do not use HTML formating.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Ergin Artun
> Sent: Wednesday, May 20, 2020 2:01 PM
> To: mailto:r-help@r-project.org
> Subject: [R] survival anaylsis with tabulated data
> 
>   Dear R Friends,
> 
> I'm a medical doctor with some knowledge about statistic and programming.
> I want to analysis and compare data of different countries with survival
or
> popEpi tools in R.
> I couldn't able to make tables with one row for every people of countries
> without illness. I can made a data table look like as:
> 
> time
> country at.risk from0to1 sk zf from0to0
> 1 AFG 40363639 1 K F 0
> 
> I try to prepare for analysis with survtab_ag function of Epi package.
When
> I run
> st <- survtab_ag(time ~ cuntry, data = , surv.type =
> "surv.obs",surv.breaks=list($time),
> +  surv.method = "lifetable",
> +  d = "from0to1")
> I see just the error message:
> Error in http://sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
>   'x' must be atomic
> 
> Can any body help me for preparing this kind tabulated data without surv()
> to other survival functions?
> Best regards from Turkey
> 
> Tanju Aktug
> 
>   [[alternative HTML version deleted]]
> 
> __
> mailto: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] survival anaylsis with tabulated data

2020-05-21 Thread PIKAL Petr
Hi

I am not an expert and cannot give you canned solution, but here are few
comments:

Without knowing data structure it is hard to decipher where is the problem.
So posting result of 
str(yourata) or at least part of it hardly anybody could help.
Cuntry is typo?
The error could by result of typo or not properly structured data.

This is plain text mail list, please do not use HTML formating.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Ergin Artun
> Sent: Wednesday, May 20, 2020 2:01 PM
> To: r-help@r-project.org
> Subject: [R] survival anaylsis with tabulated data
> 
>   Dear R Friends,
> 
> I'm a medical doctor with some knowledge about statistic and programming.
> I want to analysis and compare data of different countries with survival
or
> popEpi tools in R.
> I couldn't able to make tables with one row for every people of countries
> without illness. I can made a data table look like as:
> 
> time
> country at.risk from0to1 sk zf from0to0
> 1 AFG 40363639 1 K F 0
> 
> I try to prepare for analysis with survtab_ag function of Epi package.
When
> I run
> st <- survtab_ag(time ~ cuntry, data = , surv.type =
> "surv.obs",surv.breaks=list($time),
> +  surv.method = "lifetable",
> +  d = "from0to1")
> I see just the error message:
> Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
>   'x' must be atomic
> 
> Can any body help me for preparing this kind tabulated data without surv()
> to other survival functions?
> Best regards from Turkey
> 
> Tanju Aktug
> 
>   [[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.