所以,我试图从我的数据中删除一个单元格。问题是正常功能不起作用:
data[-1,]
data[-1,-1]
data$x = NULL
等
这就是我的主要代码的样子:
data_rd <- data_rd[-1,] ## I could delete one row but can't the next one.
## Create an empty matrix
name_cols <- paste0("F", rep(1:20, each = 4), "_", 1:4)
name_columns <- c("Description", name_cols)
mat_master_EOD <- matrix(0, nrow = length(data_rd[,1]),ncol = 81)
colnames(mat_master_EOD) <- name_columns
rownames(mat_master_EOD) <- data_rd[,1]
我要删除的单元格: http://imageshack.com/a/img32/6227/hy0s.jpg
我使用rbind.fill
函数对某些数据文件进行分组,这可能是我无法删除此单元格的原因。
编辑: 这只是我能为你做的事情:
dput(data_rd[1:3, 1:3])
structure(list(X = c("Accession", "ZZ_FGCZCont0025", "ZZ_FGCZCont0099"
), X.1 = structure(c(29L, 22L, 20L), .Label = c("", "1", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "2", "20",
"21", "23", "25", "27", "28", "29", "3", "34", "4", "5", "6",
"7", "8", "9", "Peptide count", "22", "24", "26", "30", "31",
"32", "33", "35", "36", "37", "40", "41", "45", "46", "50", "55",
"63", "73", "38", "48", "56", "68", "82", "39", "42", "43", "44",
"58", "67", "76", "90", "59", "49", "54", "71", "65", "51", "53",
"57", "61", "64", "74", "75", "47", "52", "60", "72", "69", "70",
"62"), class = "factor"), X.2 = structure(c(23L, 9L, 15L), .Label = c("",
"0", "1", "10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "2", "28", "3", "4", "5", "6", "7", "8", "9", "Peptides used for quantitation",
"20", "21", "22", "23", "24", "25", "26", "27", "29", "30", "33",
"37", "39", "41", "45", "46", "49", "32", "34", "35", "36", "44",
"68", "40", "43", "47", "66", "88", "42", "59", "58", "52", "71",
"31", "38", "51", "48", "50", "62"), class = "factor")), .Names = c("X",
"X.1", "X.2"), row.names = 2:4, class = "data.frame")
对于新创建的矩阵:
> dput(mat_master_EOD[1:10, 1:10])
structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(10L,
10L), .Dimnames = list(c("Accession", "ZZ_FGCZCont0025", "ZZ_FGCZCont0099",
"ZZ_FGCZCont0126", "ZZ_FGCZCont0146", "AT1G19570", "ZZ_FGCZCont0158",
"AT5G38480", "ZZ_FGCZCont0050", "AT1G07370"), c("Description",
"F1_1", "F1_2", "F1_3", "F1_4", "F2_1", "F2_2", "F2_3", "F2_4",
"F3_1")))
答案 0 :(得分:1)
我到达这里,但这是你想要得到的:
Accession Peptide count Peptides used for quantitation
3 ZZ_FGCZCont0025 34 15
4 ZZ_FGCZCont0099 29 28
如果是这样,你可以这样做:
setNames(data_rd[-1,], sapply(data_rd[1, ], as.character))
请注意,您的Peptide...
列是因素,这对数字列来说非常混乱。您应该考虑使用类似read.csv(file="blahblah", header=TRUE)
的重新导入数据,我认为这样可以解决您的问题。