% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/space.R
\name{tsne}
\alias{tsne}
\alias{tsne.data.frame}
\alias{tsne.tmfast}
\alias{tsne.STM}
\title{Discursive space using t-SNE}
\usage{
tsne(x, ...)

\method{tsne}{data.frame}(x, doc_ids, perplexity = NULL, df = TRUE, ...)

\method{tsne}{tmfast}(x, k, perplexity = NULL, df = TRUE, ...)

\method{tsne}{STM}(x, doc_ids, perplexity = NULL, df = TRUE, ...)
}
\arguments{
\item{x}{Fitted topic model (\code{tmfast} or \code{STM})}

\item{...}{Passed to methods}

\item{doc_ids}{Vector of document IDs, in the same order as rows in \code{x}}

\item{perplexity}{Perplexity parameter for t-SNE. By default, minimum of 30
and \code{floor((length(doc_ids) - 1)/3) - 1}.}

\item{df}{Return a dataframe with columns \code{document}, \code{x}, and \code{y} (default)
or the raw output of \code{Rtsne}.}

\item{k}{Number of topics}
}
\value{
See \code{df}
}
\description{
2-dimensional "discursive space" representation of relationships between
documents using Hellinger distances and t-SNE.
}
\details{
Algorithm checks distances to 3*perplexity nearest neighbors. Rtsne
loses rownames (document IDs); these are either extracted from the \code{tmfast}
object or passed separately for an \code{STM} object. Use \code{set.seed()} before
calling for reproducibility.
}
\section{Methods (by class)}{
\itemize{
\item \code{tsne(data.frame)}: Method for tidied gamma dataframes

\item \code{tsne(tmfast)}: Method for fitted \code{tmfast} objects

\item \code{tsne(STM)}: Method for fitted \code{STM} objects

}}
\examples{
\donttest{
set.seed(42)
theta = rdirichlet(50, 1, k = 3)
phi   = rdirichlet(3, 0.1, k = 30)
corpus = draw_corpus(rep(50L, 50), theta, phi)
fitted = tmfast(corpus, n = 3)
tsne(fitted, k = 3, df = TRUE)
}
}
