Skip to content

How to left join docvars with those in an existing corpus #7

Description

@conjugateprior

This works

> str(inaugCorpus) # but deprecated
List of 4
 $ documents:'data.frame':	58 obs. of  1 variable:
  ..$ texts: chr [1:58] "Fellow-Citizens of the Senate and of the House of Representatives:\n\nAmong the vicissitudes incident to life no event could ha"| __truncated__ "Fellow citizens, I am again called upon by the voice of my country to execute the functions of its Chief Magistrate. When the o"| __truncated__ "When it was first perceived, in early times, that no middle course for America remained between unlimited submission to a forei"| __truncated__ "Friends and Fellow Citizens:\n\nCalled upon to undertake the duties of the first executive office of our country, I avail mysel"| __truncated__ ...
 $ metadata :'data.frame':	58 obs. of  1 variable:
  ..$ Year: num [1:58] 1789 1793 1797 1801 1805 ...
 $ settings :'data.frame':	58 obs. of  1 variable:
  ..$ President: chr [1:58] "Washington" "Washington" "Adams" "Jefferson" ...
 $ tokens   :'data.frame':	58 obs. of  1 variable:
  ..$ FirstName: chr [1:58] "George" "George" "John" "Thomas" ...
 - attr(*, "class")= chr [1:2] "corpus" "list"

but this doesn't

> str(corpus(data_char_inaugural))
Error in `[[.corpus`(object, 1L) : 
  cannot index docvars this way because none exist

apparently because there are no docvars

> str(corpus(data_char_inaugural, docvars = docvars(inaugCorpus)))
List of 4
 $ documents:'data.frame':	58 obs. of  1 variable:
  ..$ texts: chr [1:58] "Fellow-Citizens of the Senate and of the House of Representatives:\n\nAmong the vicissitudes incident to life no event could ha"| __truncated__ "Fellow citizens, I am again called upon by the voice of my country to execute the functions of its Chief Magistrate. When the o"| __truncated__ "When it was first perceived, in early times, that no middle course for America remained between unlimited submission to a forei"| __truncated__ "Friends and Fellow Citizens:\n\nCalled upon to undertake the duties of the first executive office of our country, I avail mysel"| __truncated__ ...
 $ metadata :'data.frame':	58 obs. of  1 variable:
  ..$ Year: num [1:58] 1789 1793 1797 1801 1805 ...
 $ settings :'data.frame':	58 obs. of  1 variable:
  ..$ President: chr [1:58] "Washington" "Washington" "Adams" "Jefferson" ...
 $ tokens   :'data.frame':	58 obs. of  1 variable:
  ..$ FirstName: chr [1:58] "George" "George" "John" "Thomas" ...
 - attr(*, "class")= chr [1:2] "corpus" "list"

Seems like it should be possible to make a docvar-free corpus though.

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X El Capitan 10.11.6

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] readtext_0.2.9000 quanteda_0.9.9-24

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9         lattice_0.20-34     deldir_0.1-12      
 [4] png_0.1-7           class_7.3-14        gtools_3.5.0       
 [7] digest_0.6.12       foreach_1.4.3       V8_1.2             
[10] R6_2.2.0            plyr_1.8.4          tmap_1.8-1         
[13] stats4_3.3.2        coda_0.19-1         e1071_1.6-8        
[16] httr_1.2.1          spdep_0.6-9         curl_2.3           
[19] data.table_1.10.0   gdata_2.17.0        geosphere_1.5-5    
[22] raster_2.5-8        gmodels_2.16.2      R.utils_2.5.0      
[25] R.oo_1.21.0         Matrix_1.2-7.1      splines_3.3.2      
[28] webshot_0.4.0       rgdal_1.2-5         htmlwidgets_0.8    
[31] RCurl_1.95-4.8      munsell_0.4.3       rmapshaper_0.1.0   
[34] tmaptools_1.2       rgeos_0.3-22        htmltools_0.3.5    
[37] codetools_0.2-15    mapview_1.2.0       XML_3.98-1.5       
[40] viridisLite_0.1.3   MASS_7.3-45         bitops_1.0-6       
[43] R.methodsS3_1.7.1   grid_3.3.2          nlme_3.1-128       
[46] jsonlite_1.2        satellite_0.2.0     magrittr_1.5       
[49] scales_0.4.1        RcppParallel_4.3.20 KernSmooth_2.23-15 
[52] stringi_1.1.2       LearnBayes_2.15     leaflet_1.0.1      
[55] sp_1.2-4            ca_0.64             latticeExtra_0.6-28
[58] boot_1.3-18         fastmatch_1.1-0     osmar_1.1-7        
[61] RColorBrewer_1.1-2  iterators_1.0.8     tools_3.3.2        
[64] gdalUtils_2.0.1.7   dichromat_2.0-0     colorspace_1.3-2   
[67] classInt_0.1-23    

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions