Nothing
###
### write_surmiserelation.R
###
### dependencies: pks, kst, MASS, relation
###
write_surmiserelation <- function (x, filename, format=NULL, sep=',') {
if (!inherits(x, "kmsurmiserelation"))
stop(sprintf("%s must be of class %s!",
dQuote("x"),
dQuote("kmsurmiserelation")
))
else {
mat <- x
if (dim(mat)[1] != dim(mat)[2]) {
stop(sprintf("%s must be a quadratic matrix!",
dQuote("x")))
}
}
ext <- tolower(file_ext(filename))
if (is.null(format)) {
if (ext == "csv") format <- "CSV"
else if (ext == "xlsx") format <- "XLSX"
else if (ext == "ods") format <- "ODS"
else format <- "SRBT"
} else {
if ((ext == "csv") && (format != "CSV"))
warning(sprintf('Storing file in "%s" format in .csv file!', format))
else if ((ext == "ods") && (format != "ODS"))
warning(sprintf('Storing file in "%s" format in .ods file!', format))
else if ((ext == "xlsx") && (format != "XLSX"))
warning(sprintf('Storing file in "%s" format in .xlsx file!', format))
else if (format %in% c("CSV", "ODS", "XLSX") && tolower(format) != ext)
warning(sprintf("Format specification '%s' and filename extension '%s' do nto fit together!",
format, ext))
}
if (format == "CSV") {
if (sep == ',') dec <- '.'
else dec <- ','
if (is.null(colnames(mat)))
write.table(mat, filename, sep=sep, row.names=FALSE, col.names=FALSE)
else
write.table(mat, filename, sep=sep, row.names=FALSE, col.names=TRUE)
} else if (format == "XLSX") {
if (is.null(colnames(mat)))
write_xlsx(as.data.frame(mat), file = filename, col.names=FALSE)
else write_xlsx(as.data.frame(mat), file = filename)
} else if (format == "ODS") {
if (is.null(colnames(mat)))
write_ods(as.data.frame(mat), path = filename, col_names=FALSE)
else write_ods(as.data.frame(mat), path = filename)
} else {
con <- file(filename)
if (is.null(con))
stop(sprintf("Unable to open file %s.", dQuote(filename)))
open(con, open="w")
size <- dim(mat)
if (format == "SRBT") {
cat("#SRBT v2.0 relation\n", file=con)
cat(sprintf("%d\n", size[1]), file=con)
} else if (format != "matrix") {
stop(sprintf("%s must be either %s or %s!",
dQuote("format"),
dQuote("SRBT"),
dQuote("matrix")))
}
colnames(mat) <- NULL
write.table(mat, sep="", file=con, col.names=FALSE, row.names=FALSE)
close(con)
}
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.