-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_prep.R
More file actions
21 lines (19 loc) · 818 Bytes
/
data_prep.R
File metadata and controls
21 lines (19 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
### Data Prep
library(rcarbon)
library(here)
load(here('data','c14data.RData'))
# Calibrate and Pre-Process Data ####
obs.caldates = calibrate(c14data$CRA,c14data$Error,calCurves = 'intcal20')
# Consider samples that have a probability mass over 0.5 within 3400 and 1850, ca. #Late Jomon to End of Middle Yayoi. (n=288)
index = which.CalDates(obs.caldates,BP<3400&BP>1850,p=0.5)
obs.caldates = obs.caldates[index]
# Extract relevant CRA and CRAErrors
CRA=c14data$CRA[index]
Errors=c14data$Error[index]
SiteID = c14data$SiteID[index]
LabCode = c14data$LabCode[index]
# Extract Median Calibrated Dates
medDates = medCal(obs.caldates)
# Save to R Image
obs.data = data.frame(LabCode=LabCode,CRA=CRA,Error=Errors,MedCalDate=medDates,SiteID=SiteID)
save(obs.data,obs.caldates,file=here('R_images','cleaned_data.RData'))