The purpose of this report is to demonstrate basic exploration of text data and readiness to build a prediction model.
# Simple sample text data
sample_data <- c(
"This is a simple example sentence",
"Text mining is useful for prediction",
"This project explores basic text data"
)
# Number of lines
num_lines <- length(sample_data)
# Number of words (SAFE METHOD)
num_words <- sum(sapply(sample_data, function(x) {
length(strsplit(x, " ")[[1]])
}))
# Summary table
data_summary <- data.frame(
Lines = num_lines,
Words = num_words
)
data_summary
## Lines Words
## 1 3 18