Dear Gregg,
Take a look at ?duplicates. Here is an example:
z<-data.frame(
ID=c(1,1,2,1,1,1,1,2,2,3,4,3,2,2,2,2,3,4,4,5,5,6,6,7),
y=rnorm(24)
)
z[!duplicated(z$ID),]
See ?duplicated for more information.
HTH,
Jorge
On Sun, Jan 18, 2009 at 11:27 PM, <GreggAllen@gmail.com> wrote:
> Thanks to everyone who helped me when I was totally clueless. Now I'm
only
> partially clueless, and in writing functions, which is major progress.
>
>
> This is a function that is a major improvement over which I was using MS
> Excel for:
>
> function()
> {
> files <- list.files(pattern="ABN*") # All the models start
with the letters
> ABN
> for( i in 1:length(files)) # loop through the files.
> {
> f <- files[i] # temporary variable
> load(f) # Put the "abnmodel" object in this workspace
> z <- predict(abnmodel, abndata) # use my student's data, and their
various
> models to predict with new data.
> write(z, "output.txt", ncolumns = 11, append = TRUE,
sep="\t") # Write the
> output to a file for import into Excel.
> }
> }
>
> This works great for PREPARING data for Excel, but I would rather not use
> Excel.
>
> The problem is that between the lines "Z <- predict" and
"write(z, " I need
> some more code, but I can't get it to work.
>
> At the end of this function, I typically have 3,00 to 12,000 rows of data,
> in which 10% to 33% are duplicates. I need to put the value z into
> temporary storage, sort by the first column (if the first columns are
> equal, the entire vector is an unwanted duplicate) test for equality, and
> for each duplicate keep one, and discard the other(s).
>
> Thanks for any help!
>
> Gregg Allen
> Not affiliated with any respectable organization.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]]