PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, September 16, 2022

[FIXED] How can I hide messages in R markdown when "message=FALSE" doesn't work

 September 16, 2022     printing, r, r-markdown, text2vec     No comments   

Issue

I am using R Markdown and text2vec and would like to suppress the messages that come from running the function glove$fit_transform(). I've tried message=FALSE and warning=FALSE, as well as a number hacky attempts to fixing the problem, but to no avail. I would be so, so grateful for your thoughts on this problem.

library(gutenbergr)
library(tidyverse)
library(text2vec)

h_g_wells <- gutenberg_download(35)

h_g_wells <- h_g_wells %>%
  sample_n(20)

vocab_list = list(h_g_wells$text)

it = itoken(vocab_list, progressbar = FALSE)

vocab = create_vocabulary(it)

vocab = prune_vocabulary(vocab, term_count_min = 1)

vectorizer = vocab_vectorizer(vocab)

tcm = create_tcm(it, vectorizer, skip_grams_window = 5)

glove = GlobalVectors$new(rank = 4, x_max = 100)
    
wv_main = glove$fit_transform(tcm, n_iter = 1000, convergence_tol = 0.00000001, n_threads = 24)

Thanks so much for your help.


Solution

I don't know this function. Perhaps it triggers a cat. I would try to use this function:

quiet <- function(x) {
  sink(tempfile())
  on.exit(sink())
  invisible(force(x))
}

like this:

quiet(glove$fit_transform(tcm, n_iter = 1000, ......))


Answered By - Stéphane Laurent
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing