An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100101/585a0d25/attachment.pl>
suppress output for meta in package tm
6 messages · Peter Ehlers, jim holtman, Amber Jaycocks
Can you wrap your call in capture.output(..., file=...)? -Peter Ehlers
Amber Jaycocks wrote:
Hello, I am using the tm package and wish to suppress the output for meta. I am defining another variable for one of the tags and don't want the value printed on the screen. Any help would be appreciated. Thanks. here is the commnad: n_corp_file <- meta(corpa[[n]], "URI") -Amber [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list 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.
Peter Ehlers University of Calgary 403.202.3921
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100102/85a11fad/attachment.pl>
I don't know anything about pkg:tm, but I'll make a couple of comments below.
Amber Jaycocks wrote:
Hi, Peter.
Thanks. This works but is not ideal to have an external file. The main
reason I want to suppress the output is to speed up the processing time,
which capture.output does indeed do. It is a great work around for now.
I am using the output to match items in a corpa to a file that contains
metadata and then attaching the fields in the meta data file as metadata to
each item in the corpa. If you have any other suggestions to increase
processing speed please let me know. Many Thanks.
for (n in 1:length(corpa)) {
or: for(n in seq_along(corpa)){
n_corp_file <- capture.output(meta(corpa[[n]], "URI"),file="log.txt")
here, I think, you want: capture.output(n_corp_file <- meta(corpa[[n]], "URI"), file="log.txt") and I would use (on Windows): file="clipboard"
#want just file not dir and file
n_char <- nchar(n_corp_file[2])
#nchar[1] is "file"=4 and nchar[2] is dir + filename amd nchar[3] is "UTF-8"
= 5
n_char_dir <- nchar(corpa_dir)
corp_file <- substr(n_corp_file, n_char_dir + 2, n_char)
corp_file <- corp_file[2]
#match corpa file with meta data file
match_index <- match(corp_file,(meta_data$file))
if (!is.na(match_index)) {
#attach all rows of meta_data
meta_cols <- colnames(meta_data)
for (col in 1:length(meta_cols)) {
meta(corpa[[n]], meta_cols[col]) <- meta_data[match_index,meta_cols[col]] }
} #if
} #for n corpa
You might also find sink() to be more to your taste than capture.output(). -Peter
On Sat, Jan 2, 2010 at 6:03 AM, Peter Ehlers <ehlers at ucalgary.ca> wrote:
Can you wrap your call in capture.output(..., file=...)? -Peter Ehlers Amber Jaycocks wrote:
Hello,
I am using the tm package and wish to suppress the output for meta. I am
defining another variable for one of the tags and don't want the value
printed on the screen. Any help would be appreciated. Thanks.
here is the commnad:
n_corp_file <- meta(corpa[[n]], "URI")
-Amber
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
-- Peter Ehlers University of Calgary 403.202.3921
Peter Ehlers University of Calgary 403.202.3921
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100102/1e8bb300/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100102/5c9ce7ee/attachment.pl>