[R] Plotting factors in graph panel

PIKAL Petr petr@p|k@| @end|ng |rom prechez@@cz
Wed Jun 28 10:43:36 CEST 2023


Hi

You probably can use any package including base R for such plots.

1. Posting in HTML scrambles your date so they are barely readable.
2. Use dput(head(yourdata, 20)) and copy the output to your mail to show how
your data look like. Although it seems to be not readable, R will consumes
it freely.
3. If I understand correctly you should have an Income column, Percentage
column and Category column. If this is the case

ggplot(yourdata, aes(x=Income, y=Percentage)) + geom_line() +
facet_grid(~Category) 

should give you what you want. But without data it is hard to say.

Cheers
Petr

> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of Anupam Tyagi
> Sent: Wednesday, June 28, 2023 10:34 AM
> To: R-help using r-project.org
> Subject: [R] Plotting factors in graph panel
> 
> Hello,
> 
> I want to plot the following kind of data (percentage of respondents from
a
> survey) that varies by Income into many small *line* graphs in a panel of
> graphs. I want to omit "No Answer" categories. I want to see how each one
of
> the categories (percentages), "None", " Equity", etc. varies by Income.
> How can I do this? How to organize the data well and how to plot? I
thought
> Lattice may be a good package to plot this, but I don't know for sure. I
prefer
> to do this in Base-R if possible, but I am open to ggplot. Any ideas will
be
> helpful.
> 
> Income
> $10 $25 $40 $75 > $75 No Answer
> MF 1 2 3 4 5 9
> None 1 3.05 2.29 2.24 1.71 1.30 2.83
> Equity 2 29.76 28.79 29.51 28.90 31.67 36.77 Debt 3 31.18 32.64 34.31
35.65
> 37.59 33.15 Hybrid 4 36.00 36.27 33.94 33.74 29.44 27.25 Bank AC None 1
> 46.54 54.01 59.1 62.17 67.67 60.87 Current 2 24.75 24.4 25 24.61 24.02
21.09
> Savings 3 25.4 18.7 29 11.48 7.103 13.46 No Answer 9 3.307 2.891 13.4
1.746
> 1.208 4.577
> 
> Thanks.
> --
> Anupam.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using 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.


More information about the R-help mailing list