‘qdap’ — Packag for quantitative text analysis in R
1 min readJul 7, 2021
df <- "Have you ever wondered? {wondered} maybe.. [about] (what)"
Let’s see:
bracketXtract(df) all1 all2 all3
"wondered" "about" "what"
How about,
bracketXtract(df, bracket = "round")round
"what"
or,
> bracketXtract(j, bracket = "curly") curly
"wondered"
Not the curly one though…
> bracketXtract(j, bracket = c("square","round"))[[1]]
[1] "about" "what"
one more thing…
df <- data.frame(yeeees=1:5)df$fun <- c("Have you ever (seen)",
"such a beautiful [world]?",
"no, no, no, have you? {maybe}",
"don't call me maybe, [ok baby]",
"I call you (my) never seen [hubby]")
df$fun <- bracketXtract(df$fun, 'all')
df
yes, it is so:
yeeees fun
1 1 seen
2 2 world
3 3 maybe
4 4 ok baby
5 5 my, hubby
now then,,,
> df <- data.frame(yeeees=1:5)> df$fun <- c("Have you ever (seen)",
+ "such a beautiful [world]?",
+ "no, no, no, have you? {maybe}",
+ "don't call me maybe, [ok baby]",
+ "I call you (my) never seen [hubby]")
>
> df$fun <- bracketXtract(df$fun, 'curly')> df
yeeees fun
1 1
2 2
3 3 maybe
4 4
5 5
No kidding, curly and round this time..
> df <- data.frame(yeeees=1:5)
> df$fun <- c("Have you ever (seen)",
+ "such a beautiful [world]?",
+ "no, no, no, have you? {maybe}",
+ "don't call me maybe, [ok baby]",
+ "I call you (my) never seen [hubby]")
>
> df$fun <- bracketXtract(df$fun, c('curly', 'round'))
> df
yeeees fun
1 1 seen
2 2
3 3 maybe
4 4
5 5 my
happy ‘qdap’ ing…