Is this what you want? > dat <- read.table("http://dpaste.com/88988/plain/", comment.char="", header = TRUE) > names(dat) [1] "X.ID" "VALUE" "FREQUENCY" > subset(dat, X.ID %in% 0:2 & !duplicated(X.ID)) X.ID VALUE FREQUENCY 1 0 0.00 3 32 1 0.67 1 65 2 1.70 1
Bill Venables http://www.cmis.csiro.au/bill.venables/ -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gundala Viswanath Sent: Thursday, 3 September 2009 4:44 PM To: r-h...@stat.math.ethz.ch Subject: [R] Subsetting Data Frame based On Specified K Value I have a data that looks like this: http://dpaste.com/88988/plain/ How can I extract/subset the data frame based on selected uniq ID. Let's say I want the first K uniq ID. I want to be able to specify the parameter "K" here, (i.e. given K=3, we hope to extract dat$V2 = 0,1,2). I'm stuck with this construct: dat <- read.table("http://dpaste.com/88988/plain/") dats <- subset(dat, V2 = ....) - G.V. ______________________________________________ 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. ______________________________________________ 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.