Open iangow opened 2 hours ago
Also this ...
for (year in c(2012:2018)) {
dir <- "/XBRL/sub/"
sub <- do.call(rbind,
lapply(list.files(paste(dir,year,sep=""),full.names=T),
read.table,
sep="\t",
header=T,
fill=T,
quote=""))
dir <- "/XBRL/num/"
num <- do.call(rbind,
lapply(list.files(paste(dir,year,sep=""),full.names=T),
read.table,
sep="\t",
header=T,
fill=T,
quote=""))
dir <- "/XBRL/tag/"
tag <- do.call(rbind,
lapply(list.files(paste(dir,year,sep=""),full.names=T),
read.table,
sep="\t",
header=T,
fill=T,
quote=""))
sub_num <- merge(sub, num, by = "adsh", all.x = TRUE, all.y = FALSE)
sub_num <- sub_num[sub_num$coreg == "",]
sub_num <- sub_num[sub_num$form == "10-K" | sub_num$form == "10-K/A",]
sub_num <- sub_num[grepl("us-gaap", sub_num$version),]
sub_num_tag <- merge(sub_num, tag[,c("tag","datatype")], all = F)
if (year==2012) {
common_tax <- unique(sub_num_tag$tag)
} else {
common_tax <- common_tax[which(common_tax %in%
unique(sub_num_tag$tag))]
}
}
write.table(common_tax, "common_standard_tags.csv", sep = ",", col.names =
F, row.names = F)