R LDAvis K=2 createJSON() error

Viewed 922

I was using LDAvis package's createJSON() function while my topicmodel was for 2 topics and received this error

Error in stats::cmdscale(dist.mat, k = 2) : 'k' must be in {1, 2, .. n - 1} 

Then I tested with reproducible example given here, by putting K=2 and keeping everything same and bumped into this error again in createJSON().

Upon looking at the source code of createJSON() here, the issue is in function jsPCA(). In jsPCA(), while K=2, the dist.mat comes out to be a single value which throws an error in line

pca.fit <- stats::cmdscale(dist.mat, k = 2) 

Any advice how to get past this error?

1 Answers
Related