useDynLib(memisc)
import(stats,grid,lattice,methods,MASS)
importFrom(utils,
           ls.str,
           str,
           toLatex,
           head,
           tail,
           capture.output,
           getFromNamespace,
           View,
           browseURL,
           getS3method,
           localeToCharset)
export(
      contr,
      contr.treatment,
      contr.sum,
      cases,
      colrename,
      dimrename,
      mtable,
      write.mtable,
      getSummary,
      getSummary.glm,
      getSummary.lm,
      getSummary.polr,
      getSummary.clm,
      getSummary.simex,
      getSummary.coxph,
      getSummary.survreg,
      getSummary.aftreg,
      getSummary.phreg,
      getSummary.weibreg,
      getSummary.merMod,
      getSummary_expcoef,
      getSummary_expcoef.default,
      getSummary.ivreg,
      getSummary.tobit,
      getSummary.hurdle,
      getSummary.zeroinfl,
      getSummary.betareg,
      getSummary.multinom,
      applyTemplate,
      #get.substr,
      getSummaryTemplate,
      setSummaryTemplate,
      getCoefTemplate,
      setCoefTemplate,
      recode,
      relabel,
      relabel4,
      rename,
      rowrename,
      genTable,
      Aggregate,
      #wtable,
      Table,
      Descriptives,
      percent,
      percent.default,
      percent.logical,
      By,
      Sapply,
      Lapply,
      sort.data.frame,
      sort.data.set,
      to.data.frame,
      as.array,
      as.item,
      labels,
      "labels<-",
      value.filter,
      valid.values,
      missing.values,
      valid.range,
      "valid.values<-",
      "valid.range<-",
      "missing.values<-",
      measurement,
      "measurement<-",
      include.missings,
      annotation,
      "annotation<-",
      description,
      "description<-",
      wording,
      "wording<-",
      is.missing,
      is.valid,
      nvalid,
      is.nominal,
      is.ordinal,
      is.interval,
      is.ratio,
      as.nominal,
      as.ordinal,
      as.interval,
      as.ratio,
      contrasts,
      "contrasts<-",
      data.set,
      as.data.set,
      is.data.set,
      retain,
      foreach,
      xapply,
      syms,
      as.symbols,
      Substitute,
      collect,
      fapply,
      "%nin%",
      codebook,
      wild.codes,
      spss.fixed.file,
      spss.portable.file,
      spss.system.file,
      Stata.file,
      query,
      relabel4,
      Iconv,
      Write,
      mtable_format_print,
      mtable_format_latex,
      mtable_format_html,
      mtable_format_delim,
      show_html,
      write_html,
      format_html,
      dsView,
      summaryTemplate,
      percentages
      )
S3method(getSummary,aftreg)
S3method(getSummary,betareg)
S3method(getSummary,clm)
S3method(getSummary,coxph)
S3method(getSummary,glm)
S3method(getSummary,hurdle)
S3method(getSummary,zeroinfl)
S3method(getSummary,ivreg)
S3method(getSummary,lm)
S3method(getSummary,merMod)
S3method(getSummary,multinom)
S3method(getSummary,phreg)
S3method(getSummary,polr)
S3method(getSummary,simex)
S3method(getSummary,survreg)
S3method(getSummary,tobit)
S3method(getSummary,weibreg)
S3method(getSummary_expcoef,default)
S3method(getSummary_expcoef,glm)
S3method(getSummary,clm)
S3method(getSummary,clmm)
S3method(sort,data.frame)
S3method(sort,data.set)
S3method(print,memisc_mtable)
S3method(format,memisc_mtable)
S3method(dim,memisc_mtable)
S3method(dimnames,memisc_mtable)
S3method("[",memisc_mtable)
S3method(c,memisc_mtable)
S3method(toLatex,default)
S3method(toLatex,matrix)
S3method(toLatex,memisc_mtable)
S3method(toLatex,ftable)

S3method(relabel,default)
S3method(relabel,factor)
S3method(relabel,memisc_mtable)
S3method(relabel,table)
S3method(relabel,ftable)

S3method(reorder,matrix)
S3method(reorder,array)
S3method(collect,default)
S3method(collect,matrix)
S3method(collect,array)
S3method(collect,table)
S3method(collect,data.frame)
S3method(collect,data.set)
S3method(collect,by)
S3method(fapply,default)
S3method(percent,default)
S3method(percent,logical)
S3method(By,default)
S3method(By,data.frame)

exportClasses(
  atomic,
  value.labels,
  value.filter,
  valid.values,
  valid.range,
  missing.values,
  annotation,
  item,
  integer.item,
  double.item,
  character.item,
  numeric.item,
  item.vector,
  named.list,
  item.list,
  data.set,
  spss.fixed.importer,
  spss.portable.importer,
  spss.system.importer,
  Stata.importer,
  importer,
  codebook,
  datetime.item,
  Date.item
  )

if(getRversion() < "3.6.0") exportClasses(double)

exportMethods(
    as.item,
    labels,
    "labels<-",
    value.filter,
    valid.values,
    missing.values,
    valid.range,
    "valid.values<-",
    "valid.range<-",
    "missing.values<-",
    measurement,
    "measurement<-",
    annotation,
    "annotation<-",
    Arith,
    Compare,
    Math,
    Math2,
    Summary,
    print,
    show,
    unique,
    "[",
    "[<-",
    "rep",
    row.names,
    dimnames,
    as.array,
    as.vector,
    as.character,
    as.numeric,
    as.integer,
    as.factor,
    as.ordered,
    contrasts,
    as.data.set,
    "contrasts<-",
    summary,
    within,
    merge,
    "%in%",
    recode,
    dim,
    initialize,
    coerce,
    Table,
    Descriptives,
    codebook,
    wild.codes,
    sample,
    query,
    "[[",
    "$",
    head,
    tail
    )
S3method(as.data.frame,character.item)
S3method(as.data.frame,double.item)
S3method(as.data.frame,integer.item)
S3method("[[<-",data.set)
S3method(str,data.set)
S3method(str,integer.item)
S3method(str,double.item)
S3method(str,character.item)
S3method(str,datetime.item)
S3method(str,Date.item)
S3method(as.list,data.set)
S3method(as.data.frame,data.set)
S3method(subset,data.set)
S3method(cbind,data.set)
S3method(fapply,data.set)
S3method(print,descriptions)
S3method(as.data.frame,descriptions)
S3method(Iconv,item)
S3method(Iconv,value.labels)
S3method(Iconv,annotation)
S3method(Iconv,data.set)
S3method(Iconv,importer)
S3method(Write,descriptions)
S3method(Write,codebook)

S3method(as.data.frame,spss.system.importer)
S3method(as.data.frame,spss.portable.importer)
S3method(as.data.frame,spss.fixed.importer)
S3method(as.data.frame,Stata.importer)
S3method(as.data.frame,Stata_new.importer)

S3method(subset,spss.system.importer)
S3method(subset,spss.portable.importer)
S3method(subset,spss.fixed.importer)
S3method(subset,Stata.importer)
S3method(subset,Stata_new.importer)

S3method(format_html,memisc_mtable)
S3method(format_html,ftable)
S3method(format_html,codebook)
S3method(format_html,codebookEntry)
S3method(format_html,data.frame)
S3method(format_html,matrix)

S3method(sort,data.set)
S3method(rbind,data.set)

S3method(as.POSIXct,datetime.item)
S3method(as.data.frame,datetime.item)
S3method(as.data.frame,Date.item)

S3method(xtfrm,integer.item)
S3method(xtfrm,double.item)
S3method(xtfrm,character.item)
S3method(xtfrm,datetime.item)
S3method(xtfrm,Date.item)

if (getRversion() >= "4.2.0") {
    
    S3method(mtfrm,integer.item)
    S3method(mtfrm,double.item)
    S3method(mtfrm,character.item)
    S3method(mtfrm,datetime.item)
    S3method(mtfrm,Date.item)
}


S3method(unique,integer.item)
S3method(unique,double.item)
S3method(unique,character.item)
S3method(unique,datetime.item)
S3method(unique,Date.item)

S3method(toLatex,data.frame)
S3method(toLatex,data.set)

S3method(percentages,table)
S3method(percentages,formula)
S3method(percentages,default)
S3method(percentages,list)
S3method(percentages,data.frame)
S3method(as.data.frame,percentage.table)
S3method(as.data.frame,xpercentage.table)

S3method(cbind,ftable)
S3method(rbind,ftable)
S3method(cbind,ftable_matrix)
S3method(rbind,ftable_matrix)
S3method(format,ftable_matrix)
S3method(print,ftable_matrix)
S3method(Write,ftable_matrix)

S3method(toLatex,ftable_matrix)
S3method(format_html,ftable_matrix)
S3method(relabel,ftable_matrix)

export(
    df_format_stdstyle,
    ftable_format_stdstyle,
    mat_format_stdstyle,
    mtable_format_stdstyle)

export(html,content,attribs,style,
  setContent,setStyle,setAttribs,
  html_group,as.html_group,
  css,as.css,
  "content<-","attribs<-","style<-")
  
S3method(as.character,html_elem)
S3method(print,html_elem)
S3method(c,html_elem)
S3method(format_html,html_elem)

S3method(as.character,html_group)
S3method(print,html_group)
S3method(c,html_group)
S3method("[",html_group)
S3method("[<-",html_group)
S3method(format_html,html_group)


S3method(setAttribs,character)
S3method(setAttribs,html_elem)
S3method(setAttribs,html_group)
S3method("[<-",html_attributes)

S3method(as.character,css)
S3method(print,css)
S3method(setStyle,character)
S3method(setStyle,html_elem)
S3method(setStyle,html_group)
S3method("[<-",css)

S3method(format_html,descriptions)

export(withSE,withVCov)
S3method(withVCov,lm)
S3method(vcov,withVCov)
S3method(summary,withVCov)
S3method(summary,withVCov.lm)

export(codeplan,
       setCodeplan,
       "codeplan<-")
S3method(print,codeplan)

exportMethods(codeplan,setCodeplan)

S3method(as.list,item.list)
export(duplicated_labels)
S3method(duplicated_labels,item)
S3method(duplicated_labels,item.list)

S3method(print,dupLabelsReport)
S3method(print,dupLabelsReport1)

export(
    "%#%",
    "%##%",
    "%@%",
    "%@%<-"
)
export(List)

export(Groups)
S3method(Groups,data.frame)
S3method(Groups,data.set)
S3method(Groups,grouped.data)

S3method(with,grouped.data)
S3method(within,grouped.data)

S3method(print,grouped.data.frame)
S3method(print,grouped.data.set)
export(recombine)
S3method(recombine,grouped.data.frame)
S3method(recombine,grouped.data.set)

S3method(as.data.frame,grouped.data)
# S3method(as.data.set,grouped.data.frame)
# S3method(as.data.set,grouped.data.set)


S3method(print,grouped.result)
export(withGroups,withinGroups)

export(Reshape)
export(spss.file)

export(as_tibble.data.set)
# S3method("as_tibble",data.set)
# exportMethods(as_tibble)
export(as_haven)
exportMethods(as_haven)

export(view)
export(viewPrep)
S3method(viewPrep,default)
S3method(viewPrep,data.set)
S3method(viewPrep,data.frame)
S3method(viewPrep,descriptions)
S3method(viewPrep,codeplan)
S3method(viewPrep,importer)
export(view_html)

importFrom(data.table,as.data.table)
S3method(as.data.table,data.set)
# export(as.data.table.data.set) 
# exportMethods(as.data.table) 

export(set_measurement)

export(Mean,Median,Min,Max,Weighted.Mean,
       Var,StdDev,Cov,Cor,Range)

export(deduplicate_labels)
S3method(deduplicate_labels,default)
S3method(deduplicate_labels,item)
S3method(deduplicate_labels,item.list)

export(trim_labels)
exportMethods(trim_labels)
export(reversed)

export(Means)
S3method(Means,formula)
S3method(Means,data.frame)
S3method(Means,data.set)
S3method(Means,numeric)
S3method(as.data.frame,means.table)
S3method(as.data.frame,xmeans.table)

export(contract)
S3method(contract,data.frame)
S3method(contract,data.set)

S3method(format,data.set)
S3method(format,codebookEntry)
S3method(format,Date.item)
S3method(format,datetime.item)
S3method(format,item.vector)

importFrom(yaml,as.yaml,read_yaml,write_yaml)
importFrom(jsonlite,read_json,write_json)
export(read_codeplan,write_codeplan)

export(format_md)
S3method(format_md, codebook)
S3method(format_md, codebookEntry)

export(coarsen)
S3method(coarsen,numeric)

export(measurement_autolevel)
exportMethods(measurement_autolevel)

export(
    "%if%",
    "%$%",
    "%$$%",
    Within
)
S3method(Within,data.frame)

export(neg2mis)
