Re: [R] Check results between two data.frame

2012-03-21 Thread Sarah Goslee
On Wed, Mar 21, 2012 at 12:48 PM, HJ YAN wrote: > Thanks a lot Sarah, for your nice example and code. > > I know '==' can do the work.  Just as a R beginer, sometimes really want to > be more like a 'real programmer', if you know what I mean... Being a "real programmer" means using one line of co

Re: [R] Check results between two data.frame

2012-03-21 Thread Sarah Goslee
As long as == is an appropriate test for your data, why not just use R's innate ability to handle matrices/data frames? > x1 <- matrix(1:20, ncol=4) > x2 <- ifelse(x1 > 18, 22, x1) > x1 [,1] [,2] [,3] [,4] [1,]16 11 16 [2,]27 12 17 [3,]38 13 18 [4,]4

[R] Check results between two data.frame

2012-03-21 Thread HJ YAN
Dear R-user, I'm trying to compare two sets of results and wanted to find out which element in the two data frame/matrix are different. I wrote the following function and it works ok, and gives me a long list of "good" as outcomes. CHECK<- function (x = "file1", y = "file2") { for (i in 1:n