Thanks Jim and Peter.  Ignoring the filename worked.  The process is still
slow but a bit improved.  I had to slightly modify the substring to match
across the two objects.

n_corp_file <- capture.output(meta(corpa[[n]], "URI"),file=)
n_char <- nchar(n_corp_file[1])
n_char_dir <- nchar(corpa_dir)
# want to start at file(\ = 6 + directory + 2
corp_file <-substr(n_corp_file, 6+ n_char_dir +2, n_char-3)
corp_file <- corp_file[1]

##this doesnt suppress, but works too
#n_corp_file <- meta(corpa[[n]], "URI")
##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]
#####END of nonsupressed

On Sat, Jan 2, 2010 at 11:19 AM, jim holtman <jholt...@gmail.com> wrote:

> Actually if you just use 'capture.output' without specifying a 'file' it
> will return a character vector with the output which you can just ignore.
>
>   On Sat, Jan 2, 2010 at 1:51 PM, Peter Ehlers <ehl...@ucalgary.ca> wrote:
>
>>  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 <ehl...@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@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>
>>>>> <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
>>
>>    ______________________________________________
>> R-help@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.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to