Tokenizing text file generates error using word tokenize_words

0 votes

library(tokenizers)
library(SnowballC)

my_data <- read.delim("Shakespeare.txt")

tokenize_words(my_data$ACT.I

I am trying to run this code but getting the following error 

 Error in check_input(x) : 
  Input must be a character vector of any length or a list of character
  vectors, each of which has a length of 1.

Can you help me with this, please?

Aug 27, 2018 in Data Analytics by Anmol
• 1,620 points
28 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hi Bolder,

As you are using the delim function to read the file it would generate factors which cant be used as an input to the tokenizer.

Try 

text_df<-tokenize_words(as.character(my_data))

Hope this helps

answered Aug 27, 2018 by ANMOL
• 3,620 points

Related Questions In Data Analytics

0 votes
2 answers

How to write lines to a text file in R?

sink("outfile.txt") cat("hello") cat("\n" ...READ MORE

answered 1 day ago in Data Analytics by anonymous
560 views
0 votes
1 answer

How to prevent row names to be written to a file while using

Easily by: write.csv(df, "temp.csv", row.names=FALSE) READ MORE

answered Apr 20, 2018 in Data Analytics by DeepCoder786
• 1,700 points
13 views
0 votes
1 answer

How to import text file as a single character string?

First way: rd<-readChar("temp.txt",file.info("temp.txt")$size) ...READ MORE

answered Apr 23, 2018 in Data Analytics by DeepCoder786
• 1,700 points
26 views
0 votes
1 answer

Error saying cannot open file 'file.pdf' when trying to save a plot in ggplot

You could try adding the following line ...READ MORE

answered Nov 9, 2018 in Data Analytics by Maverick
• 10,000 points
195 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
29 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
39 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
65 views
0 votes
1 answer

Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,550 points
29 views
0 votes
1 answer

How can I perform word stemming in R

The tm package in R provides the stemDocument() function to stem the ...READ MORE

answered Aug 20, 2018 in Data Analytics by ANMOL
• 3,620 points
35 views
0 votes
1 answer

Python or R – Which one would you prefer for text analytics?

We will prefer Python because of the ...READ MORE

answered Aug 20, 2018 in Data Analytics by ANMOL
• 3,620 points
136 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.