It will be a lot easier to help you if you follow the posting guide and PLEASE
do read the posting guide and provide commented, minimal, self-contained,
reproducible code.
You gave your function definition, which is good. Use ?dput to give us a small
data.frame that can accurately show what you want.
harsh yadav wrote:
Hi all,
I have a data frame for which I want to limit the output by checking whether
row values for specific column meets particular conditions.
Here are the more specific details:
I have a function that checks whether an input string exists in a defined
list:-
checkBaseLine <- function(s){
for (listItem in WHITELIST){
if(regexpr(as.character(listItem), s)[1] > -1){
return(TRUE)
}
}
return(FALSE)
}
Now, I have a data frame for which I want to apply the above function for
all row values for a given column:-
This works fine when I define a condition like:
data <- data[data$urlType != 1,]
However, I want to combine two logical conditions together like:
data <- data[data$urlType != 1 & checkBaseLine(data$url),]
This would check whether the column `urlType` contains row values that !=
1,
and the column `url` contains row values that gets evaluated using the
defined function.
Any ideas how this can be done?
Thanks in advance.
Regards,
Harsh Yadav
[[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.
______________________________________________
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.