Print and plot a cross Data

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Print and plot a cross Data

Pedro páramo
Hi all,

I have a csv (extracted from a web) I attach the data:

I use this code to read the data;

library("readr")

tusDatos <- read_csv('~/datayield.csv')

In this CSV, I want to use three columns:

 tusDatos$DATA_TYPE_FM,  (will be X axis)
tusDatos$TIME_PERIOD (will be the pivot to search the values)
tusDatos$OBS_VALUE (Y Values)

In Data_Type_FM I want to plot a graph where only some rows (included in
thar colum) will be the X-axis and the Y-axis will be OBS:Value for an
specific DATE.

So for each day (time period) I will plot a plot imagine 04/08/2020 (a
value on TIME_PERIOD) for the values

c(  PY_1Y, PY_2Y,
PY_3Y, PY_4Y,
PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM

In excel for me is "easy" but in R I dont know how to proceed can you give
me some clue to make this king of operations?

If I wanted to do a 3D PloT would be possible? only also for this limited
values c(  PY_1Y, PY_2Y,
PY_3Y, PY_4Y,
PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM

tusDatos$DATA_TYPE_FM,  (will be X axis)
tusDatos$TIME_PERIOD (Z axis)
tusDatos$OBS_VALUE (Y Values)

Hope I explained properly and hope you can help and guide.



 datayield.csv
<https://drive.google.com/file/d/1WvIIhxXOeg8y_7LssRu0wK9s_c9c03sZ/view?usp=drive_web>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Print and plot a cross Data

Jim Lemon-4
Hi Pedro,
I'm not exactly sure of what you want, but try this:

# I downloaded the CSV file as datayield.csv
tus.datos<-read.table("datayield.csv",sep=";",header=TRUE)
library(scatterplot3d)
data_types<-c("PY_1Y","PY_2Y","PY_3Y","PY_4Y","PY_5Y","PY_6Y","PY_7Y")
row_subset<-tus.datos$DATA_TYPE %in% data_types
scatterplot3d(tus.datos$DATA_TYPE_FM[row_subset],
 tus.datos$OBS_VALUE[row_subset],
 tus.datos$TIME_PERIOD[row_subset],
 color=order(as.numeric(tus.datos$DATA_TYPE[row_subset])))
legend(9,8,data_types,pch=1,col=1:7,xpd=TRUE)

I used a few tricks to get this to work without being too long a
script. The color for PY_7Y is yellow, and this can be changed with a
bit of extra code.

Jim

On Thu, Aug 6, 2020 at 8:40 AM Pedro páramo <[hidden email]> wrote:

>
> Hi all,
>
> I have a csv (extracted from a web) I attach the data:
>
> I use this code to read the data;
>
> library("readr")
>
> tusDatos <- read_csv('~/datayield.csv')
>
> In this CSV, I want to use three columns:
>
>  tusDatos$DATA_TYPE_FM,  (will be X axis)
> tusDatos$TIME_PERIOD (will be the pivot to search the values)
> tusDatos$OBS_VALUE (Y Values)
>
> In Data_Type_FM I want to plot a graph where only some rows (included in
> thar colum) will be the X-axis and the Y-axis will be OBS:Value for an
> specific DATE.
>
> So for each day (time period) I will plot a plot imagine 04/08/2020 (a
> value on TIME_PERIOD) for the values
>
> c(  PY_1Y, PY_2Y,
> PY_3Y, PY_4Y,
> PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM
>
> In excel for me is "easy" but in R I dont know how to proceed can you give
> me some clue to make this king of operations?
>
> If I wanted to do a 3D PloT would be possible? only also for this limited
> values c(  PY_1Y, PY_2Y,
> PY_3Y, PY_4Y,
> PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM
>
> tusDatos$DATA_TYPE_FM,  (will be X axis)
> tusDatos$TIME_PERIOD (Z axis)
> tusDatos$OBS_VALUE (Y Values)
>
> Hope I explained properly and hope you can help and guide.
>
>
>
>  datayield.csv
> <https://drive.google.com/file/d/1WvIIhxXOeg8y_7LssRu0wK9s_c9c03sZ/view?usp=drive_web>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Print and plot a cross Data

Pedro páramo
Hi Jim,

Many thanks for your help, I will try a 2D plot and then pass to 3D.

I am trying something like this:

tus.datos<-read.table("datayield.csv",sep=";",header=TRUE)

data_types<-c("PY_1Y","PY_2Y","PY_3Y","PY_4Y","PY_5Y","PY_6Y","PY_7Y")

row_subset<-tus.datos$DATA_TYPE %in% data_types

x<-tus.datos$DATA_TYPE_FM[row_subset]
y<-tus.datos$OBS_VALUE[row_subset]

PERIOD<-tus.datos$TIME_PERIOD=="01/06/2020"

for (PERIOD="TRUE") {


plot(x, y)

}


And the error is

 for (PERIOD="TRUE") {
Error: inesperado '=' in "for (PERIOD="
>
>
> plot(x, y)
Error: no se puede ubicar un vector de tamaño  1.3 Gb
>
> }
Error: inesperado '}' in "}"
>



El jue., 6 ago. 2020 a las 2:24, Jim Lemon (<[hidden email]>)
escribió:

> Hi Pedro,
> I'm not exactly sure of what you want, but try this:
>
> # I downloaded the CSV file as datayield.csv
> tus.datos<-read.table("datayield.csv",sep=";",header=TRUE)
> library(scatterplot3d)
> data_types<-c("PY_1Y","PY_2Y","PY_3Y","PY_4Y","PY_5Y","PY_6Y","PY_7Y")
> row_subset<-tus.datos$DATA_TYPE %in% data_types
> scatterplot3d(tus.datos$DATA_TYPE_FM[row_subset],
>  tus.datos$OBS_VALUE[row_subset],
>  tus.datos$TIME_PERIOD[row_subset],
>  color=order(as.numeric(tus.datos$DATA_TYPE[row_subset])))
> legend(9,8,data_types,pch=1,col=1:7,xpd=TRUE)
>
> I used a few tricks to get this to work without being too long a
> script. The color for PY_7Y is yellow, and this can be changed with a
> bit of extra code.
>
> Jim
>
> On Thu, Aug 6, 2020 at 8:40 AM Pedro páramo <[hidden email]>
> wrote:
> >
> > Hi all,
> >
> > I have a csv (extracted from a web) I attach the data:
> >
> > I use this code to read the data;
> >
> > library("readr")
> >
> > tusDatos <- read_csv('~/datayield.csv')
> >
> > In this CSV, I want to use three columns:
> >
> >  tusDatos$DATA_TYPE_FM,  (will be X axis)
> > tusDatos$TIME_PERIOD (will be the pivot to search the values)
> > tusDatos$OBS_VALUE (Y Values)
> >
> > In Data_Type_FM I want to plot a graph where only some rows (included in
> > thar colum) will be the X-axis and the Y-axis will be OBS:Value for an
> > specific DATE.
> >
> > So for each day (time period) I will plot a plot imagine 04/08/2020 (a
> > value on TIME_PERIOD) for the values
> >
> > c(  PY_1Y, PY_2Y,
> > PY_3Y, PY_4Y,
> > PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM
> >
> > In excel for me is "easy" but in R I dont know how to proceed can you
> give
> > me some clue to make this king of operations?
> >
> > If I wanted to do a 3D PloT would be possible? only also for this limited
> > values c(  PY_1Y, PY_2Y,
> > PY_3Y, PY_4Y,
> > PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM
> >
> > tusDatos$DATA_TYPE_FM,  (will be X axis)
> > tusDatos$TIME_PERIOD (Z axis)
> > tusDatos$OBS_VALUE (Y Values)
> >
> > Hope I explained properly and hope you can help and guide.
> >
> >
> >
> >  datayield.csv
> > <
> https://drive.google.com/file/d/1WvIIhxXOeg8y_7LssRu0wK9s_c9c03sZ/view?usp=drive_web
> >
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Print and plot a cross Data

Jim Lemon-4
Hi Pedro,
I think the error arises in your "if" statement, should be:

if(PERIOD == TRUE)

or more simply:

if(PERIOD)

Jim

On Thu, Aug 6, 2020 at 11:54 PM Pedro páramo <[hidden email]> wrote:

>
> Hi Jim,
>
> Many thanks for your help, I will try a 2D plot and then pass to 3D.
>
> I am trying something like this:
>
> tus.datos<-read.table("datayield.csv",sep=";",header=TRUE)
>
> data_types<-c("PY_1Y","PY_2Y","PY_3Y","PY_4Y","PY_5Y","PY_6Y","PY_7Y")
>
> row_subset<-tus.datos$DATA_TYPE %in% data_types
>
> x<-tus.datos$DATA_TYPE_FM[row_subset]
> y<-tus.datos$OBS_VALUE[row_subset]
>
> PERIOD<-tus.datos$TIME_PERIOD=="01/06/2020"
>
> for (PERIOD="TRUE") {
>
>
> plot(x, y)
>
> }
>
>
> And the error is
>
>  for (PERIOD="TRUE") {
> Error: inesperado '=' in "for (PERIOD="
> >
> >
> > plot(x, y)
> Error: no se puede ubicar un vector de tamaño  1.3 Gb
> >
> > }
> Error: inesperado '}' in "}"
> >
>
>
>
> El jue., 6 ago. 2020 a las 2:24, Jim Lemon (<[hidden email]>) escribió:
>>
>> Hi Pedro,
>> I'm not exactly sure of what you want, but try this:
>>
>> # I downloaded the CSV file as datayield.csv
>> tus.datos<-read.table("datayield.csv",sep=";",header=TRUE)
>> library(scatterplot3d)
>> data_types<-c("PY_1Y","PY_2Y","PY_3Y","PY_4Y","PY_5Y","PY_6Y","PY_7Y")
>> row_subset<-tus.datos$DATA_TYPE %in% data_types
>> scatterplot3d(tus.datos$DATA_TYPE_FM[row_subset],
>>  tus.datos$OBS_VALUE[row_subset],
>>  tus.datos$TIME_PERIOD[row_subset],
>>  color=order(as.numeric(tus.datos$DATA_TYPE[row_subset])))
>> legend(9,8,data_types,pch=1,col=1:7,xpd=TRUE)
>>
>> I used a few tricks to get this to work without being too long a
>> script. The color for PY_7Y is yellow, and this can be changed with a
>> bit of extra code.
>>
>> Jim
>>
>> On Thu, Aug 6, 2020 at 8:40 AM Pedro páramo <[hidden email]> wrote:
>> >
>> > Hi all,
>> >
>> > I have a csv (extracted from a web) I attach the data:
>> >
>> > I use this code to read the data;
>> >
>> > library("readr")
>> >
>> > tusDatos <- read_csv('~/datayield.csv')
>> >
>> > In this CSV, I want to use three columns:
>> >
>> >  tusDatos$DATA_TYPE_FM,  (will be X axis)
>> > tusDatos$TIME_PERIOD (will be the pivot to search the values)
>> > tusDatos$OBS_VALUE (Y Values)
>> >
>> > In Data_Type_FM I want to plot a graph where only some rows (included in
>> > thar colum) will be the X-axis and the Y-axis will be OBS:Value for an
>> > specific DATE.
>> >
>> > So for each day (time period) I will plot a plot imagine 04/08/2020 (a
>> > value on TIME_PERIOD) for the values
>> >
>> > c(  PY_1Y, PY_2Y,
>> > PY_3Y, PY_4Y,
>> > PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM
>> >
>> > In excel for me is "easy" but in R I dont know how to proceed can you give
>> > me some clue to make this king of operations?
>> >
>> > If I wanted to do a 3D PloT would be possible? only also for this limited
>> > values c(  PY_1Y, PY_2Y,
>> > PY_3Y, PY_4Y,
>> > PY_5Y, PY_6Y, PY_7Y) this values are included on DATA_TYPE_FM
>> >
>> > tusDatos$DATA_TYPE_FM,  (will be X axis)
>> > tusDatos$TIME_PERIOD (Z axis)
>> > tusDatos$OBS_VALUE (Y Values)
>> >
>> > Hope I explained properly and hope you can help and guide.
>> >
>> >
>> >
>> >  datayield.csv
>> > <https://drive.google.com/file/d/1WvIIhxXOeg8y_7LssRu0wK9s_c9c03sZ/view?usp=drive_web>
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Print and plot a cross Data

Jim Lemon-4
Hi Pedro,
Scratch that last email. I remembered that "tus.datos" was so large
that it was hanging my R session last time. However, this seems to
work:

tus.datos<-read.table("datayield.csv",sep=";",
 header=TRUE,stringsAsFactors=FALSE)
row_subset<-tus.datos$DATA_TYPE_FM %in% data_types &
 tus.datos$TIME_PERIOD == "01/06/2020"
x<-tus.datos$DATA_TYPE_FM[row_subset]
y<-as.numeric(tus.datos$OBS_VALUE[row_subset])
# DATA_TYPE_FM is a character variable
# unless you let it be read as a factor (beware, it may hang your R session)
# and use as.numeric() it will not turn out well.
barplot(y,names.arg=x)

Jim

______________________________________________
[hidden email] 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.