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
43 views

1 answer to this question.

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 May 24 in Data Analytics by anonymous
1,116 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
16 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
31 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,040 points
293 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
46 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
76 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
80 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
41 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
40 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
187 views