Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-19 Thread Ista Zahn
Here is another approach, just for fun: library(tidyverse) library(tokenizers) anyall <- function(x, # a character vector terms # a list of character vectors ){ any(map_lgl(terms, function(term) { all(term %in% x) })) } mutate(th, flag

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-18 Thread Bert Gunter
Sorry. Typo. The last line should be: ans$Result <- apply(ans,1,function(r)phrasewords[[r[1]]] %allin% tweets[[r[2]]]) -- Bert On Thu, Oct 18, 2018 at 7:04 PM Bert Gunter wrote: > All (especially Nathan): **Please feel free to ignore this post without > response.** It just represents a bit

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-18 Thread Bert Gunter
All (especially Nathan): **Please feel free to ignore this post without response.** It just represents a bit of OCD-ness on my part that may or may not be of interest to anyone else. Purpose of this post: To give an alternative considerably simpler and considerably faster solution to the problem t

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-17 Thread Bert Gunter
If you wish to use R, you need to at least understand its basic data structures and functionality. Expecting that mimickry of code in special packages will suffice is, I believe, an illusion. If you haven't already done so, you should go through a basic R tutorial or two (there are many on the web;

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-17 Thread Nathan Parsons
I do not have your command of base r, Bert. That is a herculean effort! Here’s what I spent my night putting together: ## Create search terms ## dput(st) st <- structure(list(word1 = c("technique", "me", "me", "feel", "feel" ), word2 = c("olympic", "abused", "hurt", "hopeless", "alone" ), word3 =

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-16 Thread Bert Gunter
OK, as no one else has offered a solution, I'll take a whack at it. Caveats: This is a brute force attempt using R's basic regular expression engine. It is inelegant and barely tested, so likely to be at best incomplete and buggy, and at worst, incorrect. But maybe Nathan or someone else on the li

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-16 Thread Bert Gunter
The problem wasn't the data tibbles. You posted in html -- which you were explictly warned against -- and that corrupted your text (e.g. some quotes became "smart quotes", which cannot be properly cut and pasted into R). Bert On Tue, Oct 16, 2018 at 2:47 PM Nathan Parsons wrote: > Argh! Here a

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-16 Thread Nathan Parsons
Argh! Here are those two example datasets as data frames (not tibbles). Sorry again. This apparently is just not my day. th <- structure(list(status_id = c("x1047841705729306624", "x1046966595610927105", "x1047094786610552832", "x1046988542818308097", "x1046934493553221632", "x10472274428997754

[R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-16 Thread Nathan Parsons
Thanks all for your patience. Here’s a second go that is perhaps more explicative of what it is I am trying to accomplish (and hopefully in plain text form)... I’m using the following packages: tidyverse, purrr, tidytext I have a number of tweets in the following form: th <- structure(list(st