I have a result of a function I wanna export from R to visualize it in Gephi.
The result is 79.552 pairs listed like this
[[79549]]
[1] 22 26
[[79550]]
[1] 41 26
[[79551]]
[1]34 26
[[79552]]
[1]25 26
I wan't the pairs to be exported so I have them like this in .csv
22, 26
41, 26
34, 26
25, 26
I'm using the write.table
function like this, where kj.csv
is my file and kj
is my saved function.
write.table(kj, file = "kj.txt", append = FALSE,
quote = TRUE, sep = ",", eol = "\r\n",
na = "NA", dec = ".", row.names = TRUE,
col.names = TRUE,
qmethod = c("escape", "double"),fileEncoding = "")
A sample from my result .csv file looks like this (not the same numbers)
"c.22..26..483","c.41..26..596","c.34..26..543","c.25..26..773"
Can anyone help me?
You have a list object. You could create a matrix and save it to file. Here some sample data:
kj <- list(c(1,2), c(2,3))
Now create the matrix by treating each entry of the list as a row:
kj <- do.call(rbind, kj)
The matrix looks like this:
> kj
[,1] [,2]
[1,] 1 2
[2,] 2 3
Save the matrix to file:
write.table(kj, "kj.txt")
The file kj.txt
looks as follows:
"V1" "V2"
"1" 1 2
"2" 2 3