Dear all, I have a big matrix, where I want to compare, one element of a vector with many others and clear them. For example: In column sil compare elements with other columns (0.734)>-1.0770 in 3rd column, so, color them bold else color them bold red For example:> dput(test)structure(list(Class = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L), sil = c(0.734, 0.734, 0.734, 0.734, 0.734, -0.03, -0.03, -0.03), M201.1637T.1 c(-1.077019059, -1.025923945, -2.025907674, -1.223001413, -1.547348898, -0.376842603, -1.33495095, -0.486811653), M203.1794T.1 = c(-0.884899777, -0.878305283, -1.910526051, -1.446826543, -1.950515819, -0.192865129, -1.669691644, -0.636095942), M205.1950T.1 = c(-1.307163965, -1.022407192, -2.050283307, -1.508604131, -1.710170605, -0.197410826, -1.547129558, -0.780189201 ), M207.2107T.1 = c(-1.378614081, -0.950293267, -1.714837198, -1.827195011, -1.629677288, -0.064343778, -1.598304259, -0.502002575 )), .Names = c("Class", "sil", "M201.1637T.1", "M203.1794T.1", "M205.1950T.1", "M207.2107T.1"), class = "data.frame", row.names c("500002T_D06_19_42", "500030X_B03_19_15", "500059R_G09_19_81", "500061V_H02_13_86", "500078W_D10_6_46", "500082M_D05_18_41", "500105S_B09_15_21", "500120W_B04_19_16") Thanks in advance Nico [[alternative HTML version deleted]]
Post in plain text, not HTML. I would suggest that R is not Excel, and that you do not (shudder) treat it as such. Learn R and use it sensibly. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." H. Gilbert Welch On Sun, Apr 6, 2014 at 7:23 AM, Nico Met <nicomet80 at gmail.com> wrote:> Dear all, > > I have a big matrix, where I want to compare, one element of a vector with > many others and clear them. > > For example: > > In column sil compare elements with other columns (0.734)>-1.0770 in 3rd > column, so, color them bold else color them bold red > For example: > >> dput(test) > structure(list(Class = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L), sil = c(0.734, > 0.734, 0.734, 0.734, 0.734, -0.03, -0.03, -0.03), M201.1637T.1 > c(-1.077019059, > -1.025923945, -2.025907674, -1.223001413, -1.547348898, -0.376842603, > -1.33495095, -0.486811653), M203.1794T.1 = c(-0.884899777, -0.878305283, > -1.910526051, -1.446826543, -1.950515819, -0.192865129, -1.669691644, > -0.636095942), M205.1950T.1 = c(-1.307163965, -1.022407192, -2.050283307, > -1.508604131, -1.710170605, -0.197410826, -1.547129558, -0.780189201 > ), M207.2107T.1 = c(-1.378614081, -0.950293267, -1.714837198, > -1.827195011, -1.629677288, -0.064343778, -1.598304259, -0.502002575 > )), .Names = c("Class", "sil", "M201.1637T.1", "M203.1794T.1", > "M205.1950T.1", "M207.2107T.1"), class = "data.frame", row.names > c("500002T_D06_19_42", > "500030X_B03_19_15", "500059R_G09_19_81", "500061V_H02_13_86", > "500078W_D10_6_46", "500082M_D05_18_41", "500105S_B09_15_21", > "500120W_B04_19_16") > > Thanks in advance > > Nico > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Your question confuses me. Perhaps you are still thinking as though this were Excel? You refer to "a big matrix", but your dput (thank you for that) is actually a data frame. Data frames are a list of columns, each of which can have a different type. "Clear them"? I think set them to NA. You later talk about coloring and formatting... are you printing the matrix using Markdown or LaTeX? You cannot color data directly in R, only upon output. Are you plotting using a heatmap? You also mention comparing one column with multiple other columns. Regardless if this were Excel or not, that would be unclear. Do you want to compare sil with each column separately and create a whole new set of columns containing color names, or compare to the minimum of all columns and make a single column of color names for sil? I think you need to clarify your intent a bit more before I can help. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On April 6, 2014 7:23:56 AM PDT, Nico Met <nicomet80 at gmail.com> wrote:>Dear all, > >I have a big matrix, where I want to compare, one element of a vector >with >many others and clear them. > >For example: > >In column sil compare elements with other columns (0.734)>-1.0770 in >3rd >column, so, color them bold else color them bold red >For example: > >> dput(test) >structure(list(Class = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L), sil >c(0.734, >0.734, 0.734, 0.734, 0.734, -0.03, -0.03, -0.03), M201.1637T.1 >c(-1.077019059, >-1.025923945, -2.025907674, -1.223001413, -1.547348898, -0.376842603, >-1.33495095, -0.486811653), M203.1794T.1 = c(-0.884899777, >-0.878305283, >-1.910526051, -1.446826543, -1.950515819, -0.192865129, -1.669691644, >-0.636095942), M205.1950T.1 = c(-1.307163965, -1.022407192, >-2.050283307, >-1.508604131, -1.710170605, -0.197410826, -1.547129558, -0.780189201 >), M207.2107T.1 = c(-1.378614081, -0.950293267, -1.714837198, >-1.827195011, -1.629677288, -0.064343778, -1.598304259, -0.502002575 >)), .Names = c("Class", "sil", "M201.1637T.1", "M203.1794T.1", >"M205.1950T.1", "M207.2107T.1"), class = "data.frame", row.names >c("500002T_D06_19_42", >"500030X_B03_19_15", "500059R_G09_19_81", "500061V_H02_13_86", >"500078W_D10_6_46", "500082M_D05_18_41", "500105S_B09_15_21", >"500120W_B04_19_16") > >Thanks in advance > >Nico > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.