[R] using inspect with a TermDocumentMatrix to convert to a data frame

Erin Hodgess
2014-12-05T14:03:13Z

Great!

Thank you!


On Fri, Dec 5, 2014 at 12:48 AM, Wush Wu <wush978 at gmail.com> wrote:

> Dear Erin,
>
> For the issue of printing big data.frame, you could define a customized
> `print.data.frame` in the user environment
>
> to prevent R prints all the data. For example:
>
> ```r
> print.data.frame <- function(df) {
>   base::print.data.frame(head(df))
>   cat("===\n")
>   base::print.data.frame(tail(df))
> }
> ```
>
> Hope that helps.
>
> Regards,
> Wush
>
>
> 2014-12-05 11:53 GMT+08:00 Erin Hodgess <erinm.hodgess at gmail.com>:
>
>> Hello!
>>
>> I am working through the "Social Media Mining with R" book
and I have
>> something that is a bit problematic.
>>
>> Here is the code:
>>
>>  hash2_tdm <- TermDocumentMatrix(hash2_corpus)
>>        print(hash2_tdm)
>>        print(findFreqTerms(hash2_tdm,lowfreq=10))
>>        hash3_tdm <- removeSparseTerms(hash2_tdm,0.92)
>>
>>        hash3.df <- as.data.frame(inspect(hash3_tdm))
>>
>> Now when the hash3.df is created, the entire data frame is printed on
the
>> console.  That's ok if the data frame is relatively small, but is
not
>> acceptable for a large data frame.
>>
>> Has anyone run into this before, please?  I have tried all kinds of
other
>> options for converting to a data frame, but to no avail.
>>
>>
>> This is on R-3.1.2, on Ubuntu 14.0.4
>>
>> Thanks!
>> Sincerely,
>> Erin
>>
>>
>> --
>> Erin Hodgess
>> Associate Professor
>> Department of Mathematical and Statistics
>> University of Houston - Downtown
>> mailto: erinm.hodgess at gmail.com
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>


--
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com