0

I'm having problems using unnest_tokens on a particular dataset.

I've tried using non-standard evaluation, i.e. unnest_tokens_, to pull the column from the dataframe. However this feature is now deprecated.

I've subset the singular column I want to work with, transformed to a tibble and have added a column name.

unnestedSymptoms <- TidySymptoms %>% 
unnest_tokens(word, Text) 

However this is throwing the following error:

Error in UseMethod("pull") : no applicable method for 'pull' applied to an object of class "character">

As I'm not directly calling pull() I don't know where to go from here. Any help appreciated

Output from Subset Dataframe, one column:

structure(c("Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Slight fever the day of the injections. The next night he Stopped breathing in the middle of the night twice. Temperature was 96 degrees Fahrenheit when arriving at the emergency room.", "Abnormal eye movements (multiple an hour) the following day (12/19). He was taken to local emergency room and admitted to neurology for continuous video EEG, sedated for brain MRI, ophthalmology exam. All tests were normal, but movements have continued. He saw ophthalmology for a dilated exam today, 1/6/2020, and they referred us to neuro ophthalmology.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Pt showed at the ER on 12/25/2020 after falling mid walk. Pt left hand was rhythmically opening and closing. Head was twitching and left arm and left leg twitching-sx lasted 10min. Fever of 103 documented by EMS, vaccines 1 wk prior to the ER visit. Sx resolved 2 hrs after seizure. Diagnosed with ? atypical febrile seizure. Patient then sent to Center where he had an EEG and neurology consult. Dx with complex febrile seizure- had felt possible febrile seizure vs epilepsy vs genetic predisposition secondary to TMPRSS3 genetic mutation.", "Throat closing, palpitation, lightheadedness, cough with bronchospasm" ), .Names = c("Text", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA))

# Remove NA
AllData21NAGONE <- na.omit(AllData21)
AllData21NAGONE_tbl <- AllData21NAGONE %>% as_tibble(AllData21NAGONE)

# Subset Col to work with
TidySymptoms <- AllData21NAGONE_tbl$SYMPTOM_TEXT 
# Add column names
names(TidySymptoms) <- c("Text")
Magnetar
  • 85
  • 8
  • 1
    Can you share a sample of your data with dput() ? – Vinícius Félix Aug 23 '21 at 15:06
  • I've added sample with dput(), can see colnames at bottom have only appended to first row?? – Magnetar Aug 23 '21 at 15:16
  • 2
    PLease don't share this as screenshot, but paste the content from dput... to your question. – deschen Aug 23 '21 at 15:17
  • 1
    Without all of the information, I'm pretty sure it's because you have a vector - I know it says it works with a vector - that being said, try a one-column data frame... I was able to duplicate your error when I used a vector. – Kat Aug 23 '21 at 15:26
  • Converted to dataframe and it worked!! Thank you, I thought it had to be a tibble for unnest_tokens. Super – Magnetar Aug 23 '21 at 15:41

0 Answers0