Hi,
I am reading payment data like so
2010-01-01,100.00
2010-01-04,100.00
...
2011-01-01,200.00
2011-01-07,100.00
and plot it aggregated per month like so
library(zoo)
df <- read.csv("daily.csv",
colClasses=c(d="Date",s="numeric"))
z <- zoo(df$s, df$d)
z.mo <- aggregate(z, as.yearmon, sum)
barplot(z.mo, col="darkblue")
How do I get the monthly aggregated payments in different colors
next to each other (ie for each year in a different color with the x
axis showing the months)?
Solution preferred, but pointers to documentation welcome :-)-O
greetings, el
--
Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist (Saar)
el at lisse.NA el108-ARIN / * | Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ / Please do NOT email to this address
Bachbrecht, Namibia ;____/ if it is DNS related in ANY way
Hi,
I am reading payment data like so
2010-01-01,100.00
2010-01-04,100.00
...
2011-01-01,200.00
2011-01-07,100.00
and plot it aggregated per month like so
library(zoo)
df <- read.csv("daily.csv",
colClasses=c(d="Date",s="numeric"))
z <- zoo(df$s, df$d)
z.mo <- aggregate(z, as.yearmon, sum)
barplot(z.mo, col="darkblue")
How do I get the monthly aggregated payments in different colors
next to each other (ie for each year in a different color with the x
axis showing the months)?
Solution preferred, but pointers to documentation welcome :-)-O
greetings, el
--
Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist (Saar)
el at lisse.NA el108-ARIN / * | Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ / Please do NOT email to this address
Bachbrecht, Namibia ;____/ if it is DNS related in ANY way
Hi> > Hi, > > I am reading payment data like so > > 2010-01-01,100.00 > 2010-01-04,100.00 > ... > 2011-01-01,200.00 > 2011-01-07,100.00 > > and plot it aggregated per month like so > > library(zoo) > df <- read.csv("daily.csv", colClasses=c(d="Date",s="numeric")) > z <- zoo(df$s, df$d) > z.mo <- aggregate(z, as.yearmon, sum) > barplot(z.mo, col="darkblue") > > How do I get the monthly aggregated payments in different colors > next to each other (ie for each year in a different color with the x > axis showing the months)?What about putting suitable set of colours to col argument? Regards Petr> > Solution preferred, but pointers to documentation welcome :-)-O > > greetings, el > -- > Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist (Saar) > el at lisse.NA el108-ARIN / * | Telephone: +264 81 124 6733 (cell) > PO Box 8421 \ / Please do NOT email to this address > Bachbrecht, Namibia ;____/ if it is DNS related in ANY way > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Petr, Maybe I did not make it clear, I apologize for that: I want January to December on the X Axis (as 12 discrete (months)) and then for each month the values for each year as bars in different colors next to each other, ie Jan-2009, Jan-2011, Jan-2011...Dec-2009, Dec-2011, Dec-2011 whereas at the moment I get Jan-2009, Feb-2009, Mar-2009...Oct-2011, Nov-2011, Dec-2011 In SQL something like GROUP BY MONTH, YEAR as opposed to GROUP BY YEAR, MONTH. greetings, el on 2011-07-07 11:08 Petr PIKAL said the following: [...]>> How do I get the monthly aggregated payments in different colors >> next to each other (ie for each year in a different color with the x >> axis showing the months)? > > What about putting suitable set of colours to col argument? > > Regards > Petr[...] -- Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist (Saar) el at lisse.NA el108-ARIN / * | Telephone: +264 81 124 6733 (cell) PO Box 8421 \ / Please do NOT email to this address Bachbrecht, Namibia ;____/ if it is DNS related in ANY way
OK> Petr, > > Maybe I did not make it clear, I apologize for that: > > I want January to December on the X Axis (as 12 discrete (months)) > and then for each month the values for each year as bars in > different colors next to each other, ie Jan-2009, Jan-2011, > Jan-2011...Dec-2009, Dec-2011, Dec-2011 whereas at the moment I get > Jan-2009, Feb-2009, Mar-2009...Oct-2011, Nov-2011, Dec-2011Well you can look at examples of barplot, especially this one barplot(VADeaths, beside = TRUE, col = c("lightblue", "mistyrose", "lightcyan", "lavender", "cornsilk"), legend = rownames(VADeaths), ylim = c(0, 100)) title(main = "Death Rates in Virginia", font.main = 4) If you look at VADeaths structure you see you need some structured data x<-seq(as.Date("2000/1/1"), by="month", length.out=24) x.m<-aggregate(1:24, list(format(x, "%m"), format(x, "%Y")), sum) x.m Group.1 Group.2 x 1 01 2000 1 2 02 2000 2 3 03 2000 3 4 04 2000 4 5 05 2000 5 <snip> and you can use e.g. xtabs or maybe cast from reshape package x.xt<-xtabs(x~Group.1+Group.2,x.m) barplot(x.xt, beside=TRUE, col=rainbow(12)) x.xt<-xtabs(x~Group.2+Group.1,x.m) barplot(x.xt, beside=T, col=1:2) Or you could look at ggplot2 package. Regards Petr> > In SQL something like GROUP BY MONTH, YEAR as opposed to GROUP BY > YEAR, MONTH. > > greetings, el > > on 2011-07-07 11:08 Petr PIKAL said the following: > [...] > >> How do I get the monthly aggregated payments in different colors > >> next to each other (ie for each year in a different color with the x > >> axis showing the months)? > > > > What about putting suitable set of colours to col argument? > > > > Regards > > Petr > [...] > > -- > Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist (Saar) > el at lisse.NA el108-ARIN / * | Telephone: +264 81 124 6733 (cell) > PO Box 8421 \ / Please do NOT email to this address > Bachbrecht, Namibia ;____/ if it is DNS related in ANY way
I am looking for the implementation of sparse kernel regression
approach e.g. as in this paper:
The Generalized LASSO. Volker Roth
IEEE Transactions on Neural Networks, Vol. 15, NO. 1, January 2004.
I would appreciate any pointers.
Best regards,
Ryszard
--------------------------------------------------------------------------
Confidentiality Notice: This message is private and may ...{{dropped:8}}
On Thu, Jul 7, 2011 at 5:41 AM, Dr Eberhard Lisse <el at lisse.na> wrote:> Hi, > > I am reading payment data like so > > 2010-01-01,100.00 > 2010-01-04,100.00 > ... > 2011-01-01,200.00 > 2011-01-07,100.00 > > and plot it aggregated per month like so > > library(zoo) > df <- read.csv("daily.csv", colClasses=c(d="Date",s="numeric")) > z <- zoo(df$s, df$d) > z.mo <- aggregate(z, as.yearmon, sum) > barplot(z.mo, col="darkblue") > > How do I get the monthly aggregated payments in different colors > next to each other (ie for each year in a different color with the x > axis showing the months)? >Read it in with read.zoo aggregating at the same time to yearmon class and then issue the appropriate lattice barchart command: Lines <- "Date,Value 2010-01-01,100.00 2010-01-04,100.00 2010-02-04,100.00 2011-01-01,200.00 2011-01-07,100.00 2011-02-07,100.00" library(zoo) z <- read.zoo(textConnection(Lines), header = TRUE, sep = ",", FUN = as.yearmon, aggregate = sum) library(lattice) year <- factor(as.numeric(floor(time(z)))) value <- coredata(z) month <- coredata(cycle(z)) barchart(value ~ month | year, horiz = FALSE, col = 1:12, origin = 0) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Dr Eberhard Lisse <el at lisse.na> wrote:
> Hi,
>
> I am reading payment data like so
>
> 2010-01-01,100.00
> 2010-01-04,100.00
> ...
> 2011-01-01,200.00
> 2011-01-07,100.00
>
> and plot it aggregated per month like so
>
> library(zoo)
> df <- read.csv("daily.csv",
colClasses=c(d="Date",s="numeric"))
> z <- zoo(df$s, df$d)
> z.mo <- aggregate(z, as.yearmon, sum)
> barplot(z.mo, col="darkblue")
>
> How do I get the monthly aggregated payments in different colors
> next to each other (ie for each year in a different color with the x
> axis showing the months)?
Hi Dr Eberhard Lisse,
You might also be interested in barp:
paybymonth<-matrix(sample(100:200,120,TRUE),nrow=10)
rownames(paybymonth)<-2000:2009
colnames(paybymonth<-month.abb
library(plotrix)
barp(paybymonth,names.arg=colnames(paybymonth),col=rainbow(10),
ylim=c(0,250),main="Payments by month from 2000-2009")
par(xpd=TRUE)
legend(13,180,2000:2009,fill=rainbow(10))
par(xpd=FALSE)
Jim