# [R] GGPlot plot

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Thu Jul 19 01:10:38 CEST 2018

```Hi again,
Sorry, forgot this line:

fpdf\$PASPpos<-fpdf\$PASP > 0

just after reading in the data frame.

Jim

On Thu, Jul 19, 2018 at 9:04 AM, Jim Lemon <drjimlemon using gmail.com> wrote:
> Hi Francesca,
> This looks like a fairly simple task. Try this:
>
>  0          0
>  4          1
>  0          0
>  8          0
>  4          0
>  0          1
>  0          1",
> # get the number of positive PASP results by group
> ppos<-by(fpdf\$SUBJC,fpdf\$PASPpos,sum)
> # get the number of subjects per group
> spg<-c(sum(fpdf\$SUBJC==0),sum(fpdf\$SUBJC==1))
> barplot(ppos/spg,names.arg=c(0,1),xlab="Group",
>  ylab="Proportion PASP > 0",main="Proportion of PASP positive by group")
>
> Jim
>
> On Thu, Jul 19, 2018 at 2:47 AM, Francesca <francesca.pancotto using gmail.com> wrote:
>> Dear R help,
>>
>> I am new to ggplot so I apologize if my question is a bit obvious.
>>
>> I would like to create a plot where a compare the fraction of the values of a variable called PASP out of the number of subjects, for two groups of subject codified with a dummy variable called SUBJC.
>>
>> The variable PASP is discrete and only takes values 0,4,8..
>>
>> My data are as following:
>>
>>
>>
>> PASP   SUBJC
>>
>>
>>
>> 0          0
>>
>> 4          1
>>
>> 0          0
>>
>> 8          0
>>
>> 4          0
>>
>> 0          1
>>
>> 0          1
>>
>> .           .
>>
>> .           .
>>
>> .           .
>>
>>
>>
>>
>> I would like to calculate the fraction of positive levels of PASP out of the total number of observations, divided per values of SUBJ=0 and 1. I am new to the use of GGPlot and I do not know how to organize the data and what to use to summarize these data as to obtain a picture as follows:
>>
>>
>>
>>
>>
>> I hope my request is clear. Thanks for any help you can provide.
>>
>> Francesca
>>
>>
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help