Suji, # Here is your data ("test").
test <- structure(list(Chr = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "chr2", class = "factor"), start = c(9896633L, 9896639L, 14314039L, 14404467L, 14421718L, 16031710L, 16036178L, 16048665L, 37491676L, 37702947L), end = c(9896683L, 9896690L, 14314098L, 14404502L, 14421777L, 16031769L, 16036237L, 16048724L, 37491735L, 37703009L), sample1 = c(0, 0, 0, 0, -0.43, -0.43, -0.43, -0.43, 0, 0), sample2 = c(0, 0, -0.35, -0.35, -0.35, -0.35, -0.35, -0.35, 0, 0)), .Names = c("Chr", "start", "end", "sample1", "sample2"), class = "data.frame", row.names = c(NA, -10L)) # Here is where you will likely want to start (but there are many ways to skin a cat). test2 <- data.frame(c(rle(test[,4])[[2]], rle(test[,5])[[2]]), c(rle(test[,4])[[1]], rle(test[,5])[[1]])) names(test2) <- c("Values", "Probes") > test2 Values Probes 1 0.00 4 2 -0.43 4 3 0.00 2 4 0.00 2 5 -0.35 6 6 0.00 2 # Obviously this is not exactly what you wanted, only the last 2 columns. Obviously, the tricky part remains... but I hope this helps. ########################################## B77S wrote: > > If your data is named 'test_file' > > then use dput(test_file) > > You can copy and paste the results here so people can more easily try and > help you. > > see > ?dput > > > > > sujitha wrote: >> >> Hi group, >> I am trying to right a code to do the following >> This is how the test file looks like: >> Chr start end sample1 sample2 >> chr2 9896633 9896683 0 0 >> chr2 9896639 9896690 0 0 >> chr2 14314039 14314098 0 -0.35 >> chr2 14404467 14404502 0 -0.35 >> chr2 14421718 14421777 -0.43 -0.35 >> chr2 16031710 16031769 -0.43 -0.35 >> chr2 16036178 16036237 -0.43 -0.35 >> chr2 16048665 16048724 -0.43 -0.35 >> chr2 37491676 37491735 0 0 >> chr2 37702947 37703009 0 0 >> >> Now I want to summarize the values like >> Sample Chr Start End Values Probes >> 1 chr2 9896633 14404502 0 4 >> 1 chr2 14421718 16048724 -0.43 4 >> 1 chr2 37491676 37703001 0 2 >> 2 chr2 9896633 9896690 0 2 >> 2 chr2 14314039 16048724 -0.35 6 >> 2 chr2 37491676 37703009 0 2 >> >> Here the start for the first line would be the least value until values >> are similiar (4) then the end would be highest value. The values is the >> unique value among the common values. >> Can I get some ideas or suggestions to perform this because I am new to >> hard core program in R? >> waiting for your suggestions, >> Thanks, >> suji >> > -- View this message in context: http://r.789695.n4.nabble.com/R-functions-tp3816748p3817431.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.