% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods-conversion.R
\name{from_svydesign}
\alias{from_svydesign}
\title{Convert a survey Package Design to a surveycore Design Object}
\usage{
from_svydesign(x)
}
\arguments{
\item{x}{A \code{survey::svydesign}, \code{survey::svrepdesign}, \code{survey::twophase},
or \code{srvyr::tbl_svy} object.}
}
\value{
A \code{survey_taylor}, \code{survey_replicate}, or \code{survey_twophase} object.
}
\description{
Converts a \code{survey} package design object (\code{svydesign}, \code{svrepdesign}, or
\code{twophase}) to the corresponding surveycore S7 object. The data, design
variables, and replicate weights are preserved; metadata (variable labels,
value labels) is not — the \code{survey} package has no metadata system.
}
\details{
Weight column names are recovered from the design call when available. When
the call does not contain a formula (e.g., weights were passed as a vector),
the weight column is identified by matching the stored weight values against
columns in the data. If no match is found, a \code{..surveycore_wt..} column is
added.
}
\examples{
if (requireNamespace("survey", quietly = TRUE)) {
  sv <- survey::svydesign(
    ids = ~sdmvpsu, weights = ~wtint2yr, strata = ~sdmvstra,
    data = nhanes_2017, nest = TRUE
  )
  d <- from_svydesign(sv)
  survey_data(d)
}

}
\seealso{
\code{\link[=as_svydesign]{as_svydesign()}} to convert in the other direction

Other conversion: 
\code{\link{as_svydesign}()},
\code{\link{as_tbl_svy}()},
\code{\link{from_tbl_svy}()}
}
\concept{conversion}
