Re: [R] position of a string in a data frame

2014-04-30 Thread Jim Lemon
How about: testdf<-data.frame(names=c("min","max","sum"),a=1:3,b=4:6,c=c(5,7,9)) which(tolower(as.matrix(testdf)) == "sum",arr.ind=TRUE) row col [1,] 3 1 as.matrix coerces all elements to the lowest (character) mode, no? Does it unclass anything like the example below? Jim On 04/30/2

Re: [R] position of a string in a data frame

2014-04-30 Thread Duncan Murdoch
On 30/04/2014, 8:02 AM, Frede Aakmann Tøgersen wrote: Try > foo <- data.frame(oid = 1:3, functions = c("mean", "sum", "sd"), type = c(TRUE, FALSE, TRUE)) foo oid functions type 1 1 mean TRUE 2 2 sum FALSE 3 3sd TRUE foo == "sum" oid functions type

Re: [R] position of a string in a data frame

2014-04-30 Thread Frede Aakmann Tøgersen
Try > foo <- data.frame(oid = 1:3, functions = c("mean", "sum", "sd"), type = > c(TRUE, FALSE, TRUE)) > foo oid functions type 1 1 mean TRUE 2 2 sum FALSE 3 3sd TRUE > foo == "sum" oid functions type [1,] FALSE FALSE FALSE [2,] FALSE TRUE FALSE [