Re: [R] [External] Error in percentage stacked barplot

2023-05-02 Thread Richard M. Heiberger
## you may need to install HH
install.packagess("HH")

library(HH)

hellisheidi <- read.table(text="
Component  Sample1  Sample2  Sample3
CaO455248
SiO2   252218
Al2O3 151114
TiO2  6  56
Na2O5  45
CuO  335
Cl 1  34"
, header=TRUE, row.names="Component")

likert(t(hellisheidi), ReferenceZero=.5,
   xlab="X-lab", ylab="Y-lab", main="Stacked bar chart")


> On May 2, 2023, at 15:23, Maria Lathouri via R-help  
> wrote:
> 
> Dear all, 
> I am trying to plot the following table in stacked barplot in percentages and 
> also horizontal.
> Component  Sample 1  Sample 2  Sample 3CaO45  
>   5248SiO2   2522 
>18Al2O3 1511
> 14TiO2 6  56  Na2O
> 5  45CuO  
> 3  35 Cl 1
>   34
> When I tried the following functionbarplot(data,
> + main = "Stacked bar chart",
> + sub = "Subtitle",
> + xlab = "X-lab",
> + ylab = "Y-lab",
> + axes = TRUE, horiz = TRUE)
> I got the following error
> Error in barplot.default(hellisheidi, main = "Stacked bar chart", sub = 
> "Subtitle",  : 
>  'height' must be a vector or a matrix
> I also tried barplot(as.matrix(hellisheidi)) but what I was getting was the 
> three stacked columns for Samples 1, 2 and 3 but I was getting an empty 
> column for Component, instead of being the variable in the Samples. 
> 
> 
> I was hoping if you could help me on that. 
> Thank you very much in advance. 
> Kind regards,Maria
> 
> 
> 
> <1683055323500blob.jpg>__
> 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] Error in percentage stacked barplot

2023-05-02 Thread Maria Lathouri via R-help
Dear all, 
I am trying to plot the following table in stacked barplot in percentages and 
also horizontal.
Component      Sample 1      Sample 2      Sample 3CaO    45
    52    48SiO2   25    22 
   18Al2O3 15    11    14TiO2   
                  6                  5                6      Na2O   
     5  4    5CuO                      3            
      3                5         Cl 1  
3                4
When I tried the following functionbarplot(data,
+ main = "Stacked bar chart",
+ sub = "Subtitle",
+ xlab = "X-lab",
+ ylab = "Y-lab",
+ axes = TRUE, horiz = TRUE)
I got the following error
Error in barplot.default(hellisheidi, main = "Stacked bar chart", sub = 
"Subtitle",  : 
  'height' must be a vector or a matrix
I also tried barplot(as.matrix(hellisheidi)) but what I was getting was the 
three stacked columns for Samples 1, 2 and 3 but I was getting an empty column 
for Component, instead of being the variable in the Samples. 


I was hoping if you could help me on that. 
Thank you very much in advance. 
Kind regards,Maria



__
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] Reg: Help regarding ggplot2

2023-05-02 Thread Chris Evans via R-help
I'm only seeing six dates, by the look of them five at one day intervals 
and the last three days later.  According to my calendar those were 
weekdays in 2005.  I don't see much "volatility" there and that's not a 
term I'm familiar with, I suspect it's econometric.  I don't know what 
you're looking for and I think we're starting to get into issues about 
interpretation of data not issues about using R so off list.  I think 
you need statistical or econometric support from somewhere.

Good luck!

Chris

On 02/05/2023 17:50, Upananda Pani wrote:
> Hi Chrish,
>
> I am grateful to you for your reply. Your code is working fine.
> Moreover, you have guided me how to improve my knowledge, I appreciate
> it. I will be very careful next time.
> The data which i am working on is given below:
>
> dput(head(data_vol3))
> structure(list(index = structure(c(12786, 12787, 12788, 12789,
> 12790, 12793), tzone = "UTC", tclass = "Date", class = "Date"),
>  crepub = c(1.20601312, 1.176601845, 1.14945752, 1.112667506,
>  1.076184043, 1.042147848), finland = c(0.614973309, 0.615008409,
>  0.615034446, 0.615053761, 0.615068089, 0.615078717), france = 
> c(1.896830857,
>  1.849908737, 1.807150091, 1.763296422, 1.719573044, 1.690600819
>  ), germany = c(3.01041925, 2.892518667, 2.780918603, 2.672356826,
>  2.567306135, 2.479892045), italy = c(0.345659867, 0.345675874,
>  0.345686934, 0.345694578, 0.34569986, 0.34570351), netherlands =
> c(0.509263785,
>  0.509279495, 0.509289967, 0.509296947, 0.509301605, 0.509304705
>  ), norway = c(1.052509528, 0.889357215, 0.784607722, 0.710551664,
>  0.661473027, 0.629951323), poland = c(1.127163733, 1.12432629,
>  1.087704091, 1.056705592, 1.024417693, 1.007962456), slovakia =
> c(0.715652234,
>  0.706087191, 0.706077173, 0.706104559, 0.70622666, 0.706098981
>  ), slovenia = c(0.831886154, 0.831945994, 0.832003445, 0.832058602,
>  0.832111556, 0.832162397), uk = c(1.504813191, 1.463648326,
>  1.424235397, 1.38618692, 1.349628127, 1.318653737), usa = c(1.521675109,
>  1.488286869, 1.451778376, 1.418378195, 1.384742397, 1.363477506
>  )), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
> ))
>
> As there are some countries which are having higher volatilities than
> countries with lower, is there any suggestion to improve the graph?
>
> Looking forward to your suggestion in this regard.
>
> With sincere regards,
> Upananda Pani
>
>
> On Tue, May 2, 2023 at 6:14 PM Chris Evans  wrote:
>> I suspect that you have tried to pass your own data into the pivot_longer() 
>> function and your data probably doesn't have the rowN variable.
>>
>> First try running the whole of what I sent you.  It definitively works for 
>> me.  It gives me the attached graph.
>>
>> My code, using tribble() to read in the data you sent us, creates a rowN 
>> variable to save me the trouble of deleting those row numbers one by one.  
>> Then I drop that variable with that select(-rowN) line.
>>
>> Assuming that works for you running my code on that tiny dataset, and that 
>> you are trying to use the code on your full data frame, called data_vol3 
>> then try this:
>>
>> data_vol3 %>%
>># select(-rowN) %>% # I have commented out this line
>>pivot_longer(cols = -index, # as you want to pivot the other 
>> variables/columns
>> names_to = "countries") -> tibDataVol3Long
>>
>> ggplot(data = tibDataVol3Long,
>> aes(x = index, y = value, group = countries, colour = countries)) +
>>geom_line()
>>
>> This is a very good illustration of why you should supply data using 
>> dput(data), dput(head(data)) if you have a large dataset. I know it doesn't 
>> feel a very sympathetic piece of advice, but I think you need to spend some 
>> days working on your understanding of R, ggplot and the tidyverse realm of 
>> R.  You can use ggplot() without using much of the tidyverse but they are 
>> designed to complement each other and the more I understand of the tidyverse 
>> way of doing things, the better I use ggplot().
>>
>> On 02/05/2023 13:44, Upananda Pani wrote:
>>
>> Hi Chris,
>>
>> Thank for your solutions and time. I am getting the following error
>> while trying to execute the code you suggested.
>>
>> Error in select(., -rowN) : unused argument (-rowN)
>>
>> Regards,
>> Upananda
>>
>> On Tue, May 2, 2023 at 3:08 PM Chris Evans via R-help
>>   wrote:
>>
>> It's not clear what you want but ...
>>
>> On 02/05/2023 10:57, Upananda Pani wrote:
>>
>> Dear All,
>>
>> I have a dataset which contains date and 12 other countries data. I
>> have extracted the data as xts object.
>>
>> I am not able to recall all the series in the Y axis. My data set
>> looks like this
>>
>> index crepub finland france germany italy netherlands norway poland
>> 
>> 1 2005-01-03 1.21 0.615 1.90 3.01 0.346 0.509 1.05 1.13
>> 2 2005-01-04 1.18 0.615 1.85 2.89 0.346 0.509 0.889 1.12
>> 3 2005-01-05 1.15 0.615 1.81 2.78 0.346 0.509 0.785 

Re: [R] Reg: Help regarding ggplot2

2023-05-02 Thread Thomas . Rose
Dear Upananda,

I see a misplaced bracket in your code, and there is no need in aes() to call 
the dataframe explicitly. Does this work?

ggplot(data = data_vol3, aes(x = index, y = usa)) +
  geom_line()

Best wishes,
Thomas


Von: R-help  im Auftrag von Upananda Pani 

Gesendet: Dienstag, 2. Mai 2023 10:57
An: r-help 
Betreff: [R] Reg: Help regarding ggplot2

Dear All,

I have a dataset which contains date and 12 other countries data. I
have extracted the data as xts object.

I am not able to recall all the series in the Y axis. My data set
looks like this

index  crepub finland france germany italy netherlands norway poland

1 2005-01-03   1.21   0.615   1.903.01 0.346   0.509  1.051.13
2 2005-01-04   1.18   0.615   1.852.89 0.346   0.509  0.889   1.12
3 2005-01-05   1.15   0.615   1.812.78 0.346   0.509  0.785   1.09
4 2005-01-06   1.11   0.615   1.762.67 0.346   0.509  0.711   1.06
5 2005-01-07   1.08   0.615   1.722.57 0.346   0.509  0.661   1.02
6 2005-01-10   1.04   0.615   1.692.48 0.346   0.509  0.630   1.01

My code for the same is as follows

ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
  geom_line())

Any help in this regard will be highly appreciated

With regards,
Upananda Pani

__
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] [R-pkgs] gsDesign2 1.0.8 is released

2023-05-02 Thread Nan Xiao
Dear all,

A new version of gsDesign2 (1.0.8) is now on CRAN 
(https://cran.r-project.org/package=gsDesign2). gsDesign2 enables fixed or 
group sequential design under non-proportional hazards and supports highly 
flexible enrollment, time-to-event, and time-to-dropout assumptions.

The key improvements in this version include refined naming conventions for 
options in the info_scale argument adhering to the tidyverse design guide, and 
bug fixes for computing the futility bounds. Please see the changelog 
(https://merck.github.io/gsDesign2/news/) for details.

As the gsDesign2 package is still in its early stages, we're eager to continue 
refining its features and performance. We invite you to try out this new 
version and share your insights with us. Your feedback is invaluable in helping 
us develop a tool that meets the evolving needs of users.

Cheers,
-Nan

___
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] Reg: Help regarding ggplot2

2023-05-02 Thread Upananda Pani
Hi Chrish,

I am grateful to you for your reply. Your code is working fine.
Moreover, you have guided me how to improve my knowledge, I appreciate
it. I will be very careful next time.
The data which i am working on is given below:

dput(head(data_vol3))
structure(list(index = structure(c(12786, 12787, 12788, 12789,
12790, 12793), tzone = "UTC", tclass = "Date", class = "Date"),
crepub = c(1.20601312, 1.176601845, 1.14945752, 1.112667506,
1.076184043, 1.042147848), finland = c(0.614973309, 0.615008409,
0.615034446, 0.615053761, 0.615068089, 0.615078717), france = c(1.896830857,
1.849908737, 1.807150091, 1.763296422, 1.719573044, 1.690600819
), germany = c(3.01041925, 2.892518667, 2.780918603, 2.672356826,
2.567306135, 2.479892045), italy = c(0.345659867, 0.345675874,
0.345686934, 0.345694578, 0.34569986, 0.34570351), netherlands =
c(0.509263785,
0.509279495, 0.509289967, 0.509296947, 0.509301605, 0.509304705
), norway = c(1.052509528, 0.889357215, 0.784607722, 0.710551664,
0.661473027, 0.629951323), poland = c(1.127163733, 1.12432629,
1.087704091, 1.056705592, 1.024417693, 1.007962456), slovakia =
c(0.715652234,
0.706087191, 0.706077173, 0.706104559, 0.70622666, 0.706098981
), slovenia = c(0.831886154, 0.831945994, 0.832003445, 0.832058602,
0.832111556, 0.832162397), uk = c(1.504813191, 1.463648326,
1.424235397, 1.38618692, 1.349628127, 1.318653737), usa = c(1.521675109,
1.488286869, 1.451778376, 1.418378195, 1.384742397, 1.363477506
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))

As there are some countries which are having higher volatilities than
countries with lower, is there any suggestion to improve the graph?

Looking forward to your suggestion in this regard.

With sincere regards,
Upananda Pani


On Tue, May 2, 2023 at 6:14 PM Chris Evans  wrote:
>
> I suspect that you have tried to pass your own data into the pivot_longer() 
> function and your data probably doesn't have the rowN variable.
>
> First try running the whole of what I sent you.  It definitively works for 
> me.  It gives me the attached graph.
>
> My code, using tribble() to read in the data you sent us, creates a rowN 
> variable to save me the trouble of deleting those row numbers one by one.  
> Then I drop that variable with that select(-rowN) line.
>
> Assuming that works for you running my code on that tiny dataset, and that 
> you are trying to use the code on your full data frame, called data_vol3 then 
> try this:
>
> data_vol3 %>%
>   # select(-rowN) %>% # I have commented out this line
>   pivot_longer(cols = -index, # as you want to pivot the other 
> variables/columns
>names_to = "countries") -> tibDataVol3Long
>
> ggplot(data = tibDataVol3Long,
>aes(x = index, y = value, group = countries, colour = countries)) +
>   geom_line()
>
> This is a very good illustration of why you should supply data using 
> dput(data), dput(head(data)) if you have a large dataset. I know it doesn't 
> feel a very sympathetic piece of advice, but I think you need to spend some 
> days working on your understanding of R, ggplot and the tidyverse realm of R. 
>  You can use ggplot() without using much of the tidyverse but they are 
> designed to complement each other and the more I understand of the tidyverse 
> way of doing things, the better I use ggplot().
>
> On 02/05/2023 13:44, Upananda Pani wrote:
>
> Hi Chris,
>
> Thank for your solutions and time. I am getting the following error
> while trying to execute the code you suggested.
>
> Error in select(., -rowN) : unused argument (-rowN)
>
> Regards,
> Upananda
>
> On Tue, May 2, 2023 at 3:08 PM Chris Evans via R-help
>  wrote:
>
> It's not clear what you want but ...
>
> On 02/05/2023 10:57, Upananda Pani wrote:
>
> Dear All,
>
> I have a dataset which contains date and 12 other countries data. I
> have extracted the data as xts object.
>
> I am not able to recall all the series in the Y axis. My data set
> looks like this
>
> index crepub finland france germany italy netherlands norway poland
> 
> 1 2005-01-03 1.21 0.615 1.90 3.01 0.346 0.509 1.05 1.13
> 2 2005-01-04 1.18 0.615 1.85 2.89 0.346 0.509 0.889 1.12
> 3 2005-01-05 1.15 0.615 1.81 2.78 0.346 0.509 0.785 1.09
> 4 2005-01-06 1.11 0.615 1.76 2.67 0.346 0.509 0.711 1.06
> 5 2005-01-07 1.08 0.615 1.72 2.57 0.346 0.509 0.661 1.02
> 6 2005-01-10 1.04 0.615 1.69 2.48 0.346 0.509 0.630 1.01
>
> My code for the same is as follows
>
> ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
> geom_line())
>
> Well you don't need to say that the y data are from data_vol3, your data
> = declaration says that.
>
> I wonder if what you want is:
>
> library(tidyverse)
>
> tribble(
>~rowN, ~index, ~crepub, ~finland, ~france, ~germany, ~italy,
> ~netherlands, ~norway, ~poland,
>1, "2005-01-03", 1.21, 0.615, 1.90, 3.01, 0.346, 0.509, 1.05, 1.13,
>2, "2005-01-04", 1.18, 0.615, 1.85, 2.89, 0.346, 0.509, 0.889, 1.12,

Re: [R] Reg: Help regarding ggplot2

2023-05-02 Thread Upananda Pani
Hi Chris,

Thank for your solutions and time. I am getting the following error
while trying to execute the code you suggested.

Error in select(., -rowN) : unused argument (-rowN)

Regards,
Upananda

On Tue, May 2, 2023 at 3:08 PM Chris Evans via R-help
 wrote:
>
> It's not clear what you want but ...
>
> On 02/05/2023 10:57, Upananda Pani wrote:
> > Dear All,
> >
> > I have a dataset which contains date and 12 other countries data. I
> > have extracted the data as xts object.
> >
> > I am not able to recall all the series in the Y axis. My data set
> > looks like this
> >
> > index crepub finland france germany italy netherlands norway poland
> > 
> > 1 2005-01-03 1.21 0.615 1.90 3.01 0.346 0.509 1.05 1.13
> > 2 2005-01-04 1.18 0.615 1.85 2.89 0.346 0.509 0.889 1.12
> > 3 2005-01-05 1.15 0.615 1.81 2.78 0.346 0.509 0.785 1.09
> > 4 2005-01-06 1.11 0.615 1.76 2.67 0.346 0.509 0.711 1.06
> > 5 2005-01-07 1.08 0.615 1.72 2.57 0.346 0.509 0.661 1.02
> > 6 2005-01-10 1.04 0.615 1.69 2.48 0.346 0.509 0.630 1.01
> >
> > My code for the same is as follows
> >
> > ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
> > geom_line())
>
> Well you don't need to say that the y data are from data_vol3, your data
> = declaration says that.
>
> I wonder if what you want is:
>
> library(tidyverse)
>
> tribble(
>~rowN, ~index, ~crepub, ~finland, ~france, ~germany, ~italy,
> ~netherlands, ~norway, ~poland,
>1, "2005-01-03", 1.21, 0.615, 1.90, 3.01, 0.346, 0.509, 1.05, 1.13,
>2, "2005-01-04", 1.18, 0.615, 1.85, 2.89, 0.346, 0.509, 0.889, 1.12,
>3, "2005-01-05", 1.15, 0.615, 1.81, 2.78, 0.346, 0.509, 0.785, 1.09,
>4, "2005-01-06", 1.11, 0.615, 1.76, 2.67, 0.346, 0.509, 0.711, 1.06,
>5, "2005-01-07", 1.08, 0.615, 1.72, 2.57, 0.346, 0.509, 0.661, 1.02,
>6, "2005-01-10", 1.04, 0.615, 1.69, 2.48, 0.346, 0.509, 0.630, 1.01)
> -> data_vol3
>
> ### please give us data using dput in future: saves us having to do
> something like that to reclaim it!
>
> ### pivot that longer to make it easy to get country data as separate lines
>
> data_vol3 %>%  select(-rowN) %>%
>pivot_longer(cols = -index, # as you want to pivot the other
> variables/columns
> names_to = "countries") -> tibDataVol3Long
>
> ggplot(data = tibDataVol3Long,
> aes(x = index, y = value,
>   ### now get the grouping and use it for a colour legend
>   group = countries, colour = countries)) +
>geom_line()
>
> > Any help in this regard will be highly appreciated
> >
> > With regards,
> > Upananda Pani
> >
> > __
> > 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.
> --
> Chris Evans (he/him)
> Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor,
> University of Roehampton, London, UK.
> Work web site: https://www.psyctc.org/psyctc/
> CORE site: http://www.coresystemtrust.org.uk/
> Personal site: https://www.psyctc.org/pelerinage2016/
> Emeetings (Thursdays):
> https://www.psyctc.org/psyctc/booking-meetings-with-me/
> (Beware: French time, generally an hour ahead of UK)
> 
> [[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] Reg: Help regarding ggplot2

2023-05-02 Thread Upananda Pani
Hi Thomas,

Thanks for your help. I need to plot all other countries as well.

Thanks for your time

With sincere regards,
Upananda

On Tue, May 2, 2023 at 3:01 PM Thomas.Rose 
wrote:

> Dear Upananda,
>
> I see a misplaced bracket in your code, and there is no need in aes() to
> call the dataframe explicitly. Does this work?
>
> ggplot(data = data_vol3, aes(x = index, y = usa)) +
>   geom_line()
>
> Best wishes,
> Thomas
>
> --
> *Von:* R-help  im Auftrag von Upananda Pani
> 
> *Gesendet:* Dienstag, 2. Mai 2023 10:57
> *An:* r-help 
> *Betreff:* [R] Reg: Help regarding ggplot2
>
> Dear All,
>
> I have a dataset which contains date and 12 other countries data. I
> have extracted the data as xts object.
>
> I am not able to recall all the series in the Y axis. My data set
> looks like this
>
> index  crepub finland france germany italy netherlands norway poland
> 
> 1 2005-01-03   1.21   0.615   1.903.01 0.346   0.509  1.051.13
> 2 2005-01-04   1.18   0.615   1.852.89 0.346   0.509  0.889   1.12
> 3 2005-01-05   1.15   0.615   1.812.78 0.346   0.509  0.785   1.09
> 4 2005-01-06   1.11   0.615   1.762.67 0.346   0.509  0.711   1.06
> 5 2005-01-07   1.08   0.615   1.722.57 0.346   0.509  0.661   1.02
> 6 2005-01-10   1.04   0.615   1.692.48 0.346   0.509  0.630   1.01
>
> My code for the same is as follows
>
> ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
>   geom_line())
>
> Any help in this regard will be highly appreciated
>
> With regards,
> Upananda Pani
>
> __
> 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] Reg: Help regarding ggplot2

2023-05-02 Thread Ebert,Timothy Aaron
Reorganize the data so that you have three columns
Something more like this:

Date  Country  Value
2005-01-03  Crepub1.21

You ggplot statement has a mistake. The geom_line() should be outside the 
ggplot() call.

You might then have a ggplot statement like
ggplot(data=data_vol3, aes(x=Country, y=Value)) + geom_line()

Just make sure that the data type(s) are what they need to be. Country is 
non-numeric, and I am not sure geom_line() will like that. I am not sure why 
one might draw a line connecting categorical items.


Tim

-Original Message-
From: R-help  On Behalf Of Upananda Pani
Sent: Tuesday, May 2, 2023 4:57 AM
To: r-help 
Subject: [R] Reg: Help regarding ggplot2

[External Email]

Dear All,

I have a dataset which contains date and 12 other countries data. I have 
extracted the data as xts object.

I am not able to recall all the series in the Y axis. My data set looks like 
this

index  crepub finland france germany italy netherlands norway poland

1 2005-01-03   1.21   0.615   1.903.01 0.346   0.509  1.051.13
2 2005-01-04   1.18   0.615   1.852.89 0.346   0.509  0.889   1.12
3 2005-01-05   1.15   0.615   1.812.78 0.346   0.509  0.785   1.09
4 2005-01-06   1.11   0.615   1.762.67 0.346   0.509  0.711   1.06
5 2005-01-07   1.08   0.615   1.722.57 0.346   0.509  0.661   1.02
6 2005-01-10   1.04   0.615   1.692.48 0.346   0.509  0.630   1.01

My code for the same is as follows

ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
  geom_line())

Any help in this regard will be highly appreciated

With regards,
Upananda Pani

__
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] Reg: Help regarding ggplot2

2023-05-02 Thread Olivier Crouzet
Dear Upananda,

to complement the current response to your question, your data
source looks like a "wide table" while you would certainly need them to
be organised as a "long table", or to speak differently as a "tidy
table". You should read this source in order to get a grasp on these
issues:

https://tidyr.tidyverse.org/articles/tidy-data.html

Please note that the etiquette on this list states that example data
should conform to some constraints that your message does not conform
to (you shoud therefore also read the posting guide:
http://www.R-project.org/posting-guide.html).

Yours. 
Olivier.

On Tue, 2 May 2023 14:27:24 +0530 Upananda
Pani  wrote:

> Dear All,
> 
> I have a dataset which contains date and 12 other countries data. I
> have extracted the data as xts object.
> 
> I am not able to recall all the series in the Y axis. My data set
> looks like this
> 
> index  crepub finland france germany italy netherlands norway
> poland   
>1 2005-01-03   1.21   0.615   1.903.01 0.346
> 0.509  1.051.13 2 2005-01-04   1.18   0.615   1.852.89
> 0.346   0.509  0.889   1.12 3 2005-01-05   1.15   0.615   1.81
> 2.78 0.346   0.509  0.785   1.09 4 2005-01-06   1.11   0.615
> 1.762.67 0.346   0.509  0.711   1.06 5 2005-01-07   1.08
> 0.615   1.722.57 0.346   0.509  0.661   1.02 6 2005-01-10
> 1.04   0.615   1.692.48 0.346   0.509  0.630   1.01
> 
> My code for the same is as follows
> 
> ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
>   geom_line())
> 
> Any help in this regard will be highly appreciated
> 
> With regards,
> Upananda Pani
> 
> __
> 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.


-- 
  Olivier Crouzet, PhD
  http://olivier.ghostinthemachine.space
  /Maître de Conférences/
  @LLING - Laboratoire de Linguistique de Nantes
UMR6310 CNRS / Université de Nantes

__
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] Reg: Help regarding ggplot2

2023-05-02 Thread Chris Evans via R-help
It's not clear what you want but ...

On 02/05/2023 10:57, Upananda Pani wrote:
> Dear All,
>
> I have a dataset which contains date and 12 other countries data. I
> have extracted the data as xts object.
>
> I am not able to recall all the series in the Y axis. My data set
> looks like this
>
> index crepub finland france germany italy netherlands norway poland
> 
> 1 2005-01-03 1.21 0.615 1.90 3.01 0.346 0.509 1.05 1.13
> 2 2005-01-04 1.18 0.615 1.85 2.89 0.346 0.509 0.889 1.12
> 3 2005-01-05 1.15 0.615 1.81 2.78 0.346 0.509 0.785 1.09
> 4 2005-01-06 1.11 0.615 1.76 2.67 0.346 0.509 0.711 1.06
> 5 2005-01-07 1.08 0.615 1.72 2.57 0.346 0.509 0.661 1.02
> 6 2005-01-10 1.04 0.615 1.69 2.48 0.346 0.509 0.630 1.01
>
> My code for the same is as follows
>
> ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
> geom_line())

Well you don't need to say that the y data are from data_vol3, your data 
= declaration says that.

I wonder if what you want is:

library(tidyverse)

tribble(
   ~rowN, ~index, ~crepub, ~finland, ~france, ~germany, ~italy, 
~netherlands, ~norway, ~poland,
   1, "2005-01-03", 1.21, 0.615, 1.90, 3.01, 0.346, 0.509, 1.05, 1.13,
   2, "2005-01-04", 1.18, 0.615, 1.85, 2.89, 0.346, 0.509, 0.889, 1.12,
   3, "2005-01-05", 1.15, 0.615, 1.81, 2.78, 0.346, 0.509, 0.785, 1.09,
   4, "2005-01-06", 1.11, 0.615, 1.76, 2.67, 0.346, 0.509, 0.711, 1.06,
   5, "2005-01-07", 1.08, 0.615, 1.72, 2.57, 0.346, 0.509, 0.661, 1.02,
   6, "2005-01-10", 1.04, 0.615, 1.69, 2.48, 0.346, 0.509, 0.630, 1.01) 
-> data_vol3

### please give us data using dput in future: saves us having to do 
something like that to reclaim it!

### pivot that longer to make it easy to get country data as separate lines

data_vol3 %>%  select(-rowN) %>%
   pivot_longer(cols = -index, # as you want to pivot the other 
variables/columns
    names_to = "countries") -> tibDataVol3Long

ggplot(data = tibDataVol3Long,
    aes(x = index, y = value,
  ### now get the grouping and use it for a colour legend
  group = countries, colour = countries)) +
   geom_line()

> Any help in this regard will be highly appreciated
>
> With regards,
> Upananda Pani
>
> __
> 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.
-- 
Chris Evans (he/him)
Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, 
University of Roehampton, London, UK.
Work web site: https://www.psyctc.org/psyctc/
CORE site: http://www.coresystemtrust.org.uk/
Personal site: https://www.psyctc.org/pelerinage2016/
Emeetings (Thursdays): 
https://www.psyctc.org/psyctc/booking-meetings-with-me/
(Beware: French time, generally an hour ahead of UK)

[[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] Reg: Help regarding ggplot2

2023-05-02 Thread Upananda Pani
Dear All,

I have a dataset which contains date and 12 other countries data. I
have extracted the data as xts object.

I am not able to recall all the series in the Y axis. My data set
looks like this

index  crepub finland france germany italy netherlands norway poland

1 2005-01-03   1.21   0.615   1.903.01 0.346   0.509  1.051.13
2 2005-01-04   1.18   0.615   1.852.89 0.346   0.509  0.889   1.12
3 2005-01-05   1.15   0.615   1.812.78 0.346   0.509  0.785   1.09
4 2005-01-06   1.11   0.615   1.762.67 0.346   0.509  0.711   1.06
5 2005-01-07   1.08   0.615   1.722.57 0.346   0.509  0.661   1.02
6 2005-01-10   1.04   0.615   1.692.48 0.346   0.509  0.630   1.01

My code for the same is as follows

ggplot(data=data_vol3, aes(x=index, y=data_vol3$usa)+
  geom_line())

Any help in this regard will be highly appreciated

With regards,
Upananda Pani

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