Learn R Programming

tosca (version 0.3-4)

filterDate: Subcorpus With Date Filter

Description

Generates a subcorpus by restricting it to a specific time window.

Usage

filterDate(...)

# S3 method for default filterDate( text, meta, s.date = min(meta$date, na.rm = TRUE), e.date = max(meta$date, na.rm = TRUE), ... )

# S3 method for textmeta filterDate( object, s.date = min(object$meta$date, na.rm = TRUE), e.date = max(object$meta$date, na.rm = TRUE), filtermeta = TRUE, ... )

Value

textmeta object if object is specified, else only the filtered text. If a textmeta object is returned its meta data are filtered to those texts which appear in the corpus by default (filtermeta).

Arguments

...

Not used.

text

Not necessary if object is specified, else should be object$text

meta

Not necessary if object is specified, else should be object$meta

s.date

Start date of subcorpus as date object

e.date

End date of subcorpus as date object

object

textmeta object

filtermeta

Logical: Should the meta component be filtered, too?

Examples

Run this code
texts <- list(A="Give a Man a Fish, and You Feed Him for a Day.
Teach a Man To Fish, and You Feed Him for a Lifetime",
B="So Long, and Thanks for All the Fish",
C="A very able manipulative mathematician, Fisher enjoys a real mastery
in evaluating complicated multiple integrals.")

corpus <- textmeta(meta=data.frame(id=c("A", "B", "C", "D"),
title=c("Fishing", "Don't panic!", "Sir Ronald", "Berlin"),
date=c("1885-01-02", "1979-03-04", "1951-05-06", "1967-06-02"),
additionalVariable=1:4, stringsAsFactors=FALSE), text=texts)

subcorpus <- filterDate(object=corpus, s.date = "1951-05-06")
subcorpus$meta
subcorpus$text

Run the code above in your browser using DataLab