[R] create new matrix from user-defined function

bcrombie bcrombie at utk.edu
Wed Jul 10 21:18:58 CEST 2013


#Let's say I have the following data set:

dat3 = data.frame(A_CaseID = c(1881, 1882, 1883, 1884, 1885),
                  B_MW_EEsDue1 = c(2, 2, 1, 4, 6),
                  C_MW_EEsDue2 = c(5, 5, 4, 1, 6),
                  D_MW_EEsDueTotal = c(7, 9, 5, 6, 112))
dat3
# A_CaseID B_MW_EEsDue1 C_MW_EEsDue2 D_MW_EEsDueTotal
# 1     1881            2            5                7
# 2     1882            2            5                9
# 3     1883            1            4                5
# 4     1884            4            1                6
# 5     1885            6            6              112

# I want to:
#CREATE A NEW 1-COLUMN MATRIX (of unknown #rows) LISTING ONLY "A"'s WHERE "D
!= B + C"
#THIS COLUMN CAN BE LABELED "MW_EEsDue_ERRORS", and output for this example
should be:

# MW_EEsDue_ERRORS 
# 1 1882
# 2 1884
# 3 1885

#What is the best way to do this?  Thanks for your time.  BNC



--
View this message in context: http://r.789695.n4.nabble.com/create-new-matrix-from-user-defined-function-tp4671250.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list