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

  • SEARCH
  • Home
  • 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 8128477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:53:47+00:00 2026-06-06T07:53:47+00:00

I am using RTextTools to build a training set with a matrix and a

  • 0

I am using RTextTools to build a training set with a matrix and a model which I will later apply to different documents to classify them.

EDIT: The matrix is a Document Term Matrix

The problem I am having is that sometimes with certain documents when I create the new_matrix with the following line

new_matrix <- create_matrix(data$document,language="english", removeNumbers=FALSE, removePunctuation=TRUE, removeStopwords=TRUE, toLower=TRUE, stemWords=TRUE, minDocFreq=1,weighting=weightTfIdf,originalMatrix=matrix)

I get some NaN values which make my corpus fail

corpus <- create_corpus(new_matrix,data$value, testSize=1:100,virgin=FALSE)

With the error

Error in .csr.coo(x) : NA/NaN/Inf in foreign function call (arg 4)

I am not sure why there are some NaN values. My guess is that it has to do with some words being present on the new_matrix and not on the original matrix.

How can I change NaN values for a 0 in the resulting matrix?

Will doing that alter the result of the classification?

Any help much appreciated! Thanks!

  • 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-06-06T07:53:51+00:00Added an answer on June 6, 2026 at 7:53 am

    Simple way to find NaN values by using is.na():

    data<-c(1,2,NaN,4,2)
    data[is.na(data)]<-0
    data
    

    [1] 1 2 0 4 2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using RTextTools to train and classify data which comes from a MySQL
Using MVC2 I have an AJAX form which is posting to a bound model.
Using Nunit, I want to be able to write a test fixture that will
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using Delphi 2010. I am looking for (possibly) a function or procedure which can
Using PyGtk's IconView, I can set the icons to be reorderable by calling gtk.IconView.set_reorderable(True)
Using MVVM. I have a DataTemplate which I am using to display an expander
Using the opencart image manager how would I set the upload to automatically remove:
Using JDeveloper , I started developing a set of web pages for a project
Using Windows, Mercurial, and the extdiff extension (for Mercurial). I was trying to set

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.