Re: [R] Plotting factors in graph panel

2023-06-29 Thread Jim Lemon
Okay. Here is a modification that does four single line plots.

at_df<-read.table(text=
 "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None Bank_Current
Bank_Savings Bank_NA
 $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
 $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
 $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
 $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
 >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208
 No_Answer 9 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
 header=TRUE,stringsAsFactors=FALSE)
at_df<-at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
png("Income_pcts.png",height=700)
par(mfrow=c(4,1))
plot(at_df[,"Bank_Current"],
 type="l",lwd=3,main="Bsnk_Current",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
plot(at_df[,"Bank_Savings"],
 type="l",lwd=3,main="Bank_Sasvings",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
plot(at_df[,"MF_Equity"],
 type="l",lwd=3,main="MF_Equity",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
plot(at_df[,"MF_Debt"],
 type="l",lwd=3,main="MF_Debt",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
dev.off()

Jim

On Thu, Jun 29, 2023 at 1:49 PM Anupam Tyagi  wrote:
>
> Thanks, Pikal and Jim. Yes, it has been a long time Jim. I hope you have
> been well.
>
> Pikal, thanks. Your solution may be close to what I want. I did not know
> that I was posting in HTML. I just copied the data from Excel and posted in
> the email in Gmail. The data is still in Excel, because I have not yet
> figured out what is a good way to organize it in R. I am posting it again
> below as text. These are rows in Excel: 1,2,3,5,9 after MF are income
> categories and No Answer category (9). Down the second column are
> categories of MF and Bank AC. Rest of the columns are percentages.
>
> Jim, thanks for the graph. I am looking to plot only one line (category)
> each in many small plots on the same page. I don't want to compare
> different categories on the same graph as you do, but see how each category
> varies by income, one category in each graph. Like Excel does with
> Sparklines (Top menu: Insert, Sparklines, Lines). I have many categories
> for many variables. I am only showing two MF and Bank AC.
>
> 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
>
>
> On Wed, 28 Jun 2023 at 17:30, Jim Lemon  wrote:
>
> > Hi Anupam,
> > Haven't heard from you in a long time. Perhaps you want something like
> > this:
> >
> > at_df<-read.table(text=
> >  "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None Bank_Current
> > Bank_Savings Bank_NA
> >  $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
> >  $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
> >  $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
> >  $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
> >  >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208
> >  No_Answer 9 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
> >  header=TRUE,stringsAsFactors=FALSE)
> > at_df<-at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
> > png("MF_Bank.png",height=600)
> > par(mfrow=c(2,1))
> > matplot(at_df[,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid")],
> >  type="l",col=1:4,lty=1:4,lwd=3,
> >  main="Percentages by Income and MF type",
> >  xlab="Income",ylab="Percentage of group",xaxt="n")
> > axis(1,at=1:5,labels=at_df$Income)
> > legend(3,24,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid"),
> >  lty=1:4,lwd=3,col=1:4)
> > matplot(at_df[,c("Bank_None","Bank_Current","Bank_Savings")],
> >  type="l",col=1:3,lty=1:4,lwd=3,
> >  main="Percentages by Income and Bank type",
> >  xlab="Income",ylab="Percentage of group",xaxt="n")
> > axis(1,at=1:5,labels=at_df$Income)
> > legend(3,54,c("Bank_None","Bank_Current","Bank_Savings"),
> >  lty=1:4,lwd=3,col=1:3)
> > dev.off()
> >
> > Jim
> >
> > On Wed, Jun 28, 2023 at 6:33 PM Anupam Tyagi  wrote:
> > >
> > > 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
> > 

Re: [R] Processing a hierarchical string name

2023-06-29 Thread Kevin Zembower via R-help
Ivan and Bert, thank you so much for your help.

Ivan, your solution worked perfectly. I didn't really understand how to 
do string processing on a vector of strings, and your solution 
demonstrated it for me. I modified it to work with the tidyverses' 
stringr library in this way:

bg3_race_sum <- bg3_race %>%
 left_join(pl_vars, by=c("variable" = "name")) %>%
 group_by(variable) %>%
 summarize(count = sum(value)) %>%
 left_join(pl_vars, by=c("variable" = "name")) %>%
 filter(count > 0) %>%
 .$label %>%
 str_replace("^ !!", "") %>% #Drop the leading ' !!'
 str_replace_all("[^!]*!!", " ") #Replace each !!.* with space

Bert, your solution was close to correct. It correctly dropped the right 
text, but didn't insert a space for each piece of text between "!!" and 
after the ":". I'm using those spaces to preserve the hierarchical 
nature of the numbers, how lower numbers (in the chart) are included in 
higher numbers. For instance, the "Total:" number is the sum of 
"Population of one race" and "Population of two or more races".

Thank you both for helping me with this specific problem and for 
increasing my knowledge and abilities with R.

-Kevin

On 6/28/23 16:56, Ivan Krylov wrote:
> On Wed, 28 Jun 2023 20:29:23 +
> Kevin Zembower via R-help  wrote:
> 
>> I think my algorithm for the labels is:
>> 1. keep everything from the last "!!" up to and including the last
>> character
>> 2. for everything remaining, replace each "!!.*:" group with a single
>> space.
> 
> If you remove the initial ' !!', the problem becomes a more tractable
> "replace each group of non-'!' followed by '!!' with one space":
> 
> bg3_race_sum$label |>
>   (\(.) sub('^ !!', '', .))() |>
>   (\(.) gsub('[^!]*!!', ' ', .))()
> 
> But that solution could have been impossible if the task was slightly
> different.
> 
>> I can split the label using str_split(label, pattern = "!!") to get a
>> vector of strings, but don't know how to work on the last string and
>> all the rest of the strings separately.
> 
> str_split() would have given you a list of character vectors. You can
> use lapply to evaluate a function on each vector inside that list.
> Inside the function, use length(x) (if `x` is the argument of the
> function) to find out how many spaces to produce and which element of
> the vector is the last one. (For code golf points, use rev(x)[1] to get
> the last element.)
>

__
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 factors in graph panel

2023-06-29 Thread John Kane
Anupa,

I think your  best bet with your data would be to tidy it up in Excel, read
it into  R using something like the readxl package and then supply some
sample data is the dput() function.

In the case of a large dataset something like dput(head(mydata, 100))
should supply the data we need. Just do dput(mydata) where *mydata* is your
data. Copy the output and paste it here.

On Thu, 29 Jun 2023 at 08:37, Ebert,Timothy Aaron  wrote:

> Reposting the data did not help. We do not like to guess, and doing so
> takes a great deal of time that is likely wasted.
> Rows are observations.
> Columns are variables.
> In Excel, the first row will be variable names and all subsequent rows
> will be observations.
>
> Income is the first variable. It has seven states: $10, $25, $40, $75,
> >$75, "No", "Answer"
> MF is the second variable. It has six values: 1, 2, 3, 4, 5, 9
> None is the third variable. It has seven values: 1, 3.05,  2.29, 2.24,
> 1.71, 1.30, 2.83
> Equity is the last variable with many states, both numeric and text. A
> computer will read it all as text.
>
> As written the data cannot be analyzed.
>
> Equity looks like it should be numeric. However, it has text values:
> "Debt", "Hybrid", Bank", "AC", "None", "Current", "Savings", "No", and
> "Answer"
>
> In looking at the data I try to find some organization where every
> variable has the same number of rows as every other variable. I fail with
> these data.
> I could combine "No" and "Answer" into one name "No Answer" to make it
> agree with MF, but then it does not work for None.
>
>
> Please rework the data in Excel so that we can properly interpret the
> content. If it is badly organized in Excel, moving it to R will not help.
> Below, I tried adding carriage returns and spaces to organize the data,
> but I have a column of numbers that are not identified. The values below
> $10 do not make much sense compared to other values.
>
> I am tired of guessing.
>
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of Anupam Tyagi
> Sent: Wednesday, June 28, 2023 11:49 PM
> To: r-help@r-project.org
> Subject: Re: [R] Plotting factors in graph panel
>
> [External Email]
>
> Thanks, Pikal and Jim. Yes, it has been a long time Jim. I hope you have
> been well.
>
> Pikal, thanks. Your solution may be close to what I want. I did not know
> that I was posting in HTML. I just copied the data from Excel and posted in
> the email in Gmail. The data is still in Excel, because I have not yet
> figured out what is a good way to organize it in R. I am posting it again
> below as text. These are rows in Excel: 1,2,3,5,9 after MF are income
> categories and No Answer category (9). Down the second column are
> categories of MF and Bank AC. Rest of the columns are percentages.
>
> Jim, thanks for the graph. I am looking to plot only one line (category)
> each in many small plots on the same page. I don't want to compare
> different categories on the same graph as you do, but see how each category
> varies by income, one category in each graph. Like Excel does with
> Sparklines (Top menu: Insert, Sparklines, Lines). I have many categories
> for many variables. I am only showing two MF and Bank AC.
>
> Income$10 $25 $40  $75   > $75No Answer
> MF   1  2 3   4 5  9
> None   1   3.05 2.292.24 1.711.30
>  2.83
> Equity 229.76  28.79  29.51 28.90   31.6736.77
>
> Debt3  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
>
> Current2 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
>
>
> On Wed, 28 Jun 2023 at 17:30, Jim Lemon  wrote:
>
> > Hi Anupam,
> > Haven't heard from you in a long time. Perhaps you want something like
> > this:
> >
> > at_df<-read.table(text=
> >  "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None Bank_Current
> > Bank_Savings Bank_NA
> >  $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
> >  $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
> >  $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
> >  $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
> >  >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208  No_Answer 9
> > 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
> >  header=TRUE,stringsAsFactors=FALSE)
> > at_df<-at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
> > png("MF_Bank.png",height=600)
> > par(mfrow=c(2,1))
> > matplot(at_df[,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid")],
> >  type="l",col=1:4,lty=1:4,lwd=3,
> >  main="Percentages by Income and MF type",
> > xlab="Income",ylab="Percentage of group",xaxt="n")
> > axis(1,at=1:5,labels=at_df$Income)
> > legend(3,24,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid"),
> >  

Re: [R] Plotting factors in graph panel

2023-06-29 Thread Ebert,Timothy Aaron
Reposting the data did not help. We do not like to guess, and doing so takes a 
great deal of time that is likely wasted.
Rows are observations.
Columns are variables.
In Excel, the first row will be variable names and all subsequent rows will be 
observations.

Income is the first variable. It has seven states: $10, $25, $40, $75, >$75, 
"No", "Answer"
MF is the second variable. It has six values: 1, 2, 3, 4, 5, 9
None is the third variable. It has seven values: 1, 3.05,  2.29, 2.24, 1.71, 
1.30, 2.83
Equity is the last variable with many states, both numeric and text. A computer 
will read it all as text.

As written the data cannot be analyzed.

Equity looks like it should be numeric. However, it has text values: "Debt", 
"Hybrid", Bank", "AC", "None", "Current", "Savings", "No", and "Answer"

In looking at the data I try to find some organization where every variable has 
the same number of rows as every other variable. I fail with these data.
I could combine "No" and "Answer" into one name "No Answer" to make it agree 
with MF, but then it does not work for None.


Please rework the data in Excel so that we can properly interpret the content. 
If it is badly organized in Excel, moving it to R will not help.
Below, I tried adding carriage returns and spaces to organize the data, but I 
have a column of numbers that are not identified. The values below $10 do not 
make much sense compared to other values.

I am tired of guessing.

Tim

-Original Message-
From: R-help  On Behalf Of Anupam Tyagi
Sent: Wednesday, June 28, 2023 11:49 PM
To: r-help@r-project.org
Subject: Re: [R] Plotting factors in graph panel

[External Email]

Thanks, Pikal and Jim. Yes, it has been a long time Jim. I hope you have been 
well.

Pikal, thanks. Your solution may be close to what I want. I did not know that I 
was posting in HTML. I just copied the data from Excel and posted in the email 
in Gmail. The data is still in Excel, because I have not yet figured out what 
is a good way to organize it in R. I am posting it again below as text. These 
are rows in Excel: 1,2,3,5,9 after MF are income categories and No Answer 
category (9). Down the second column are categories of MF and Bank AC. Rest of 
the columns are percentages.

Jim, thanks for the graph. I am looking to plot only one line (category) each 
in many small plots on the same page. I don't want to compare different 
categories on the same graph as you do, but see how each category varies by 
income, one category in each graph. Like Excel does with Sparklines (Top menu: 
Insert, Sparklines, Lines). I have many categories for many variables. I am 
only showing two MF and Bank AC.

Income$10 $25 $40  $75   > $75No Answer
MF   1  2 3   4 5  9
None   1   3.05 2.292.24 1.711.30   2.83
Equity 229.76  28.79  29.51 28.90   31.6736.77

Debt3  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

Current2 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


On Wed, 28 Jun 2023 at 17:30, Jim Lemon  wrote:

> Hi Anupam,
> Haven't heard from you in a long time. Perhaps you want something like
> this:
>
> at_df<-read.table(text=
>  "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None Bank_Current
> Bank_Savings Bank_NA
>  $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
>  $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
>  $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
>  $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
>  >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208  No_Answer 9
> 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
>  header=TRUE,stringsAsFactors=FALSE)
> at_df<-at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
> png("MF_Bank.png",height=600)
> par(mfrow=c(2,1))
> matplot(at_df[,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid")],
>  type="l",col=1:4,lty=1:4,lwd=3,
>  main="Percentages by Income and MF type",
> xlab="Income",ylab="Percentage of group",xaxt="n")
> axis(1,at=1:5,labels=at_df$Income)
> legend(3,24,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid"),
>  lty=1:4,lwd=3,col=1:4)
> matplot(at_df[,c("Bank_None","Bank_Current","Bank_Savings")],
>  type="l",col=1:3,lty=1:4,lwd=3,
>  main="Percentages by Income and Bank type",
> xlab="Income",ylab="Percentage of group",xaxt="n")
> axis(1,at=1:5,labels=at_df$Income)
> legend(3,54,c("Bank_None","Bank_Current","Bank_Savings"),
>  lty=1:4,lwd=3,col=1:3)
> dev.off()
>
> Jim
>
> On Wed, Jun 28, 2023 at 6:33 PM Anupam Tyagi  wrote:
> >
> > 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 

Re: [R] Plotting factors in graph panel

2023-06-29 Thread PIKAL Petr
Hi Anupam

Using Jim's data

library(reshape2)
at_long <- melt(at_df)
at_long$innum <- as.numeric(as.factor(at_long$Income))
ggplot(at_long, aes(x=innum, y=value)) + geom_path() + facet_wrap(~variable, 
ncol=1)

is probably close to what you want. 

You need to fiddle with labels, facets variable names to fit your needs.
Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Anupam Tyagi
> Sent: Thursday, June 29, 2023 5:49 AM
> To: r-help@r-project.org
> Subject: Re: [R] Plotting factors in graph panel
> 
> Thanks, Pikal and Jim. Yes, it has been a long time Jim. I hope you have been
> well.
> 
> Pikal, thanks. Your solution may be close to what I want. I did not know that 
> I
> was posting in HTML. I just copied the data from Excel and posted in the email
> in Gmail. The data is still in Excel, because I have not yet figured out what 
> is a
> good way to organize it in R. I am posting it again below as text. These are
> rows in Excel: 1,2,3,5,9 after MF are income categories and No Answer
> category (9). Down the second column are categories of MF and Bank AC.
> Rest of the columns are percentages.
> 
> Jim, thanks for the graph. I am looking to plot only one line (category) each 
> in
> many small plots on the same page. I don't want to compare different
> categories on the same graph as you do, but see how each category varies by
> income, one category in each graph. Like Excel does with Sparklines (Top
> menu: Insert, Sparklines, Lines). I have many categories for many variables. I
> am only showing two MF and Bank AC.
> 
> 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
> 
> 
> On Wed, 28 Jun 2023 at 17:30, Jim Lemon  wrote:
> 
> > Hi Anupam,
> > Haven't heard from you in a long time. Perhaps you want something like
> > this:
> >
> > at_df<-read.table(text=
> >  "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None
> Bank_Current
> > Bank_Savings Bank_NA
> >  $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
> >  $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
> >  $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
> >  $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
> >  >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208  No_Answer 9
> > 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
> >  header=TRUE,stringsAsFactors=FALSE)
> > at_df<-
> at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
> > png("MF_Bank.png",height=600)
> > par(mfrow=c(2,1))
> > matplot(at_df[,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid")],
> >  type="l",col=1:4,lty=1:4,lwd=3,
> >  main="Percentages by Income and MF type",
> > xlab="Income",ylab="Percentage of group",xaxt="n")
> > axis(1,at=1:5,labels=at_df$Income)
> > legend(3,24,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid"),
> >  lty=1:4,lwd=3,col=1:4)
> > matplot(at_df[,c("Bank_None","Bank_Current","Bank_Savings")],
> >  type="l",col=1:3,lty=1:4,lwd=3,
> >  main="Percentages by Income and Bank type",
> > xlab="Income",ylab="Percentage of group",xaxt="n")
> > axis(1,at=1:5,labels=at_df$Income)
> > legend(3,54,c("Bank_None","Bank_Current","Bank_Savings"),
> >  lty=1:4,lwd=3,col=1:3)
> > dev.off()
> >
> > Jim
> >
> > On Wed, Jun 28, 2023 at 6:33 PM Anupam Tyagi 
> wrote:
> > >
> > > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> 

Re: [R] horizontal grouped stacked plots and removing space between bars

2023-06-29 Thread PIKAL Petr
Hi Anamaria

Thanks for the data. 

See in line.

> -Original Message-
> From: R-help  On Behalf Of Ana Marija
> Sent: Wednesday, June 28, 2023 6:00 PM
> To: r-help 
> Subject: [R] horizontal grouped stacked plots and removing space between
> bars
> 
> I have code like this:
> 
> data <- read.csv("test1.csv", stringsAsFactors=FALSE, header=TRUE)
> # Graph
> myplot=ggplot(data, aes(fill=condition, y=value, x=condition)) +
> geom_bar(position="dodge", stat="identity", width=0.5) +
> scale_fill_manual(values=c("#7b3294", "#c2a5cf", "#a6dba0",
"#008837"))+

You have only 4 colours, you need 5 so I removed the line

> ylab("Performance (ns/day)") +
> facet_wrap(~specie,nrow=3, labeller = label_wrap_gen(width = 85),
> strip.position="bottom") +
>theme_bw() +
>theme(panel.grid = element_blank(),
> panel.spacing = unit(0, "mm"),
> legend.title=element_blank(),
> axis.title.x = element_blank(),
> panel.grid.major = element_blank(),
> panel.grid.minor = element_blank(),
> panel.background = element_blank(),
> axis.ticks.x=element_blank(),
> axis.title.y = element_text(angle = 90, hjust = 0.5))
> 
> 
> 
> myplot + theme(panel.grid.major = element_blank(), panel.grid.minor =
> element_blank(), legend.title=element_blank(),
> panel.background = element_blank(), axis.title.x = element_blank(),
> axis.text.x=element_blank(), axis.ticks.x=element_blank(),
> axis.title.y = element_text(angle = 90, hjust = 0.5))

And here I got 2 plots one above the other so I presume this is what you
wanted. 

Spacing between bars
https://www.statology.org/ggplot2-space-between-bars/

Cheers
Petr

> 
> And my data is this:
> 
> > dput(data)
> structure(list(specie = c("gmx mdrun -gpu_id 1 -ntomp 16 -s
> benchMEM.tpr -nsteps 1", "gmx mdrun -gpu_id 1 -ntomp 16 -s
> benchMEM.tpr -nsteps 1", "gmx mdrun -gpu_id 1 -ntomp 16 -s
> benchMEM.tpr -nsteps 1", "gmx mdrun -gpu_id 1 -ntomp 16 -s
> benchMEM.tpr -nsteps 1", "gmx mdrun -gpu_id 1 -ntomp 16 -s
> MD_15NM_WATER.tpr -nsteps 1", "gmx mdrun -gpu_id 1 -ntomp 16 -s
> MD_15NM_WATER.tpr -nsteps 1", "gmx mdrun -gpu_id 1 -ntomp 16 -s
> MD_15NM_WATER.tpr -nsteps 1", "gmx mdrun -gpu_id 1 -ntomp 16 -s
> MD_15NM_WATER.tpr -nsteps 1"), condition = c("Tesla P100-SYCL",
> "Tesla V100-SYCL", "Tesla P100-CUDA", "Tesla V100-CUDA", "Tesla
> P100-SYCL", "Tesla V100-SYCL", "Tesla P100-CUDA", "Tesla V100-CUDA"),
> value = c(75.8, 77.771, 63.297, 78.046, 34.666, 50.052, 32.07,
> 59.815)), class = "data.frame", row.names = c(NA, -8L))
> 
> How do I:
> 
>1. have these two plots next to each other, not on the top of each
other
>2. How do I remove spaces between those bars?
> 
>   [[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] LINUX SuSE15.4 (GNU & Intel) compiler problem in "configure" file

2023-06-29 Thread Ivan Krylov
On Wed, 28 Jun 2023 16:55:33 +0500
Jannie Pretorius  wrote:

> ./configure: line 24446: ${}: bad substitution

>   ## Export LD_LIBRARY_PATH or equivalent.
>  if eval "test -z \"\*${*${Rshlibpath_var}*}*\""; then
> eval "${Rshlibpath_var}=\"${R_LD_LIBRARY_PATH}\""
> else
> eval
> "${Rshlibpath_var}=\"${R_LD_LIBRARY_PATH}${PATH_SEPARATOR}\${${Rshlibpath_var}}\""
> fi

What's your /bin/sh? Is it a symlink to bash, dash, or something else?

Does the config.log file created in the directory where you ran
.../configure contain mentions of variables Rshlibpath_var and
shlibpath_var? Which values do they have? (Are they really empty?)

The configure script should have noticed that you're building for
GNU/Linux and set these variables appropriately (the value should be
'LD_LIBRARY_PATH' in both cases). What is the output of
tools/config.guess?

-- 
Best regards,
Ivan

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