Thanks David. Is there a way of explicitly passing the rowname since I need it in the function.
On Apr 19, 4:19 pm, David Winsemius <dwinsem...@comcast.net> wrote: > On Apr 19, 2011, at 6:59 AM, santosh wrote: > > > > > > > > > > > > > Dear Group, > > > I am doing an apply function on a zoo object. I need the rownames to > > be passed to the function. > > Any suggestions on how to accomplish this? > > > Here is the code I am using > > > tmp <- > > structure(c(611.55, 611.55, 611.55, 611.55, 611.55, 520, 520, > > 520, 520, 520, 425, 425, 425, 432.2, 432.2, 337, 338, 328.95, > > 328.95, 328.95, 243.8, 242.775, 238.5, 239, 235.925, 161.7, 156.625, > > 152.825, 151.95, 151.9, 1.5, 1.5, 1.5, 1.5, 1.5, 2, 2.15, 2.15, > > 2, 2, 3, 2.95, 3.175, 3.2, 3.15, 6, 6.15, 6.525, 6.6, 6.6, 14.5, > > 14.5, 15.15, 15.45, 15.3, 32.05, 32.05, 33.09, 33.8, 33.23), .Dim = > > c(5L, > > 12L), .Dimnames = list(c("2011-04-19 09:24:30", "2011-04-19 > > 09:25:00", > > "2011-04-19 09:25:30", "2011-04-19 09:26:00", "2011-04-19 09:26:30" > > ), c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L" > > )), index = > > structure(c(1303185270begin_of_the_skype_highlighting 1303185270 end_of_the_skype_highlighting,1303185300begin_of_the_skype_highlighting 1303185300 end_of_the_skype_highlighting,1303185330begin_of_the_skype_highlighting 1303185330 end_of_the_skype_highlighting, > >1303185360begin_of_the_skype_highlighting 1303185360 end_of_the_skype_highlighting, > >1303185390begin_of_the_skype_highlighting 1303185390 end_of_the_skype_highlighting), > > class = c("POSIXt", "POSIXct"), tzone = ""), class = > > "zoo") > > >> tmp > > A B C D E F G H I J K > > L > > 2011-04-19 09:24:30 612 520 425 337 244 162 1.5 2.00 3.00 6.00 14.5 > > 32.0 > > snipped > > >> apply(tmp,1,function(x)(print (rownames(x)))) > > NULL > > NULL > snipped > >> #How can I get the rownames here instead? > > > rownames(tmp) > [1] "2011-04-19 09:24:30" "2011-04-19 09:25:00" > [3] "2011-04-19 09:25:30" "2011-04-19 09:26:00" > [5] "2011-04-19 09:26:30" > > (apply() removes the rownames before passing rows on to functions, ... > since they are no longer rows but rather vectors at that point.) > > -- > David Winsemius, MD > West Hartford, CT > > ______________________________________________ > r-h...@r-project.org mailing listhttps://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. ______________________________________________ R-help@r-project.org mailing list 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.