[R] reading row title
arun
smartpink111 at yahoo.com
Wed Mar 19 20:04:29 CET 2014
Hi,
dat <- read.table(text="Date A B C D
1-Jan-61 0.00 1.27 8.128 0.25
2-Jan-61 6.10 9.144 94.742 15.49
3-Jan-61 0.00 0.508 1.27 0.00
4-Jan-61 0.00 0 NA 0.00
5-Jan-61 0.00 0 0 0.00
6-Jan-61 0.00 NA 0 0.00
7-Jan-61 0.00 0 0 0.00
8-Jan-61 0.00 NA 0 0.00
9-Jan-61 0.00 NA 0 NA
10-Jan-61 0.00 4.064 4.826 0.76",sep="",header=TRUE,stringsAsFactors=FALSE)
res <- as.data.frame(apply(dat[,-1],2,FUN=function(x) {x1 <-dat[,1][is.na(x)]; x2 <- max(colSums(is.na(dat[,-1]))); if(length(x1) < x2) c(x1, rep("",x2-length(x1))) else x1}),stringsAsFactors=FALSE)
A.K.
On Wednesday, March 19, 2014 2:39 PM, eliza botto <eliza_botto at hotmail.com> wrote:
Dear R-Family,
I have a data-set of the following format. I am only presenting a part of it.
Date A B C D
1-Jan-61
0.00
1.27
8.128
0.25
2-Jan-61
6.10
9.144
94.742
15.49
3-Jan-61
0.00
0.508
1.27
0.00
4-Jan-61
0.00
0
NA
0.00
5-Jan-61
0.00
0
0
0.00
6-Jan-61
0.00
NA
0
0.00
7-Jan-61
0.00
0
0
0.00
8-Jan-61
0.00
NA
0
0.00
9-Jan-61
0.00
NA
0
NA
10-Jan-61
0.00
4.064
4.826
0.76
You can see that each column has some NAs in it, What i want to do is to learn that which date has NA for each column.
Here it should be something like the following
A B C D
6-Jan-61 4-Jan-61 9-Jan-61
8-Jan-61
9-Jan-61
Thankyou very much in advance
Eliza
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
More information about the R-help
mailing list