1. Demographics data
# Load the foreign package
library(foreign)
# Read the XPT file into a data frame
demo = read.xport("C:/Users/Momo/Desktop/Machine Learning/Demographics data/DEMO_H.XPT")
# Write the data frame to a CSV file
write.csv(demo, file = "demo.csv", row.names = FALSE)
2. Dietary data
2.1 Food 1st day
DR1IFF = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DR1IFF_H.XPT")
write.csv(DR1IFF, file = "DR1IFF.csv", row.names = FALSE)
2.2 Food 2nd day
DR2IFF = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DR2IFF_H.XPT")
write.csv(DR2IFF, file = "DR2IFF.csv", row.names = FALSE)
2.3 Total Nutrient Intakes, 1st day
DR1TOT = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DR1TOT_H.XPT")
write.csv(DR1TOT, file = "DR1TOT.csv", row.names = FALSE)
2.4 Total Nutrient Intakes, 2nd day
DR2TOT = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DR2TOT_H.XPT")
write.csv(DR2TOT, file = "DR2TOT.csv", row.names = FALSE)
2.5 Dietary Interview Technical Support File - Food Codes
DRXFCD = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DRXFCD_H.XPT")
write.csv(DRXFCD, file = "DRXFCD.csv", row.names = FALSE)
2.9 Dietary Supplement Use 24-Hour - Individual Dietary Supplements,
First Day
DS1IDS = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DS1IDS_H.XPT")
write.csv(DS1IDS, file = "DS1IDS.csv", row.names = FALSE)
2.10 Dietary Supplement Use 24-Hour - Individual Dietary
Supplements, Second Day
DS2IDS = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DS2IDS_H.XPT")
write.csv(DS2IDS, file = "DS2IDS.csv", row.names = FALSE)
2.11 Dietary Supplement Use 24-Hour - Total Dietary Supplements,
First Day
DS1TOT = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DS1TOT_H.XPT")
write.csv(DS1TOT, file = "DS1TOT.csv", row.names = FALSE)
2.12 Dietary Supplement Use 24-Hour - Total Dietary Supplements,
Second Day
DS2TOT = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DS2TOT_H.XPT")
write.csv(DS2TOT, file = "DS2TOT.csv", row.names = FALSE)
2.13 Dietary Supplement Use 30-Day - Individual Dietary
Supplements
DSQIDS = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DSQIDS_H.XPT")
write.csv(DSQIDS, file = "DSQIDS.csv", row.names = FALSE)
2.14 Dietary Supplement Use 30-Day - Total Dietary Supplements
DSQTOT = read.xport("C:/Users/Momo/Desktop/Machine Learning/Dietary data/DSQTOT_H.XPT")
write.csv(DSQTOT, file = "DSQTOT.csv", row.names = FALSE)