Skip to content

convert(x, to = "stm") fails when dfm is 0% sparse #701

Closed

Description

@kbenoit

this is fine:

convert(as.dfm(matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 0), ncol = 3)), to = "stm")
# $documents
# $documents$doc1
# [,1] [,2] [,3]
# [1,]    1    2    3
# [2,]    1    4    7
# 
# $documents$doc2
# [,1] [,2] [,3]
# [1,]    1    2    3
# [2,]    2    5    8
# 
# $documents$doc3
# [,1] [,2]
# [1,]    1    2
# [2,]    3    6
# 
# 
# $vocab
# [1] "feat1" "feat2" "feat3"
# 
# $meta
# NULL

but replace the zero with a count, and it fails:

convert(as.dfm(matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), ncol = 3)), to = "stm")
# $documents
# 1 2 3
# [1,] 1 1 1
# [2,] 1 2 3
# [3,] 2 2 2
# [4,] 4 5 6
# [5,] 3 3 3
# [6,] 7 8 9
# attr(,"names")
# [1] "doc1" "doc2" "doc3" NA     NA     NA     NA     NA     NA     NA     NA     NA     NA    
# [14] NA     NA     NA     NA     NA    
# 
# $vocab
# [1] "feat1" "feat2" "feat3"
# 
# $meta
# NULL

Activity

  1. self-assigned this
    on May 4, 2017
  2. added 2 commits that reference this issue on May 5, 2017
  3. added a commit that references this issue on May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions