tests/testthat/test_dimnames.R

context("dimnames")

data(iris)
xl.workbook.add()
xl[d4]=iris
test1=xl.connect.table("d4",row.names=FALSE,col.names=FALSE)
# expect_identical(has.colnames(test1),FALSE )
# expect_identical(has.rownames(test1),FALSE )
expect_identical(dimnames(test1),list(as.integer(c(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 
	19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 
	35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 
	51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 
	67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 
	83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 
	99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 
	112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 
	125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 
	138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 
	151, 152, 153)), c("d", "e", "f", "g", "h")))
expect_identical(rownames(test1),as.integer(c(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
	21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
	37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 
	53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 
	69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 
	85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 
	101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 
	114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 
	127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 
	140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 
	153)))
expect_identical(colnames(test1),c("d", "e", "f", "g", "h"))

xl.sheet.add()
xlrc[d4]=iris
test2=xl.connect.table("d4",row.names=TRUE,col.names=TRUE)
# expect_identical(has.colnames(test2), TRUE)
# expect_identical(has.rownames(test2), TRUE)
expect_identical(dimnames(test2),list(c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", 
	"12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", 
	"23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", 
	"34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", 
	"45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", 
	"56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", 
	"67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", 
	"78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", 
	"89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", 
	"100", "101", "102", "103", "104", "105", "106", "107", "108", 
	"109", "110", "111", "112", "113", "114", "115", "116", "117", 
	"118", "119", "120", "121", "122", "123", "124", "125", "126", 
	"127", "128", "129", "130", "131", "132", "133", "134", "135", 
	"136", "137", "138", "139", "140", "141", "142", "143", "144", 
	"145", "146", "147", "148", "149", "150"), c("Sepal.Length", 
	"Sepal.Width", "Petal.Length", "Petal.Width", "Species")))
expect_identical(rownames(test2),c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", 
	"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", 
	"24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", 
	"35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", 
	"46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", 
	"57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", 
	"68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", 
	"79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", 
	"90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", 
	"101", "102", "103", "104", "105", "106", "107", "108", "109", 
	"110", "111", "112", "113", "114", "115", "116", "117", "118", 
	"119", "120", "121", "122", "123", "124", "125", "126", "127", 
	"128", "129", "130", "131", "132", "133", "134", "135", "136", 
	"137", "138", "139", "140", "141", "142", "143", "144", "145", 
	"146", "147", "148", "149", "150"))
expect_identical(colnames(test2),c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", 
	"Species"))

xl.workbook.close()
gdemin/excel.link documentation built on Feb. 10, 2024, 5 p.m.