Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7497029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:53:57+00:00 2026-05-29T18:53:57+00:00

EDIT: This was an issue with objects in the workspace conflicting and causing unexpected

  • 0

EDIT: This was an issue with objects in the workspace conflicting and causing unexpected behavior.

I am trying to create a DocumentTermMatrix from a document using the following code. The document contains many 1 and 2-character tokens. However, even when the minimum word length is set to 1 character, the resulting matrix contains 699 documents and 0 terms.

library(tm)
data <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.data",header=FALSE)
data <- data[-1]

training_data <- as.vector(apply(as.matrix(data, mode="character"),1,paste,collapse=" "))
corpus <- Corpus(VectorSource(training_data))

matrix <- DocumentTermMatrix(corpus,control=list(wordLengths=c(1,Inf)))

Can anyone shed some light as to why no tokens are created despite there being many 1 and 2 character tokens in the data? Here is one sample data entry:

" 4  8  8  5  4 5 10  4  1 4"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:54:01+00:00Added an answer on May 29, 2026 at 6:54 pm

    I ran exactly what you gave me in the latest version of R and tm on a windows 7 machine and produced the results you were looking for(see below). I’d try clearing your workspace, exiting R and/or rebooting.

    > library(tm)
    > data <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.data",header=FALSE)
    > data <- data[-1]
    > 
    > training_data <- as.vector(apply(as.matrix(data, mode="character"),1,paste,collapse=" "))
    > corpus <- Corpus(VectorSource(training_data))
    > 
    > matrix <- DocumentTermMatrix(corpus,control=list(wordLengths=c(1,Inf)))
    > matrix
    A document-term matrix (699 documents, 11 terms)
    
    Non-/sparse entries: 2899/4790
    Sparsity           : 62%
    Maximal term length: 2 
    Weighting          : term frequency (tf)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue while trying to parse an Xml to Objects using Linq
EDIT: This issue is already submitted on Github. Changing the Act part to this
(EDIT: This question is now outdated for my particular issue, as Google Code supports
Edit: closing anchor fixed. This issue exists when testing on the following browsers: Google
I am a Cake PHP novice. I want to edit the table Issue. This
EDIT: The issue underneath is fixed, GO TO EDIT2 in this post. I have
I am using this adobe example under reading and writing objects to try and
I'm currently getting this error from an InvalidCastException [A]System.Data.Objects.ObjectResult`1[EDMXAssembly.ServiceStatus] cannot be cast to [B]System.Data.Objects.ObjectResult`1[EDMXAssembly.ServiceStatus].
I'm having an issue when working with javascript date objects, specifically, when trying to
Edit: This question was written in 2008, which was like 3 internet ages ago.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.