- if (original.data) {
- if (!is.null(attr(obj[[1]], "origin"))) {
- if (!file.exists(attr(obj[[1]], "origin"))) {
- warning(paste("the file", attr(obj[[1]], "origin"),
- "cannot be found,
-the original data won't be written with the tree."))
- original.data <- FALSE
- }
- else {
- ORI <- scan(file = attr(obj[[1]], "origin"), what = character(),
- sep = "\n", skip = 1)
- start <- grep("BEGIN TAXA;", ORI)
- ORI <- ORI[-(1:(start - 1))]
- ORI <- gsub("ENDBLOCK;", "END;", ORI)
- endblock <- grep("END;", ORI)
- start <- grep("BEGIN TREES;", ORI)
- end <- endblock[endblock > start][1]
- cat(ORI[1:(start - 1)], file = file, append = TRUE, sep = "\n")
- ORI <- ORI[-(1:end)]
- }
- }
- else original.data <- FALSE
- }