Many, many blank lines deleted.

On Jun 1, 2012, at 2:53 AM, Akkara, Antony (GE Energy, Non-GE) wrote:

Hi iLai,

What you showed below, almost same like I am also expecting.

There is two matrix,

               1) 1st - matrix contain values like this,

                               ABC       XYZ     PQR       ABC_CHECK
XYZ_CHECK       PQR_CHECK
                               ----         ----     ----
----------------      --------------       -----------------
                                10          20         30
                               40          50         60
                               70          80         90

               2)2nd matrix have some conditions, need to check with
1st matrix columns. Like this,

                               CHECK FOR
CONDITION
                               --------------
-----------------
                               ABC_CHECK
ABC > 10 & XYZ < 30 & PQR <90

                               XYZ_CHECK
ABC > 9 & XYZ < 25 & PQR <60

                               PQR_CHECK
ABC > 60 & XYZ < 79 & PQR <100


Here I need to change the cell content that already created
["ABC_CHECK"," XYZ_CHECK"," PQR_CHECK"]

So,
               Finally the result should get like this,

                               ABC       XYZ     PQR       ABC_CHECK
XYZ_CHECK       PQR_CHECK
                               ----         ----     ----
----------------      --------------       -----------------
                                10          20         30
FALSE                    TRUE                     FALSE
                               40          50         60
FALSE                    FALSE                    FALSE
                               70          80         90
FALSE                    FALSE                    TRUE

And can please tell me which is the best way to do this ?, Can we do
this with-out loop ?

And, Is it possible to put any other character instead of TRUE & FALSE
?, like this

Here

For TRUE = T , FLASE = F
                               ABC       XYZ     PQR       ABC_CHECK
XYZ_CHECK       PQR_CHECK

                               ----         ----     ----
----------------      --------------       -----------------
                                10          20         30
F                              T                              F
40 50 60 F
F                              F
70 80 90 F
F                              T


Can I get an immediate reply ?

I would like to ask why you think you deserve an "immediate reply"? You are posting data structures in a completely ambiguous manner. Had you instead posted the names of these structures and the output of dput() on each of them there might have be a basis for immediate response. As it is I see no reason to try to guess what class these items might be after reconstruction from the mail-client-mangled output you offered.

--
David.

- Thanks

Antony.

From: ila...@gmail.com [mailto:ila...@gmail.com] On Behalf Of ilai
Sent: Wednesday, May 30, 2012 10:35 PM
To: Akkara, Antony (GE Energy, Non-GE)
Cc: r-help@r-project.org
Subject: Re: [R] Separate Array Variable Content

If you haven't done so you *must* read an Introduction to R. The only
reason this is a problem is Myarray is a character string, not a
function or expression to be evaluated. I think this will get you what
you want though:

# In the future use the output of ?dput to provide data to this list
(MyMatrix <- structure(c(10, 20, 30, 40, 50, 60, 70, 80, 90), .Dim =
c(3L,
3L), .Dimnames = list(NULL, c("ABC", "PQR", "XYZ"))))

# DO NOT use rich font !!! in plain text it adds '*' to the bold names
which is more than annoying...
MyArray <-  c("ABC>50","PQR<50","ABC<30 & XYZ<40")

# finally the answer:
sapply(MyArray,function(x) eval(parse(text=x),as.data.frame(MyMatrix)))

HTH

On Wed, May 30, 2012 at 12:44 AM, Rantony <antony.akk...@ge.com> wrote:

Hi,

I am new in R,

i have a matrix like this

MyMatrix <-
*ABC   PQR    XYZ*
10       20        30
40       50        60
70       80        90

And, i have an array containing some conditions like this,
MyArray <-  c("*ABC*>50","*PQR*<50","*ABC*<30 &* XYZ*<40")

"ABC>50"
"PQR<50"
"ABC<30 & XYZ<40"

My purpose what is, i need to check this conditions in *MyArray* with
*MyMatrix* value for particular column

How it is possible ?

- Thanks

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to