I would like to apply some function to every row of data in R.
A function can return a single-line data frame or nothing (I think 'return ()' returns nothing?).
I would like to apply this function to each of the rows of a given data frame and get the resulting data frame (which is possibly shorter, that is, has fewer rows than the original).
For example, if the original data framework looks something like this:
id size name
1 100 dave
2 200 sarah
3 50 ben
And the function I use gets the string n in the dataframe (ie, a single-line DataFrame), returns it as it is, if the name rhymes with "brave", otherwise returns null, then the result should be:
id size name
1 100 dave
, , , , (, ) . , ( , $size>100, , , boo(single_row_df).
P.s.
, , - apply(df, MARGIN=1), do.call(rbind ...), , , ( Error in do.call(rbind, filterd) : second argument must be a list)
UPDATE
:
ranges.filter <- function(ranges,boo) {
subset(x=ranges,subset=!any(boo[start:end]))
}
ranges.filter , :
start end
100 200
250 400
698 1520
1988 2147
...
(TRUE,FALSE,TRUE,TRUE,TRUE,...)
, TRUE . , 100 .. 200 , FALSE 100 .. 200.
, , , numerical expression has 53 elements: only the first used.