use                 package:epicalc                 R Documentation

_Q_u_i_c_k _c_o_m_m_a_n_d _t_o _r_e_a_d _i_n _d_a_t_a

_D_e_s_c_r_i_p_t_i_o_n:

     Quick command to read in data in Stata, SPSS, EpiInfo and .csv
     formats in addition to

_U_s_a_g_e:

     use(filename, clear = TRUE, tolower=TRUE)

_A_r_g_u_m_e_n_t_s:

filename: a character object ended with one of the following: .dbf,
          .dta, .sav, .rec, .csv (file withh comma and header); data
          set in R package requires no quote

   clear: equal to 'detachAllData()' before reading in the data set and
          attaching it to the search path

 tolower: whether all the names of the variables should be forced to
          lower case (only if the original file has one the following
          extensions: '.dbf', 'rec' and '.sav' files)

_D_e_t_a_i_l_s:

     'use' reads in datasets from Dbase (.dbf), Stata (.dta),
     SPSS(.sav), EpiInfo(.rec) and Comma separated value(.csv) formats
     as well as those come with 'pakage:datasets' in R. The data frame
     is saved in memory as '.data' and automatically attached to the
     search path. This setting is the basis for other commands of
     'epicalc' including 'des', 'summ', 'recode', 'labelVar' etc. 

     The next 'use' command replaces the default data frame '.data'
     with the new one. If required it should be copied to a new data
     frame object for further use or 'save'd into an R image file.

_A_u_t_h_o_r(_s):

     Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

_S_e_e _A_l_s_o:

     'read.table', 'read.dta', 'read.SPSS', etc and 'detachAllData'

_E_x_a_m_p_l_e_s:

     # data(BOD)
     library(foreign)
     write.dta(BOD, file="BOD.dta")
     rm(list=ls())
     ls()
     use("BOD.dta", clear=FALSE)

     # The above lines write Stata format from R data frame. 
     # In reality, one just exploits 'use("filename.dta")', if the file is available.
     des()
     file.remove("BOD.dta")

     # A better way to read R dataset for exploration with Epicalc is
      use(BOD, clear=FALSE)
      des()
      summ()

