cat("this is an example which you can run if you can write to the
file system\n")
## Not run:
#
# # create matrix
# NC <- 5
# NR <- 10
# data <- matrix(rnorm(NC*NR),ncol=NC,nrow=NR)
# rownames(data) <- paste("r",1:NR,sep="")
# colnames(data) <- paste("c",1:NC,sep="")
# data
#
# # create text files
# write.table(data, file="test_matrix_dimnames.dat", row.names=TRUE,
# col.names=TRUE, quote=FALSE)
# write.table(data, file="test_matrix_colnames.dat", row.names=FALSE,
# col.names=TRUE, quote=FALSE)
# write.table(data, file="test_matrix_rownames.dat", row.names=TRUE,
# col.names=FALSE, quote=FALSE)
# write.table(data, file="test_matrix_NOnames.dat", row.names=FALSE,
# col.names=FALSE, quote=FALSE)
# write(colnames(data), file="test_matrix.colnames")
# write(rownames(data), file="test_matrix.rownames")
#
# # generate identical data
# text2databel(infile="test_matrix_dimnames.dat",
# outfile="test_matrix_dimnames", R_matrix=TRUE)
# x <- databel("test_matrix_dimnames")
# data <- as(x, "matrix")
# data
#
# # convert text two filevector format
#
# text2databel(infile="test_matrix_NOnames.dat",
# outfile="test_matrix_NOnames.fvf",
# colnames="test_matrix.colnames",
# rownames="test_matrix.rownames")
# x <- databel("test_matrix_NOnames.fvf")
# if (!identical(data, as(x, "matrix"))) stop("not identical data")
#
# text2databel(infile="test_matrix_NOnames.dat",
# outfile="test_matrix_NOnames_T.fvf",
# colnames="test_matrix.colnames",
# rownames="test_matrix.rownames", transpose=TRUE)
# x <- databel("test_matrix_NOnames_T.fvf")
# if (!identical(data, t(as(x, "matrix")))) stop("not identical data")
#
# text2databel(infile="test_matrix_rownames.dat",
# outfile="test_matrix_rownames.fvf",
# rownames=1, colnames="test_matrix.colnames")
# x <- databel("test_matrix_rownames.fvf")
# if (!identical(data, as(x, "matrix"))) stop("not identical data")
#
# text2databel(infile="test_matrix_colnames.dat",
# outfile="test_matrix_colnames.fvf",
# colnames=1, rownames="test_matrix.rownames")
# x <- databel("test_matrix_colnames.fvf")
# if (!identical(data, as(x, "matrix"))) stop("not identical data")
#
# text2databel(infile="test_matrix_dimnames.dat",
# outfile="test_matrix_dimnames.fvf", R_matrix=TRUE)
# x <- databel("test_matrix_dimnames.fvf")
# if (!identical(data, as(x, "matrix"))) stop("not identical data")
#
# # stupid extended matrix in non-R format
# newmat <- matrix(-100, ncol=NC+3, nr=NR+2)
# newmat[3:(NR+2), 4:(NC+3)] <- data
# newmat[2, 4:(NC+3)] <- paste("c", 1:NC, sep="")
# newmat[3:(NR+2), 3] <- paste("r", 1:NR, sep="")
# newmat
# write.table(newmat, file="test_matrix_strange.dat",
# col.names=FALSE, row.names=FALSE, quote=FALSE)
#
# text2databel(infile="test_matrix_strange.dat",
# outfile="test_matrix_strange.fvf",
# colnames=2, rownames=3)
# x <- databel("test_matrix_strange.fvf")
# if (!identical(data, as(x, "matrix"))) stop("not identical data")
#
# ## End(Not run)
Run the code above in your browser using DataLab