| Title: | reading and writing SEER*STAT data files |
|---|---|
| Description: | read and write SEER*STAT data files Compatibility updates by Renova. |
| Authors: | Jun Luo [aut, cre] |
| Maintainer: | Jun Luo <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0.9001 |
| Built: | 2026-11-15 20:45:03 UTC |
| Source: | https://github.com/renova-r/SEER2R |
The Surveillance, Epidemiology, and End Results (SEER) Program of the National Cancer Institute (NCI) is an authoritative source of information on cancer incidence and survival in the United States. The SEER*Stat software developed by NCI provides a convenient, intuitive mechanism for the analysis of SEER and other cancer-related databases. SEER*STAT presents results in matrix session and users can export results into data file (either in plain text format or gz format) and dictionary information into dic file. read.SeerStat reads data and dictionary information from SEER*STAT export files. write.SeerStat writes data and dictionary information to files in the formats of SEER*STAT export files
| Package: | SEER2R |
| Type: | Package |
| Version: | 1.0 |
| Date: | 2011-09-28 |
| License: | |
| LazyLoad: | yes |
Maintainer: Jun Luo <[email protected]>
Jun Luo and Binbing Yu, 'SEER2R: An interface between SEER cancer registry data and R'
#load testing data: there are three data objects, i.e. SEER2RTestData1,SEER2RTestData2,SEER2RTestData3 data("SEER2RTestdata"); #create one SEER*STAT export dic and the associated text data file for testing purpose dicinfoused = write.SeerStat(SEER2RTestData2, DICfileName = "testrun1.dic",UseVarLabelsInTxtFile=FALSE); #usage of read.SeerStat mydata = read.SeerStat("testrun1.dic",UseVarLabelsInData=FALSE); #get informatin inside the dic file DICInfo = attr(mydata, "DICInfo"); #change names of columns whose names contains strings "site" or "sex"; #the order of strings does not matter testdatanewnames = attr(mydata,"assignColNames")(mydata,c("sex","site")); #extract columns whose names contains strings "site" or "sex"; testdata = attr(mydata,"getSubDataByVarName")(mydata,c("site","sex")); #usage of write.SeerStat dicinfoused = write.SeerStat(mydata, DICfileName = "testrun2.dic", UseVarLabelsInTxtFile = FALSE);#load testing data: there are three data objects, i.e. SEER2RTestData1,SEER2RTestData2,SEER2RTestData3 data("SEER2RTestdata"); #create one SEER*STAT export dic and the associated text data file for testing purpose dicinfoused = write.SeerStat(SEER2RTestData2, DICfileName = "testrun1.dic",UseVarLabelsInTxtFile=FALSE); #usage of read.SeerStat mydata = read.SeerStat("testrun1.dic",UseVarLabelsInData=FALSE); #get informatin inside the dic file DICInfo = attr(mydata, "DICInfo"); #change names of columns whose names contains strings "site" or "sex"; #the order of strings does not matter testdatanewnames = attr(mydata,"assignColNames")(mydata,c("sex","site")); #extract columns whose names contains strings "site" or "sex"; testdata = attr(mydata,"getSubDataByVarName")(mydata,c("site","sex")); #usage of write.SeerStat dicinfoused = write.SeerStat(mydata, DICfileName = "testrun2.dic", UseVarLabelsInTxtFile = FALSE);
SEER*STAT presents results in matrix session and users can export results into data file (either in plain text format or gz format) and dictionary information into dic file. read.SeerStat reads data and dictionary information from SEER*STAT export files.
read.SeerStat(DICfileName, TXTfileName = NULL, UseVarLabelsInData = FALSE,ReadHeaderOnly=FALSE,...)read.SeerStat(DICfileName, TXTfileName = NULL, UseVarLabelsInData = FALSE,ReadHeaderOnly=FALSE,...)
DICfileName |
: filename of the dic file. The default extention is 'dic'. If 'DICfileName' does not contain at the end a string '.dic' (letter case does not matter), then '.dic' will be added. |
TXTfileName |
: filename of the associated data file. If TXTfileName = NULL, then a string of DICfileName with extention substituted by 'txt' (for uncompressed data file) or 'gz' (for gzip compressed data file) will be used (whether 'txt' or 'gz' depends on information in the dic file). |
UseVarLabelsInData |
: a logic value. If true, then variable labels read from the dic file will replace associated numeric values in the data.frame object, which stores data from the associated data file and is returned by this function read.SeerStat. If false, then data read from the associated data file won't be changed. |
ReadHeaderOnly |
: a logic value. If true, then only the list storing the information read from the dic file will be returned. Otherwise, A data frame object containing a representation of the data in the associated data file will be returned. |
... |
:
Arguments to be passed to |
“read.SeerStat” reads data from a SEER*Stat data file into an object of data.frame in R and stores information from the associated dictionary file in an attribute variable (named “DICInfo”) of the data.frame object. The variables of the SEER*Stat data file are stored in columns of the data.frame object. The column names of the data.frame object are based on the variable names in the associated SEER*Stat dic file, with special characters “,:()<>={}!@#$ to a single ‘_’. For example, the column name will be “Example_Variable_1” if the variable name in the SEER*Stat dic file is “Example* (Variable 1)”.
A data frame (data.frame) containing a representation of the data in the associated data file and having three attributes ('DICInfo': a list storing dictionary information read from the dic file; 'assignColNames': a function that assigns new names (they are substrings of names of those columns that will be replaced) to asscociated columns of a data.frame object; 'getSubDataByVarName': a function that extracts columns of a data.frame object given substrings of names of columns that will be extracted ).
or
a list storing dictionary information read from the dic file if ReadHeaderOnly is true
Jun Luo
Maintainer: Jun Luo <[email protected]>
Jun Luo and Binbing Yu, 'SEER2R: An interface between SEER cancer registry data and R'
#load testing data: there are three data objects, i.e. SEER2RTestData1,SEER2RTestData2,SEER2RTestData3 data("SEER2RTestdata"); #create one SEER*STAT export dic and the associated text data file for testing purpose dicinfoused = write.SeerStat(SEER2RTestData2, DICfileName = "testrun1.dic",UseVarLabelsInTxtFile=FALSE); #usage of read.SeerStat mydata = read.SeerStat("testrun1.dic",UseVarLabelsInData=FALSE); #get informatin inside the dic file DICInfo = attr(mydata, "DICInfo"); #change names of columns whose names contains strings "site" or "sex"; #the order of strings does not matter testdatanewnames = attr(mydata,"assignColNames")(mydata,c("sex","site")); #extract columns whose names contains strings "site" or "sex"; testdata = attr(mydata,"getSubDataByVarName")(mydata,c("site","sex")); #usage of write.SeerStat dicinfoused = write.SeerStat(mydata, DICfileName = "testrun2.dic", UseVarLabelsInTxtFile = FALSE);#load testing data: there are three data objects, i.e. SEER2RTestData1,SEER2RTestData2,SEER2RTestData3 data("SEER2RTestdata"); #create one SEER*STAT export dic and the associated text data file for testing purpose dicinfoused = write.SeerStat(SEER2RTestData2, DICfileName = "testrun1.dic",UseVarLabelsInTxtFile=FALSE); #usage of read.SeerStat mydata = read.SeerStat("testrun1.dic",UseVarLabelsInData=FALSE); #get informatin inside the dic file DICInfo = attr(mydata, "DICInfo"); #change names of columns whose names contains strings "site" or "sex"; #the order of strings does not matter testdatanewnames = attr(mydata,"assignColNames")(mydata,c("sex","site")); #extract columns whose names contains strings "site" or "sex"; testdata = attr(mydata,"getSubDataByVarName")(mydata,c("site","sex")); #usage of write.SeerStat dicinfoused = write.SeerStat(mydata, DICfileName = "testrun2.dic", UseVarLabelsInTxtFile = FALSE);
There are three data objects, i.e. SEER2RTestData1,SEER2RTestData2,SEER2RTestData3, contained in SEER2RTestData.rda.
SEER2RTestData1: A data frame with 495 observations on the following 7 variables.
Statecounty_Testa factor with levels CA: Alameda County (06001) CA: Contra Costa County (06013) CA: Marin County (06041) CA: San Francisco County (06075) CA: San Mateo County (06081)
Sexa factor with levels Female Male Male and female
19982008a numeric vector
Site_Test_a factor with levels Hodgkin - Extranodal NHL - Extranodal NHL - Nodal
AgeAdjusted_Ratea numeric vector
Counta numeric vector
Populationa numeric vector
SEER2RTestData2: A data frame with 628 observations on the following 20 variables.
Page_typea numeric vector
Sites_LBa numeric vector
Year_of_diagnosis_7507_individuala numeric vector
Histologic_Type_ICDO3_LungSCNSCOtha numeric vector
Sexa numeric vector
Age_7584a numeric vector
Intervala numeric vector
Alive_at_Starta numeric vector
Dieda numeric vector
Lost_to_Followupa numeric vector
Observed_Survival_Intervala numeric vector
Observed_Survival_Cuma numeric vector
Expected_Survival_Intervala numeric vector
Expected_Survival_Cuma numeric vector
Relative_Survival_Intervala numeric vector
Relative_Survival_Cuma numeric vector
Observed_SE_Intervala numeric vector
Observed_SE_Cuma numeric vector
Relative_SE_Intervala numeric vector
Relative_SE_Cuma numeric vector
SEER2RTestData3: A data frame with 628 observations on the following 20 variables.
Page_typea character vector
Sites_LBa character vector
Year_of_diagnosis_7507_individuala character vector
Histologic_Type_ICDO3_LungSCNSCOtha character vector
Sexa character vector
Age_7584a character vector
Intervala character vector
Alive_at_Starta numeric vector
Dieda numeric vector
Lost_to_Followupa numeric vector
Observed_Survival_Intervala numeric vector
Observed_Survival_Cuma numeric vector
Expected_Survival_Intervala numeric vector
Expected_Survival_Cuma numeric vector
Relative_Survival_Intervala numeric vector
Relative_Survival_Cuma numeric vector
Observed_SE_Intervala numeric vector
Observed_SE_Cuma numeric vector
Relative_SE_Intervala numeric vector
Relative_SE_Cuma numeric vector
These data are extracted from SEER*STAT, which is available for general public.
Jun Luo and Binbing Yu, 'SEER2R: An interface between SEER cancer registry data and R'
data(SEER2RTestdata)data(SEER2RTestdata)
write.SeerStat writes data and dictionary information to files in the format of SEER*STAT export files
write.SeerStat(myData, DICfileName, TXTfileName = NULL, UseVarLabelsInTxtFile = TRUE, LabVarsNames = NULL,...)write.SeerStat(myData, DICfileName, TXTfileName = NULL, UseVarLabelsInTxtFile = TRUE, LabVarsNames = NULL,...)
myData |
: A data.frame object to be output. It may have an attribute 'DICInfo'. If no 'DICInfo' defined, then a default 'DICInfo' will be created and used for generating the dic file. |
DICfileName |
: filename of the dic file. The default extention is 'dic'. If 'DICfileName' does not contain at the end a string '.dic' (letter case does not matter), then '.dic' will be added. |
TXTfileName |
: filename of the associated data file. If TXTfileName = NULL, then a string of DICfileName with extention substituted by 'txt' (for uncompressed data file) or 'gz' (for gzip compressed data file) will be used (whether 'txt' or 'gz' depends on the attribute variable 'DICInfo' of the data.frame object 'myData'). |
UseVarLabelsInTxtFile |
: a logic value. If true, then variable labels will be output into the associated data file. If false, then the numeric values will be output. The variables, labels of which are to be output, are all character or factor columns of 'myData' if LabVarsNames = NULL, otherwise they are defined by 'LabVarsNames'. |
LabVarsNames |
: a name list of variables in the data.frame 'myData', labels of which will be output into the associated data file, instead of numeric values. |
... |
:
Arguments to be passed to |
“write.SeerStat” writes an object of data.frame to a SEER*Stat data file and creates the associated dictionary file that is in the format of SEER*Stat dictionary files. The variable names of the SEER*Stat data file are the same as the column names of the data.frame object. The contents of sections of dictionary file are based on the attribute variable “DICInfo" of the data.frame object. If users do not define an attribute variable “DICInfo" of the data.frame object, then default values will be used.
The 'DICInfo' actually used for writing to the dictionary file and the associated data file will be returned.
Jun Luo
Maintainer: Jun Luo <[email protected]>
Jun Luo and Binbing Yu, 'SEER2R: An interface between SEER cancer registry data and R'
#load testing data: there are three data objects, i.e. SEER2RTestData1,SEER2RTestData2,SEER2RTestData3 data("SEER2RTestdata"); #create one SEER*STAT export dic and the associated text data file for testing purpose dicinfoused = write.SeerStat(SEER2RTestData2, DICfileName = "testrun1.dic",UseVarLabelsInTxtFile=FALSE); #usage of read.SeerStat mydata = read.SeerStat("testrun1.dic",UseVarLabelsInData=FALSE); #get informatin inside the dic file DICInfo = attr(mydata, "DICInfo"); #change names of columns whose names contains strings "site" or "sex"; #the order of strings does not matter testdatanewnames = attr(mydata,"assignColNames")(mydata,c("sex","site")); #extract columns whose names contains strings "site" or "sex"; testdata = attr(mydata,"getSubDataByVarName")(mydata,c("site","sex")); #usage of write.SeerStat dicinfoused = write.SeerStat(mydata, DICfileName = "testrun2.dic", UseVarLabelsInTxtFile = FALSE);#load testing data: there are three data objects, i.e. SEER2RTestData1,SEER2RTestData2,SEER2RTestData3 data("SEER2RTestdata"); #create one SEER*STAT export dic and the associated text data file for testing purpose dicinfoused = write.SeerStat(SEER2RTestData2, DICfileName = "testrun1.dic",UseVarLabelsInTxtFile=FALSE); #usage of read.SeerStat mydata = read.SeerStat("testrun1.dic",UseVarLabelsInData=FALSE); #get informatin inside the dic file DICInfo = attr(mydata, "DICInfo"); #change names of columns whose names contains strings "site" or "sex"; #the order of strings does not matter testdatanewnames = attr(mydata,"assignColNames")(mydata,c("sex","site")); #extract columns whose names contains strings "site" or "sex"; testdata = attr(mydata,"getSubDataByVarName")(mydata,c("site","sex")); #usage of write.SeerStat dicinfoused = write.SeerStat(mydata, DICfileName = "testrun2.dic", UseVarLabelsInTxtFile = FALSE);