Note that there are some explanatory texts on larger screens.

plurals
  1. POreplace values in a list of matrices from an external data.frame
    primarykey
    data
    text
    <p>I have a list of matrices (list1) and a data.frame (df1) and I would like to replace the values (characters) of columns (starting in the third column) in each matrix with the numeric values that match the same character in the data.frame</p> <p>The code that I am using is the following:</p> <pre><code>func &lt;- function(m) { df[,3:dim(m)[2]] &lt;- pvals[match(as.character(unlist(m[,3:dim(m)[2]])), as.character(df1[[1]])), 2] df } list.new &lt;- lapply(list1, func) </code></pre> <p>My real data is comprised of a data.frame with 17,000 rows and a list of matrices with different number of rows (from 6 to 300) and the length of the list is 2508</p> <p>Here is an example <code>dput</code> how looks my data</p> <p>Thanks a lot</p> <pre><code>dput(df1) structure(list(V1 = structure(1:26, .Label = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"), class = "factor"), V2 = c(-1.05472743912239, -0.465387694876923, -1.50964262537451, 0.487940146424352, -0.00535613573109694, -2.55414346097441, 1.15509940021931, 1.64866342884192, -0.020679542693602, -0.975466676313729, 1.44489084009727, 0.34865766217741, -0.164166594564227, 0.2334524300922, -3.00151476863052, -0.162648518811422, -0.562118292072104, 0.530959584228129, -0.696269913233278, 0.510942754508697, 0.313765084303269, -0.572585873036666, -1.33022085052541, 0.983493004888859, 0.135722232469565, 0.857043820782375)), .Names = c("V1", "V2"), row.names = c(NA, -26L), class = "data.frame") dput(list1) list(structure(c("J", "E", "I", "V", "R", "W", "6", "5", "3", "4", "2", "1", "Q", "C", "F", "W", "I", "S", "L", "W", "T", "N", "M", "H", "I", "L", "B", "Q", "T", "X", "I", "X", "R", "V", "H", "S", "M", "I", "H", "L", "W", "B", "P", "G", "N", "L", "I", "Q", "U", "Y", "F", "D", "N", "T", "E", "R", "X", "M", "F", "T", "X", "R", "S", "W", "N", "I", "J", "N", "L", "V", "C", "B"), .Dim = c(6L, 12L), .Dimnames = list(NULL, c("Name", "bd", "P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10"))), structure(c("Z", "K", "F", "H", "L", "O", "N", "S", "W", "V", "J", "A", "G", "I", "C", "E", " 7", "14", " 9", " 8", " 3", " 1", "13", "12", "10", "11", " 2", " 5", "15", " 4", "16", " 6", "M", "R", "S", "O", "K", "W", "B", "D", "C", "J", "A", "H", "U", "Y", "T", "P", "Z", "U", "O", "C", "J", "Q", "E", "L", "X", "R", "G", "B", "M", "F", "T", "W", "D", "P", "Z", "M", "H", "W", "X", "U", "K", "V", "S", "C", "L", "I", "B", "N", "P", "S", "R", "I", "F", "G", "W", "D", "A", "V", "L", "U", "C", "X", "T", "E", "Y", "V", "X", "H", "I", "N", "K", "M", "D", "C", "Z", "L", "W", "F", "B", "Q", "E", "F", "A", "C", "G", "L", "B", "M", "X", "Q", "Y", "S", "W", "P", "K", "R", "Z", "P", "R", "G", "W", "S", "J", "E", "A", "F", "K", "U", "N", "O", "D", "L", "L", "A", "W", "F", "V", "G", "M", "U", "H", "O", "J", "K", "T", "C", "S", "D", "Z", "X", "L", "V", "R", "P", "I", "H", "E", "W", "K", "T", "U", "S", "J", "D", "Q", "V", "J", "Z", "K", "C", "W", "P", "D", "I", "B", "O", "S", "A", "G", "U"), .Dim = c(16L, 12L), .Dimnames = list(NULL, c("Name", "bd", "P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10"))), structure(c("A", "V", "I", "C", "Z", "H", "M", "Q", "R", "S", "X", "E", "K", "T", "W", "U", "J", "G", "L", "D", "P", "B", "O", "F", "N", "Y", "12", "14", " 8", " 2", "18", "21", "10", "19", "25", "26", " 5", "11", " 9", " 1", "23", " 3", "17", "24", " 4", "22", "16", " 7", "20", "13", " 6", "15", "O", "Q", "W", "N", "F", "J", "K", "T", "A", "U", "L", "Z", "R", "P", "M", "Y", "B", "S", "V", "C", "G", "X", "I", "E", "D", "H", "X", "N", "H", "Y", "U", "Q", "B", "O", "S", "E", "J", "L", "F", "A", "M", "P", "Z", "G", "V", "K", "W", "C","R", "I", "T", "D", "G", "C", "Y", "K", "N", "T", "Z", "D", "A", "X", "Q", "J", "V", "W", "I", "U", "R", "F", "O", "S", "L", "P", "B", "H", "E", "M", "T", "I", "O", "W", "Q", "M", "X", "G", "U", "S", "Z", "K", "V", "R", "L", "D", "H", "Y", "J", "A", "B", "F", "P", "C", "N", "E", "X", "Z", "E", "G", "F", "S", "Y", "L", "W", "O", "T", "K", "C", "I", "U", "Q", "N", "A", "D", "R", "P", "M", "V", "B", "J", "H", "R", "B","C", "Z", "H", "J", "V", "K", "M", "F", "S", "U", "N", "A", "L", "W", "D", "Q", "G", "E", "T", "Y", "I", "O", "X", "P", "J", "N", "L", "R", "G", "Q", "I", "A", "D", "E", "C", "O", "F", "Z", "Y", "X", "M", "V", "T", "W", "K", "H", "U", "P", "B", "S", "T", "D", "R", "J", "M", "P", "Y", "Q", "G", "B", "C", "S", "V", "N", "K", "F", "I", "U", "H", "X", "A", "Z", "L", "W", "O", "E", "Q", "Y", "L", "J", "I", "N", "F", "X", "W", "P", "G", "D", "A", "B", "V", "S", "K", "U", "T", "H", "R", "E", "Z", "O", "M", "C", "H", "B", "Q", "V", "S", "Z", "L", "I", "A", "K", "J", "C", "U", "X", "W", "M", "O", "E", "G", "T", "P", "D", "F", "N", "Y", "R"), .Dim = c(26L, 12L), .Dimnames = list(NULL, c("Name", "bd", "P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10")))) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload