Vertices overlap when there's only one component in igraph - r

So I noticed that the default layout in igraph sometimes behave weird when there's only one component of the graph, specifically vertices form a cluster that overlap. Consider the following matrix:
mat <- 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, 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, 1, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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, 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 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,
1, 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, 1, 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(65L, 65L), .Dimnames = list(
NULL, NULL))
g <- graph_from_adjacency_matrix(mat)
plot(g)
Compared to when I add vertex 29 to the main component
mat[29, 44] <- 1
g <- graph_from_adjacency_matrix(mat)
plot(g)
In which case I get the following figure which is much uglier.
Of course, I can work around this by adding an invisible vertex or by creating my own layout but I would like to know why this happens or what is an appropriate layout, similar to the default layout, in the igraph package that doesn't cause the vertices to overlap when I remove the singleton component.

You can try
plot(add_edges(g, c("29", "44")), layout = layout_nicely(g))

Related

R: How can I convert list of lists data into a dataframe

I have a list of lists of matrices as shown below, I have posted the code that got me closest to my desired format and some reproducible data.
Here is picture showing the format of my data:
I would like it to be in a dataframe format, similar to that shown below:
V1 V2
1 2
1 2
1 2
1 2
1 2
1 2
The closest I got was with this code:
dt_list <- purrr::map(a, data.table::as.data.table)
dt <- data.table::rbindlist(dt_list, fill = TRUE)
But instead of putting the second list into a second row, this code adds it on to the bottom of the column.
Reproducible data:
data <- list(list(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0)))
You can try unlist with option recursive = FALSE, e.g.,
list2DF(unlist(data, recursive = FALSE))
or use data.frame (thank #akrun's comment)
setNames(data.frame(data), paste0("V", seq_along(data)))
I think purrr::map_dfc(data, as.data.frame) may solve your problem.

Why are the number of row results always different to the number of data frame rows and how can I make them match?

I use this loop to connect to Elasticsearch, retrieve some data and add it into my data frame based on a common identifier:
library(elastic); library(jsonlite)
for (i in first_chats_eu$associate) {
firstchats_eu_body <- paste0(
'{"size":1,"query":{"bool":{"must":[{"term":{"associate":"',
i
,'"}},{"term":{"type":"conversation-archived"}}]}},"sort":{"time":"asc"}}'
)
firstchats_eu_connection <- Search(
index = "my_index",
type = "my_type",
body = firstchats_eu_body
)
first_chats_eu$firstChat[first_chats_eu$associate == i] <- fromJSON(toJSON(firstchats_eu_connection$hits$hits), flatten = TRUE)[1]$`_source.time`
}
The problem is that it always produces the following message:
Error in `$<-.data.frame`(`*tmp*`, "firstChat", value = list("2017-06-08T00:17:01.118Z", :
replacement has 445 rows, data has 446
I have looked at other answers on SO but the solutions appear to be specific to each case, and thus not applicable to mine.
What could be causing this?
If it is of any use, this loop sometimes partially succeeds, in that it returns the first 34 results and then fails for all other rows after that point.
Data frame:
structure(list(associate = c("Pm0jYumSjx", "PbjmBqnIdY", "Vq3VblKpZn",
"JUCx0MOygt", "9IxVPXPGvQ", "FUUobAsS2Z", "uflgsKMNze", "VzeedmQuiv",
"BWYbDAIPkr", "PNCzrO3TRA", "zwemlUrxQE", "y19AiLUxLN", "4hhURCoC8H",
"Ak13YJF63y", "aoQI4Ncrt4", "syaulepdzW", "ISdTwUISIG", "wncQ5pXq88",
"MYbsg1E2EQ", "OhkAz5aren", "A2wqC9F1WR", "ZDVmRyHkUY", "n5kKRmTMzj",
"mfek2ukQXk", "9Tz6HWSBTd", "b7JdFFaL7M", "TetbzmItfe", "NfCPXPfA8G",
"fc3QfKEgoI", "lWOiSbqDkN", "PXU7CqGO1S", "kEgnBQeUVH", "Zk182RMS4W",
"vzF3lzDKlx", "92PThwjFeO", "hunSRzc1p9", "n2xvlXoTS3", "AzJIMGGn4I",
"8DAm5dFPtN", "Qk6Dl1wgAG", "b6Z1C2RgYk", "FsHvmjOWu8", "SHqTI9YFFx",
"xhKjx5JJin", "RAPQXUNJbF", "vuq1KKylZY", "sBcaWcjEsk", "B4Z2TYT02E",
"u6iEcDrjRL", "Tv8FVDmFlN", "lTS0ZT24vu", "i2I0kykYo0", "N9Nqwu7XiM",
"0wFw3bY5De", "KEcKE4DRdT", "JcZWhBasDE", "FfLrHsnrT5", "ibOCROEWcG",
"b9K3V27GH7", "1TMLQZS5eR", "Yfo5sO7Hyj", "Q09sg2jrsI", "byzMzoS8QV",
"NKLbLwDA4b", "iKkQUDBXln", "Rutbihe39R", "T00E44PAAf", "PSKIFW2Bi3",
"ewJjvrT8H6", "rudiPWdyHj", "gShZwgHn0m", "dQmluy3ilM", "kO2hP2SNzJ",
"hG8iLjN6BD", "GuDBMuoht6", "AOzBVHetmK", "inSAsVD12e", "tYSXKOEhQB",
"ie5m9sDcd5", "31XpEIYYEd", "qrh9kSiCTh", "6cGqFJB1vh", "VPqvH3dHnz",
"tmg2iLu1f6", "a7nBJlzYRt", "D8jHgvvZfY", "pMwjxAV1iP", "0hD2vZYxf7",
"JFuSGQZmYq", "dCu6ebaRzu", "8kFAGY52xO", "8dq2kAKbnP", "FL3RRY9dbb",
"kJhRRpLQDu", "bRkAyVrvBf", "mMHRUeQEjd", "3ATe60itju", "t1IdGh570n",
"LT7PLxWjKh", "zanyzD8KHy", "zo2fOcIflj", "pLhZhgBSd6", "iTzqXtTlVc",
"6ZGJSIjfUK", "bp0JOkgL2n", "4fHmIsuzoR", "wr8pS9BIGn", "XjBFbgCbA6",
"aBDfBMlyhl", "bjpWS5Zi1d", "1m8RnFavmk", "BCbEV3YcWs", "WO3z2kXsHv",
"W4ziF0GFYp", "Dvdpoq3gZJ", "TeO490YGfr", "sMuDgfHnOY", "IBH2U18pLr",
"iWfUpGFrvN", "JiqDLRGEFX", "kyNo0jk8Z1", "93HElGBOHz", "5ZJCyJrVoO",
"2XS3g6lGJN", "BcLA5ChZHs", "kEVIPyQENZ", "xEHCoCz4kk", "2VP9YQHg0z",
"NE1PnnqgGk", "Ay1r8aB1p3", "KX6pPK8IYt", "oaPI42kqwl", "G8DQ2GKget",
"rrUNVhvaL6", "e1V2GXIIQi", "S1ABORMzvC", "P5SHJFevse", "G5oyD7KyNk",
"96uS2gpKKW", "oVokuIkcBH", "uvZwOIZkhC", "9g3a3lkaqK", "sL3CM1Ydmp",
"CeRfpJxt5l", "gywxLgJfwk", "ykryX7GvTZ", "6G3LCq9dTM", "zcbQHDmYlm",
"vb9zQCBcsC", "CHQR1sudJt", "aSPIsQtBW9", "vUF6TTncxg", "mfZwbqTdqs",
"6KFAVH1JfU", "5VC1MoGAPL", "dBT7WbCPbg", "hsiLXdTOlX", "RYCLZhFY90",
"q9SsmoL8Ig", "eHawNS1jr0", "GVgIzKB9UB", "v1RSMGUZAb", "2arkjePApM",
"FVNiv2T5i2", "2YI036CYSi", "bEe9hMOuPw", "SYHAbSA4Bo", "kIxHklYUvm",
"ea0HZio45e", "bJLyBCIDLq", "UOX1xE4I4m", "DUlIH2h7wi", "MYF1ueeXfe",
"1tOV5TEEK5", "oPt6FcBGj5", "jvyfvuEgaZ", "lNVTpT4hA9", "HqDMYSu1lC",
"al11gInzgN", "hIC4Q5JlBH", "ujvEUtatGU", "wU4B2gFWsH", "UbC2Fnef7t",
"4PMafQHS86", "pzgyPSDDR2", "HajTJzwD6s", "Vmb16EuXQd", "MLImxndCP8",
"JioVLn85XG", "ezeN1Jrfz7", "X3dVvzFpO7", "jXWNcEJF40", "1Dlxb9sFY1",
"I2rDM0GCQY", "ItEc62tlMD", "BQSEE0aw5j", "PcKSaFFCjc", "UZOQv40QpR",
"TpTUfAkH2j", "102Qub695d", "iYMYFVeO3a", "9q6smEyLHE", "Oft5GPL1Kz",
"RNgREArWYp", "6JpBEX0t5E", "FQGSnKhEHZ", "qhH4yU4GF4", "smal1c8nZI",
"XM22Vo5TMb", "wVNGHFxsrw", "bOhSejjY4F", "XstvxG2evH", "YSeaBFnCxC",
"aHvosVBvWF", "ECa32iNWUP", "ntNOwcH86q", "6sBSxrENuN", "TKrEDKGBP4",
"7goCPMibBX", "owne4NwFBU", "DzbUeksk3x", "GFmnRMNXLn", "z03bGKnR4K",
"yrickhqzXO", "orNL3qgRs5", "aZDhxK3MnT", "GfjLnYebLi", "ABzJScG4aF",
"MzDl5sIcEv", "nDPQ5ryX60", "wzYLWcEGt7", "fg4yEOCrMg", "cOxDNFSVJ1",
"N3xJGamqYg", "YCWeSx7FdA", "nS7j6dlHW1", "v8xHPHvF9I", "WTgftXNmQv",
"JhhRGHAiAv", "kA95elFmbl", "6SBhLJ10MA", "zB8PDYd3yi", "Id0K9bUgkh",
"wBkgvnElHb", "kQnwwfc7kJ", "6hNV4Y1C4A", "AmA4Y13eQd", "flON1gpb6N",
"f5DopCEFwK", "boFD2o0FU2", "yd2OuCsCSL", "nDzEFEpz2D", "fweWiQ6x6l",
"G1mT217Z6l", "rFt9fevsgu", "MGtbd36gdp", "K48dwo2BDj", "fzDa2HHq8k",
"q3MmPsZKB4", "O9yTAKQlCN", "tDpjeKpWIY", "wOgm4P7503", "4kXj6O1TWk",
"GTgOP6Ik3U", "AcCdmoQqtn", "F5fwdhj5l3", "AJnCAwFOdi", "ssvby6VgQp",
"qzh7xCHMLl", "T2VySRQ0M0", "0yfnFPWynB", "L7PqHs1f0H", "83GzTa9bxh",
"DOGXIreUyo", "PDsqEWLsu5", "sN3JstovsG", "knZx7l2hsk", "asCBJPBgTg",
"ytAmW9sTAP", "S9vuzwn13O", "nrXFr6Ww5O", "sFUB1beOAx", "CyCvAIDs5q",
"z2jmTzZVAo", "Zdd2fiDPVe", "MOQP5vAj8W", "rjx4tHVh6E", "2G3dquHI2q",
"BruK8mqzVI", "GAB1feRTKE", "TPwJ8jp6j2", "mprSpIdRuJ", "qBaU7KERwq",
"QNfCFKWXv5", "6IdSIlfhrz", "19SMR3CQID", "LxnNlx8DsD", "TEJeH1bZXz",
"bTmafqEayN", "9X18BUOA36", "NoYo4tT3oG", "yj5TyZZyNT", "kPVRWBJRXM",
"H3kVwfzGTe", "vq7qUUqGUr", "GLDCR4av3A", "xiYU2MDc6c", "qOGqanHpjw",
"5BaW31f0Nr", "4dJwcfCqkA", "UJzHhwFZRe", "dec0Qlz3eK", "0l7WDqbZb0",
"MMwd72FDCL", "EDMkdKIWMy", "2zLQmEuKpY", "1SUMAUhkZc", "BxXiWBTb8w",
"zFdVjcL7qz", "pfPOEmMTei", "HzjyCETszF", "b26xszWUlP", "AseQsOAqqY",
"lvDbmLqnyg", "L5WxvWWAyt", "X5WUvRm2BY", "t6XCwcOinz", "FG7pLFG8Uw",
"yLpMyvmHb2", "7Ac9pVAF0B", "sDN9UHNGm4", "9Z1L7RtlA3", "bVb8hjn1ju",
"F4nLAs89VO", "kB4aIQEpkf", "lov4Q42w2B", "jnFjq8covm", "tIuHe5uCaC",
"qsAssEo3Qr", "mW3HVtDHQj", "pFoLBb4EfI", "5UA1lbRTrF", "s1qrkLbTIU",
"RQrW6CtY7C", "xVIb7ymcmW", "Iw3AvXAlZK", "yW0P3oHRKp", "Ivf463pZ3k",
"07OAzJ3LMW", "5nB6O3rLm3", "QsI7HSwDZ6", "YN6V6flLDk", "B5RXoyGmeY",
"gt1VgDERw1", "FS2yKGf1vg", "BpUytkzSeS", "fKFSxBU4QG", "ueBhiB7lig",
"c901c019c5", "MKADBViZNz", "Vcb76RpM0z", "PnIACGOY1I", "EIYwDIB3od",
"B30kGNViyD", "YuAuj81ULa", "HBRNcgXjly", "CNFYrTCnkB", "0NG6oAIhrv",
"39OL0da3JB", "pEYsCPrejG", "imUsAjHivl", "D6QCEqCeEN", "pbARKO6WHG",
"mtx6Brb5rP", "oaLUE44A5W", "AgrZaWAFsg", "yvOMkkIZ1m", "Z6fXosz4Fa",
"2fthCJ5DpQ", "yzDHP6VC3C", "oACH3KkPl4", "OUpJGlVe7Q", "rTUsgI4HB1",
"BG0bfaNntS", "T6DgmUfrMS", "tjMwvgas9N", "gSYzWEbwH6", "6P9pRD9jft",
"h7jgprw5ZI", "9RYqSSNP4s", "pv51ewuo8J", "kPHNzPAsy7", "qDg9oiE5vO",
"8PxDnGjkT9", "czyeqBbnOJ", "uHSx9FbBZy", "Z2mdkJk7Tk", "A9lBq2pPB7",
"1MjXRGUpCL", "oS6oAKFqvi", "Ro2Cpuw7nB", "4LjJWDFiJU", "ASrmSlOd4j",
"f9BBXMzBju", "VHdzp3okgg", "zgCdOvoFoJ", "vm7dLCBAXu", "aohXymMv9M",
"rsATydK2xE", "l6erf0NNN8", "wtcNWItEK5", "XO9BfYHSuJ", "FIsDrDMEM6",
"wThiyvldqW", "n49e2LohLA", "ISPVKeaL8B", "QavdvrKCrJ", "Oc5GaqMvsD",
"dBgH5abgm4", "jbxXIMi5T3", "wOEbpBhvJO", "EcSEO5x8Aa", "IPYmcletaC",
"RccyJrXYSQ", "F044DDAL9U", "xCUcsCDnQd", "wkF3tx7M5N", "RNMO5oH2ce",
"KEUArjG58B", "TfBcBOhVZQ", "BpjQjjlTDg", "wSsnje6q39", "ITAESdcmae",
"XTzpZzZFxy", "UutDWic510", "TMgewBSCgi", "mhEM43wLRC", "FwXswHZJzn",
"jqvBb6v6CY", "1YJDIwy9q2", "ea7Hx9RXNl", "cAYtXFKDvK", "R8DhTwSDmg",
"a54nasvwuX", "bnNkM8nimD", "FSSGwmo5Qh"), accountCreation = structure(c(1521647203.675,
1519339418.982, 1520978846.791, 1521462847.464, 1521219528.448,
1525602918.744, 1521039530.235, 1521026513.49, 1521802344.631,
1523790193.342, 1523699716.79, 1522159355.724, 1520935894.587,
1525529531.887, 1524575967.739, 1521127935.332, 1521047835.094,
1521101424.346, 1520997141.963, 1521025271.346, 1521106469.437,
1520952168.279, 1522939980.072, 1521644559.484, 1520962152.598,
1520946377.448, 1521114036.503, 1523303212.556, 1520948768.796,
1521281304.856, 1521484713.426, 1521314445.804, 1521632072.396,
1524399853.238, 1524063742.962, 1524048668.223, 1521231047.543,
1524157639.65, 1521209831.34, 1521475186.089, 1521724609.138,
1523533039.228, 1523702955.539, 1522488605.67, 1521890183.374,
1521642579.3, 1522228581.673, 1523525372.293, 1521195229.708,
1520940268.528, 1521044364.138, 1527678100.482, 1524600058.621,
1522777239.275, 1523870518.667, 1521369133.225, 1522232575.542,
1521198325.682, 1523360584.136, 1521813258.386, 1521627226.595,
1521033049.721, 1523452387.623, 1522236488.509, 1521198246.297,
1524671994.275, 1521720640.095, 1522242402.263, 1521637447.34,
1521718413.354, 1521290525.148, 1521530545.831, 1521022229.054,
1521054255.295, 1522147616.899, 1521115359.397, 1525349801.15,
1520943213.673, 1523610221.63, 1521478193.229, 1521889281.441,
1523701184.22, 1521810788.09, 1520946831.645, 1521471304.719,
1521561858.612, 1521893506.908, 1521048628.327, 1521116277.724,
1522765167.032, 1521286311.531, 1521125237.2, 1521887929.78,
1525159037.328, 1524135123.072, 1519230466.413, 1521030848.111,
1520956865.733, 1521592739.521, 1521457270.104, 1521736081.412,
1521736093.529, 1522159760.701, 1524053386.664, 1524496291.977,
1524216088.817, 1520936977.191, 1520953090.937, 1521212807.586,
1521803151.728, 1521801343.725, 1524055557.569, 1522767163.557,
1521729513.656, 1524316353.148, 1520935603.264, 1523960278.276,
1521499028.577, 1521643199.88, 1524483302.128, 1525335512.042,
1521373117.292, 1520879030.594, 1521023257.287, 1521022157.451,
1523800300.841, 1520935205.484, 1521738187.203, 1521280970.99,
1521213783.986, 1523970332.086, 1522053669.333, 1521738166.805,
1522945933.897, 1520952792.799, 1524757978.638, 1521111905.664,
1524295064.907, 1521025774.074, 1522320956.043, 1521655757.989,
1521195220.823, 1521016193.598, 1521730985.238, 1521739086.354,
1520936329.814, 1520941866.452, 1521308647.796, 1520942541.479,
1520932451.164, 1520932450.409, 1524233637.038, 1523542112.437,
1521891391.694, 1520941112.597, 1521981704.61, 1524126540.184,
1521452436.923, 1521681150.112, 1521021271.162, 1523113077.121,
1524135121.181, 1521225075.835, 1521200485.608, 1521463364.621,
1522340866.586, 1522675782.65, 1522061257.085, 1520935213.165,
1521111379.722, 1522405319.784, 1521021777.312, 1521062469.007,
1524653489.931, 1521216029.087, 1520932450.074, 1522483910.384,
1521019100.815, 1524483561.903, 1521196200.601, 1521141925.275,
1524608679.675, 1520935615.677, 1524766524.32, 1521019881.426,
1520936989.662, 1523036547.916, 1521196426.438, 1521210908.376,
1521628649.889, 1521280983.286, 1521300046.167, 1524738218.644,
1523543199.814, 1521200519.952, 1524914417.224, 1524652840.984,
1525862276.545, 1521027321.217, 1521104801.584, 1521223553.524,
1521211503.42, 1521921773.167, 1520946989.043, 1523445841.807,
1521725990.924, 1521977244.334, 1521627508.652, 1525969006.645,
1525969022.093, 1521812644.345, 1520932449.817, 1521458377.453,
1521020768.777, 1521304861.478, 1520947823.441, 1521205017.765,
1520953961.96, 1520940974.834, 1523182530.64, 1521886711.101,
1521393592.616, 1521377252.798, 1521455570.819, 1521477410.136,
1524502991.311, 1521568209.362, 1520970930.145, 1523821413.628,
1521541778.729, 1519236437.627, 1523702049.192, 1522173164.254,
1524657516.266, 1521735865.479, 1521466638.454, 1521813538.683,
1521476092.325, 1521150151.59, 1521565928.114, 1522758779.981,
1521479231.715, 1520935850.699, 1521025111.789, 1522867701.541,
1521471989.26, 1524744993.667, 1520950428.393, 1523536553.54,
1522421382.988, 1521546156.87, 1521028394.686, 1521050335.668,
1521020456.866, 1522229659.937, 1521025286.049, 1521122727.912,
1521026467.854, 1521450006.649, 1521219087.52, 1521469866.623,
1521197195.734, 1521105260.349, 1521011471.989, 1521190524.789,
1521452303.022, 1520933421.224, 1521115127.677, 1523884939.943,
1520961138.002, 1521016753.264, 1521016893.143, 1521017010.196,
1521017173.526, 1521017281.13, 1521017606.628, 1521117180.29,
1521117300.792, 1521125450.611, 1521132242.791, 1521205674.621,
1521205950.641, 1521215731.346, 1521459082.156, 1521460316.99,
1521482702.085, 1521482815.695, 1521482903.143, 1521483099.712,
1521483278.868, 1521483371.324, 1521540692.887, 1521543890.489,
1521544034.707, 1521544160.551, 1521544235.273, 1521544330.989,
1521544485.786, 1521544609.88, 1521544764.696, 1521553643.038,
1521553739.931, 1521590910.434, 1521731535.229, 1521731535.928,
1521731546.759, 1521802978.117, 1521886145.182, 1521886194.283,
1521886413.213, 1521889580.687, 1522052985.205, 1522069337.077,
1522063483.939, 1522166738.438, 1522250898.347, 1522340911.64,
1522942459.588, 1523359215.503, 1523397047.86, 1523437988.256,
1523438083.426, 1523445420.319, 1523447633.945, 1523455566.243,
1523458605.986, 1523541116.105, 1523615795.787, 1523879249.334,
1523890699.033, 1523979871.23, 1523980654.125, 1524045405.981,
1524056257.89, 1524154119.955, 1524159979.146, 1524393026.557,
1524393845.931, 1524478733.191, 1524494492.895, 1524495293.313,
1524500425.993, 1524500660.969, 1524585635.173, 1524641288.518,
1524659670.369, 1524667611.839, 1524668269.638, 1524672949.857,
1524673079.627, 1524673178.774, 1524912901.694, 1525006502.237,
1525034518.791, 1525076940.386, 1525079238.038, 1525079979.214,
1525081785.524, 1525083082.759, 1525085456.7, 1525176437.685,
1525253930.6, 1525255054.744, 1525259664.818, 1525261014.423,
1525261500.246, 1525287238.277, 1525346162.325, 1525350313.866,
1525451045.815, 1525686874.633, 1525800629.92, 1525865551.171,
1525877902.633, 1525942349.151, 1525945093.268, 1526141141.217,
1526142261, 1526301362.64, 1526301431.797, 1526301861.592, 1526302079.545,
1526324313.439, 1526327287.226, 1526383076.912, 1526394120.405,
1526394871.906, 1526395540.302, 1526396440.737, 1526467461.013,
1526474515.013, 1526474851.867, 1526474950.656, 1526475027.807,
1526572192.208, 1526899111.332, 1526903749.417, 1526911124.083,
1526978640.406, 1526992033.825, 1527005249.155, 1527062775.068,
1527065597.18, 1527070549.853, 1527072673.61, 1527086220.387,
1527087986.751, 1527149254.527, 1527149382.032, 1527149716.254,
1527149851.777, 1527150283.992, 1527150450.301, 1527150553.517,
1527150666.548, 1527165902.1, 1527165998.747, 1527166128.254,
1527166243.866, 1527170994.7, 1527171081.964, 1527171158.104,
1527171239.335, 1527174965.995, 1527175065.505, 1527236752.65,
1527237081.146, 1527237162.074, 1527237333.16, 1527237518.202,
1527237606.934, 1527237676.797, 1527237786.63, 1527237891.106,
1527237979.302, 1527238310.444, 1527238397.71, 1527238467.749,
1527247882.085, 1527247921.493, 1527253757.25, 1527261991.607,
1527262528.413, 1527590487.952, 1527590606.241, 1527590748.119
), class = c("POSIXct", "POSIXt")), firstChat = list("2017-12-23T19:02:03.112Z",
"2017-06-08T00:17:01.118Z", "2016-12-11T15:20:54.019Z", "2017-03-10T11:41:44.036Z",
"2017-02-07T17:00:13.338Z", "2017-02-09T17:56:32.961Z", "2017-02-06T16:34:19.095Z",
"2017-06-07T12:11:15.257Z", "2017-02-21T14:58:31.850Z", "2017-02-09T15:17:40.920Z",
"2017-02-09T14:43:02.026Z", "2017-02-20T15:37:56.756Z", "2017-03-08T15:04:17.341Z",
"2017-03-03T19:43:19.287Z", "2017-07-16T09:47:28.713Z", "2017-03-30T17:57:47.205Z",
"2017-03-20T20:09:41.879Z", "2017-03-22T15:09:21.433Z", "2017-03-22T19:02:20.977Z",
"2017-04-06T10:46:50.105Z", "2017-04-19T17:12:18.318Z", "2017-04-21T15:21:48.603Z",
"2017-04-20T14:12:07.052Z", "2017-04-21T11:33:10.867Z", "2017-04-20T08:58:52.326Z",
"2017-04-21T13:34:01.145Z", "2017-04-24T17:50:07.694Z", "2017-04-21T11:02:15.512Z",
"2017-05-24T10:56:42.089Z", "2017-05-06T13:26:43.845Z", "2017-05-10T17:44:43.533Z",
"2017-05-04T15:14:47.320Z", "2017-05-16T15:28:05.820Z", "2017-05-17T19:29:16.809Z",
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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA,
446L), class = "data.frame")

Error in solving set of linear equation in R even when the determinant of coefficient matrix is not zero

I have coefficient matrix f as 55 by 55 matrix which det(f) is not zero :
f = structure(c(0.2, 1, 4, 12, 24, 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.25,
1, 3, 6, 6, 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.333333333333333, 1, 2,
2, 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, 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-6, 0.25, 0, 0, 6, 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, -2, 0,
0.333333333333333, 0, 2, 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, -1, 0, 0, 0.5,
1, 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, -1, 0, 0, 0, 1, 0, 0, 0, 0), .Dim = c(55L,
55L))
and a vector p like :
p=c(0.02, 0, 0, 0, 0, 0.03, 0, 0, 0, 0, 0.04, 0, 0, 0, 0, 0.02,
0, 0, 0, 0, 0.03, 0, 0, 0, 0, 0.03, 0, 0, 0, 0, 0.03, 0, 0, 0,
0, 0.03, 0, 0, 0, 0, 0.03, 0, 0, 0, 0, 0.04, 0, 0, 0, 0, 0.04,
0, 0, 0, 0)
To solve f by using solve(f,p) I'm getting the error :
Error in solve.default(f, p) :
system is computationally singular: reciprocal condition number = 1.31432e-16
Since det(f) is not zero and is inverse-able, why I'm getting this error and how could I resolve that ?
If your matrix is near singular you can perform regularization with a truncated SVD or truncated QR.
tsvd(x, nu, tol = 0.1, maxit = 20, tx, v, pca = FALSE)
the solution then is simply the inverse of this multiplied by your vector p.
The tsvd method uses Baglama and Reichel's efficient agumented
implicitly restarted Lanczos method for computing a truncated SVD of
large dense or sparse matrices. The method works best for the hard
case of close to square matrices. For matrices where the row and
column dimensions are very different (tall, skinny or short, fat
matrices), consider the computationally cheaper eigenvalue
decomposition of the small matrix cross product instead.
https://www.rdocumentation.org/packages/scidb/versions/1.2-0/topics/tsvd

R cut based on prespecified levels

I am trying to cut my numeric values such that I also get a count for the number of zeros. Not sure how to accomplish that. These are my goals.
1) I specifically get a count of number of zeros.
2) Option to cut the remaining non-zero values into many different
bins.
Right now I tried this below and I cannot get any count of number of zeros.
c1 <- cut(df$Col1, breaks = seq(0, 1442, by = 53.25))
Expected Output
(0] (0,53.2] (53.2,106] (106,160] (160,213] (213,266] (266,320] (320,373] (373,426] (426,479]
1652 1 6 1 34 6 1 1 8 2
(479,532] (532,586] (586,639] (639,692] (692,746] (746,799] (799,852] (852,905] (905,958]
0 0 4 1 0 0 1 0 0
(958,1.01e+03] (1.01e+03,1.06e+03] (1.06e+03,1.12e+03] (1.12e+03,1.17e+03] (1.17e+03,1.22e+03] (1.22e+03,1.28e+03] (1.28e+03,1.33e+03] (1.33e+03,1.38e+03] (1.38e+03,1.44e+03]
0 0 0 0 0 0 0 0 0
dput(df$Col1)
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, 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, 198, 0, 0, 0, 0,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 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, 204, 0, 0, 0, 207, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 209, 0, 0, 161.19, 0, 0, 106, 0, 0, 0, 0, 0, 0, 0,
0, 100, 0, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 195, 0, 0, 0, 0, 398,
0, 0, 0, 0, 0, 103, 0, 0, 0, 0, 0, 0, 204, 0, 89.37, 0, 0, 0,
0, 0, 0, 194, 0, 0, 0, 0, 212, 0, 0, 0, 0, 212, 211, 0, 402,
219, 0, 0, 244, 194, 0, 183.75, 0, 0, 0, 0, 0, 0, 0, 104, 197,
0, 0, 53.25, 0, 0, 0, 0, 0, 0, 0, 103, 0, 0, 0, 0, 0, 0, 383,
314, 202, 0, 0, 0, 0, 204, 227, 0, 205, 211, 670, 230.39, 0,
0, 110, 801, 595, 0, 0, 0, 438, 0, 397, 203, 209, 0, 209, 0,
258, 0, 0, 213, 0, 201, 174.84, 213, 0, 407, 208, 218, 365.7,
205, 595, 0, 608, 601, 183, 381.56, 421, 1442, 408), label = "Col1", class = c("labelled",
"numeric"))
The ( of (0,53.2] on the left of each bin means an "open-end", meaning values above that boundary. (x is your df$Col1.)
And it looks like you want the table of the cut, so this is the starting point:
head(table(cut(x, breaks = seq(0, 1442, by = 53.25))))
# (0,53.2] (53.2,106] (106,160] (160,213] (213,266] (266,320]
# 1 6 1 34 6 1
Two options. Either use right-closed:
head(table(cut(x, breaks = seq(0, 1442, by = 53.25), right = FALSE)))
# [0,53.2) [53.2,106) [106,160) [160,213) [213,266) [266,320)
# 1652 7 1 32 8 1
(Realize that this will change some of your bin counts, as you can see above.) Or explicitly provide something "to the left" of your first bin:
head(table(cut(x, breaks = c(-Inf, seq(0, 1442, by = 53.25)))))
# (-Inf,0] (0,53.2] (53.2,106] (106,160] (160,213] (213,266]
# 1652 1 6 1 34 6
This retains the original bin counts and ensures you have all of your zeroes (and, if present, any negative values).

Which of elements come together in different data

I'm trying to write a script to analyze my data. Would be great if you can help me with that.
Let's start with my data:
> dput(tbl_alles[1:100,])
structure(list(`10` = 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), `20` = 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), `52.5` = 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.7306675, 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, 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, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.663889907, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.789927058, 0, 0.44201215,
0, 0, 0, 0, 0.134339392, 0, 0.668372028, 0, 0, 0, 0, 0, 0, 0,
0.387740087, 0, 0, 0, 0, 0, 0, 0), `397` = c(0, 1, 0, 0, 0, 0,
1, 0, 1, 0, 0, 0, 0, 0.63953839, 0, 1, 0, 0, 0, 1, 1, 0.81888525,
0.89884151, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0.51459601, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0.75141988, 0, 0, 0, 0, 0, 0, 0, 0, 0.65763553, 1, 0, 0,
0, 0, 1, 0, 1, 0.67607045, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0,
0, 0.80260185, 0, 0, 0, 0, 0, 0, 1), `453.5` = c(0, 0.66069369,
0, 0, 0, 1, 0.57541627, 1, 1, 0, 0, 0, 1, 0.64615661, 0, 0.45209671,
0, 0, 0, 0.17022498, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0.02056466, 0.08765142, 1, 0, 0, 0, 0, 0, 1, 0.53107365,
0, 0, 1, 0, 0.47454662, 1, 0.58701126, 1, 0.83194495, 0, 0, 1,
0, 0, 0, 0, 0.04550448, 0, 1, 0, 0.65763553, 1, 1, 0.05581525,
0, 0, 0.78992706, 1, 0.80859968, 0.80441503, 1, 1, 0, 0.5866736,
0, 0, 0.75623688, 0.36602167, 0, 0, 1, 0, 0.31053744, 1, 0.52549512,
1, 0, 0, 0, 0, 0.51742419), `529` = c(0, 0.521435654, 0, 0, 1,
0, 0.175996209, 0, 0, 0, 1, 0, 0, 0, 0, 0.886059888, 0, 0, 0,
0.17022498, 0, 0, 0.643526362, 0, 0, 0, 0, 0, 0.438237074, 0.01594858,
0, 0.383182117, 0, 0, 0, 0, 0, 0, 1, 0.101027654, 1, 0, 0, 0,
0, 0, 0, 0.733614607, 0.89648659, 0, 0, 0.703255538, 0, 1, 0.383200069,
0.868653232, 1, 0.065540432, 0, 0, 0.221275397, 0.229618981,
0, 0, 0, 0.14131076, 0, 0.665883882, 0, 0.399096177, 0.570186116,
0.917797708, 0.349222091, 0, 0, 0.872987981, 0, 0, 1, 1, 0.58275186,
0, 0.211497647, 0, 0, 0.929066091, 0.826799766, 0, 0, 0, 0, 0.148043509,
0.802601847, 1, 0.780383116, 0, 0, 0, 0, 0.340224249), `580` = c(0,
0.437291195, 0, 0, 1, 0, 0.20731698, 0, 0, 0, 1, 0, 0, 0, 0,
0.719755907, 0, 0, 0, 0.033248127, 0, 0, 0, 0, 0, 0, 0, 0, 0.443305568,
0, 0, 0.558877749, 0, 0, 0, 0, 0, 0, 1, 0.171621995, 1, 0, 0,
0, 0, 0, 0, 0.28952456, 1, 1, 0, 0.470920245, 0, 0.690299657,
0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0.111377617, 0.740623952, 0,
0, 0.53029633, 0, 0.917797708, 0.395559317, 0, 0, 0.484708125,
0, 0, 0.174273053, 0, 0.693355663, 0, 0.050471201, 1, 0, 0, 1,
0, 0, 0, 0, 0.698359908, 0.298609118, 0.702753583, 0.926794372,
0, 0, 0, 0, 0.320673115), `630.5` = c(0, 0.52204783, 0, 0, 0,
0, 0.48815538, 0, 0, 0, 0, 1, 0, 0, 0, 0.82709638, 0, 0, 0, 0.09539534,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0.45656691,
0.74836669, 0, 0, 0, 0, 0, 0, 0, 0.95701562, 1, 0, 0.67884433,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0.65763553,
0, 0, 1, 0, 0, 0.77875219, 0, 0, 0.25002477, 0, 1, 0, 0, 0, 0,
0, 0.82679977, 0, 0, 0, 0, 0.84843874, 0.38138487, 0.79820877,
0, 0, 0, 0, 0, 0.51876177), `683.5` = c(0, 0.52429838, 0, 0,
0, 0, 0.59605685, 0, 0, 0, 0, 0, 0, 0, 0, 0.27845748, 0.28224351,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0.94942976, 0, 0, 0, 0, 0, 0.74467188, 0, 0, 0.31501511,
0, 0, 0, 0, 0, 0, 0, 0.73190143, 0, 0, 0, 0, 0, 0.90254266, 0.42921624,
0, 0, 0.56841245, 0, 0, 0.48306937, 0.54177946, 0, 0.70689046,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.72875619, 0, 0, 0, 0, 1, 0.26676304,
0.77778861, 0, 0, 0, 0, 0, 0.17064527), `735.5` = c(1, 0.3768651,
0, 1, 0, 0, 0.51381348, 0, 0, 0, 0, 0, 0, 0, 0, 0.39914361, 0.22206677,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0.42663351, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.61727598,
0, 0, 0, 0, 0, 0, 0.70045244, 0, 0, 0, 0, 1, 0.62631217, 0, 0,
0, 0, 0, 0, 0.14653411, 1, 1, 0.27513455, 0, 0, 0, 0, 0.75025613,
0, 0, 0, 0, 0, 0.92484335, 0, 1, 0, 1, 0.84843874, 0.12198269,
0.58556836, 0, 0, 0, 0, 0, 0.09714178), `784` = c(0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.45656691, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0.61727598, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0)), .Names = c("10",
"20", "52.5", "81", "110", "140.5", "189", "222.5", "278", "340",
"397", "453.5", "529", "580", "630.5", "683.5", "735.5", "784",
"832", "882.5", "926.5", "973", "1108", "1200"), row.names = c("at1g01050.1",
"at1g01080.1", "at1g01090.1", "at1g01220.1", "at1g01420.1", "at1g01470.1",
"at1g01800.1", "at1g01910.5", "at1g01920.2", "at1g01980.1", "at1g02020.2",
"at1g02100.2", "at1g02130.1", "at1g02140.1", "at1g02150.1", "at1g02500.2",
"at1g02560.1", "at1g02780.1", "at1g02880.3", "at1g02920.1", "at1g02930.2",
"at1g03030.1", "at1g03110.1", "at1g03130.1", "at1g03210.1", "at1g03220.1",
"at1g03230.1", "at1g03310.2", "at1g03330.1", "at1g03475.1", "at1g03630.2",
"at1g03680.1", "at1g03870.1", "at1g03900.1", "at1g04130.1", "at1g04170.1",
"at1g04190.1", "at1g04270.2", "at1g04350.1", "at1g04410.1", "at1g04420.1",
"at1g04530.1", "at1g04640.2", "at1g04690.1", "at1g04750.2", "at1g04810.1",
"at1g04850.1", "at1g04870.2", "at1g05010.1", "at1g05180.1", "at1g05320.3",
"at1g05350.1", "at1g05520.1", "at1g05560.1", "at1g05620.2", "at1g06000.1",
"at1g06110.1", "at1g06130.2", "at1g06290.1", "at1g06410.1", "at1g06550.1",
"at1g06560.1", "at1g06570.1", "at1g06620.1", "at1g06650.2", "at1g06680.2",
"at1g06900.1", "at1g07080.1", "at1g07110.1", "at1g07140.1", "at1g07240.1",
"at1g07250.1", "at1g07440.1", "at1g07750.1", "at1g07780.4", "at1g07890.8",
"at1g07990.1", "at1g08110.3", "at1g08200.1", "at1g08360.1", "at1g08490.1",
"at1g08520.1", "at1g08550.2", "at1g08820.2", "at1g08830.2", "at1g08980.1",
"at1g09010.1", "at1g09020.1", "at1g09130.2", "at1g09210.1", "at1g09300.2",
"at1g09310.1", "at1g09340.1", "at1g09430.1", "at1g09490.2", "at1g09620.1",
"at1g09640.1", "at1g09750.1", "at1g09760.1", "at1g09780.1"), class = "data.frame")
As you can see most of cells contain a number "0".
I would like to create a subsets of my data. Let's call them "clusters". I would like to put in the same cluster "elements" (row.names) which has any value (different than 0) in the same column.
So for example:
row.name Column1 Column2 Column3 Column4
at1g02560.1 0 0.12 0 0
at1g02020.2 1 0 0.55 0.31
at1g14560.2 0.15 0.47 0 0
As you see at1g02560.1 has a value only in column 2, there is one more row which contains any value in the column 2, it's at1g14560.2. That means that they belong to the same cluster (let's say cluster 1).
The problem is that at1g02020.2 and at1g14560.2 has a value different than 0 in the column 1. They should be in the same cluster aswell (cluster 2).
In summary at1g14560.2 belong to two different clusters (cluster 1 and cluster 2).
As a result I would like to add additional column to my data named clusters and fill it with the numbers.
Example:
row.name data data data data Clusters
at1g02560.1 1
at1g14560.2 1,2
at1g02020.2 2
Is it even possible to do with R ?
Yes, it is possible to do with R. Here's one way using apply:
res <- cbind(tbl_alles,
Clusters=apply(tbl_alles, 1, function(x) paste(which(x!=0), collapse=",")))
head(res[, c(1:5, ncol(res))])
# 10 20 52.5 81 110 Clusters
# at1g01050.1 0 0 0 0 0 17
# at1g01080.1 0 0 0 0 0 11,12,13,14,15,16,17
# at1g01090.1 0 0 0 1 0 4
# at1g01220.1 0 0 0 0 0 17
# at1g01420.1 0 0 0 0 0 13,14
# at1g01470.1 0 0 0 0 0 12
You may also try:
indx <- which(!!tbl_alles,arr.ind=T)
tbl_alles$Clusters <- tapply(indx[,2],indx[,1], FUN=paste, collapse=",")
tbl_alles[1:5,c(1:5, ncol(tbl_alles))]
# 10 20 52.5 81 110 Clusters
#at1g01050.1 0 0 0 0 0 17
#at1g01080.1 0 0 0 0 0 11,12,13,14,15,16,17
#at1g01090.1 0 0 0 1 0 4
#at1g01220.1 0 0 0 0 0 17
#at1g01420.1 0 0 0 0 0 13,14

Resources