Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syllable_sum error message: Subset out of bounds #262

Open
schaubst opened this issue Jun 20, 2021 · 1 comment
Open

syllable_sum error message: Subset out of bounds #262

schaubst opened this issue Jun 20, 2021 · 1 comment

Comments

@schaubst
Copy link

Dear all,

I would like to use qdap::syllable_sum to count the syllables in a large dataset (>450.000 rows). The text data whose syllables I want to count are stored in the column of a tibble. I want to count the syllables for each row and store the sum in a separate column.

Syllable_sum works fine with expected input, but throws an error message when it encounters unexpected input, e.g. "____" or "12345". Instead of storing an NA value and moving on, the process stops and prints the error message "Subset out of bounds".

Is there a way to force the function to spit out an NA for those rows where the function cannot produce a syllable sum?

Here's a reproducible example with some 'good' and 'bad' input. I would like the function to create a new column syls_y with the sums (3 and 4) for the first two rows, and NA for the last three.

Thank you in advance for your tips!

`

qdap syllable separation reprex

Load packages

library(tidyverse)
library(qdap)

Create data frame

data <- tibble(
x = 1:5,
y = c("A few words", "a few more words", "____", "1235", "+#$")
)

Syllable separation of each row in data$y

data_syls = data %>%
mutate(syls_y = qdap::syllable_sum(data$y))`

@schaubst
Copy link
Author

I still need help with this. Any tipp, recommendation or response would be greatly appreciated. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant