所以,我想從我的數據中刪除單個單元格。問題是,一個正常的功能不起作用:如何刪除單個單元格?
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
函數來分組一些數據文件,這可能是我無法刪除這個cell的原因湖
編輯: 這只是我能爲你做:
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")))
你能輸(數據[1:10,1:10])嗎? – BrodieG
完成。我想通過設置它的名稱來輕鬆訪問第一列。 –
「刪除單元格」是什麼意思?永遠不能刪除矩陣中的單元格,只能刪除其內容。 –