An expression with conditions does not work when testing a bpm process created in bpm-explorer alfresco activiti.
${document.attributes['EPR/DMS/DMBTR'] < 10000000
&& document.attributes['EPR/DMS/DMBTR'] >= 5000000
&& document.attributes['EPR/DMS/CONCERN_FLG'] == true}
|| ${document.attributes['EPR/DMS/DMBTR'] >= 10000000}
such options do not work either
${(document.attributes['EPR/DMS/DMBTR'] < 10000000
&& document.attributes['EPR/DMS/DMBTR'] >= 5000000
&& document.attributes['EPR/DMS/CONCERN_FLG'] == true)
|| document.attributes['EPR/DMS/DMBTR'] >= 10000000}
Displays error
Error parsing '${document.attributes['EPR/DMS/DMBTR'] < 10000000 \n&& \n(document.attributes['EPR/DMS/DMBTR'] > 5000000 || document.attributes['EPR/DMS/DMBTR'] = 5000000) \n&& document.attributes['EPR/DMS/CONCERN_FLG'] == true} \n|| ${document.attributes['EPR/DMS/DMBTR'] > 10000000 || document.attributes['EPR/DMS/DMBTR'] =10000000}': lexical error at position 143, encountered invalid character '=', expected expression token
Try using > and < instead of the > and <. This will encode the string correctly and hope it will help solve the issue.
Try this,
execution.setVariable('EPR_DMS_DMBTR', document.attributes['EPR/DMS/DMBTR'])
execution.setVariable('EPR_DMS_CONCERN_FLG', document.attributes['EPR/DMS/CONCERN_FLG'])
${EPR_DMS_DMBTR < 10000000
&& EPR_DMS_CONCERN_FLG >= 5000000
&& EPR_DMS_DMBTR == true)
|| EPR_DMS_DMBTR >= 10000000}
Related
How to simplify the != statements. I have plenty of values like this
if (charNr%2 == 0 && newChar != " " && newChar !="0" && newChar !="1" && newChar !="2" && newChar !="3" && newChar !="4" && newChar !="5" && newChar !="6" && newChar !="7" && newChar !="8" && newChar !="9" ) {newStr = newStr newChar }
I want to use it in AWK AIX 7.1.2 fuctions. Please help me.
I am expecting something like
if (charNr%2 == 0 && newChar NOT IN (1 2 3 4 5 6 7 8 9 0) ) {newStr = newStr newChar }
The in operator in Awk works with array keys, so you can do:
keys["foo"];
"foo" in keys # true
For your example, you would have to create an array containing all the keys first:
keys[1]; keys[2]; keys[3]; # etc.
In this specific case you could use a loop to help you:
for (i = 0; i < 10; ++i) keys[i] # set keys from 0 to 9
newChar in keys # true if newChar is 0-9
In a general case, you can use:
input = "first,second,third,fourth"
n = split(input, temp, /,/)
for (i = 1; i <= n; ++i) keys[temp[i]]
if your black list is single digits there are easier ways, but assuming that you have a list of arbitrary tokens, you can use this trick
awk -v n='t1 t2 t3 t4' 'FS n FS !~ FS $1 FS'
it adds the FS to the beginning and end of the list and check for pattern match with a FS padded keyword (here $1, replace with your variable). Here assuming the default field delimiter is used, otherwise use the same delimiter in the list of tokens.
For example,
$ awk -v n='11 13 17 19' 'FS n FS !~ FS $1 FS' < <(seq 10 20)
10
12
14
15
16
18
20
if your list is arbitrary single chars (or digits), you can simplify it to
$ awk 'FS $1 FS !~ / [2357] /' < <(seq 10)
1
4
6
8
9
10
To simplify the != is to have the unwanted values in an array and to (value in array==0), like this:
$ awk '
BEGIN {
for(i=0;i<=9;i++) a[i] # add values 0...9 to array a
}
($1 in a==0) { # if value is not found in array
print # print it
}' <(seq 1 12) # test values
10
11
12
I have a data matrix 1200 (row, sample name)* 20000 (col, gene name), I want to delete row when my interested 5 genes have zero values in all samples
command I used for single gene:
allexp <-preallexp[preallexp$GZMB > 0, ]
but I want to use AND in above command, like this:
allexp <-preallexp[preallexp$GZMB && preallexp$TP53 && preallexp$EGFR && preallexp$BRAF && preallexp$VGEF > 0, ]
but this command doesnt work, please I need your help..How to use AND in above command.
EDIT: in response to OP.
I'm sure there's a much more efficient way to code this, but this is what you're after:
allexp <-preallexp[preallexp$GZMB + preallexp$TP53 + preallexp$EGFR +
preallexp$BRAF + preallexp$VGEF > 0, ]
Unless you have negative expression values I would have thought mkt's should work. But here is mine. It will remove values rows where each of the 5 genes and a value of 0
which(preallexp$GZMB == 0 && preallexp$TP53 &&
preallexp$EGFR == 0 && preallexp$BRAF == 0 && preallexp$VGEF == 0)
This gives so the rows where all 5 genes have a value of zero
So we can remove these rows if from the dataframe like follows
allexp <-preallexp[
-(which(preallexp$GZMB == 0 && preallexp$TP53 &&
preallexp$EGFR == 0 && preallexp$BRAF == 0 && preallexp$VGEF == 0)), ]
I have two dates which im loading into variables using
a=`date +%s`
b=`date +%s`
i want to know the difference between times e.g difference 00:00:10 and so on , i do calculate it using
diff=$(( b-a ))
echo "$(( diff/3600 )):$((( diff/60)%60)):$((diff%60))"
but the output is 0:0:07 , how can i convert it on 2points = on 00:00:07?
If the string length is 1 then added the zero with value
hour=$(( diff/3600 ))
min=$((( diff/60)%60))
sec=$((diff%60))
[[ ${#hour} == 1 ]] && hour="0$hour" || hour="$hour"
[[ ${#min} == 1 ]] && min="0$min" || min="$min"
[[ ${#sec} == 1 ]] && sec="0$sec" || sec="$sec"
echo "$hour:$min:$sec"
Output:
00:00:16
I want to return a value in a column, or NA, contingent on values in other columns.
I basically want to see if the value in the column meets the first test criteria:
df$v2.1 >= df$varx & df$v3.1 <6
if not does it meet the second:
df$v4.1 >= df$vary & df$v5.1 >5
and then if neither return NA
The code I have tried is below.
df$v1.1 = ifelse(df$v2.1 >= df$varx & df$v3.1 <6 || df$v4.1 >= df$vary & df$v5.1 >5 ,df$v1.1, NA)
Your only mistake is using || rather than |. || is not vectorised, and only considers the first element. All your other operators (and ifelse()) are vectorised, so the following should work as expected:
df$v1.1 = ifelse(df$v2.1 >= df$varx & df$v3.1 <6 | df$v4.1 >= df$vary & df$v5.1 > 5, df$v1.1, NA)
A good way to check when you're doing reasonably complex or multiple logical operations is to run each one of them and see if you're getting the expected output. If you run:
df$v2.1 >= df$varx & df$v3.1 <6
or
df$v4.1 >= df$vary & df$v5.1 > 5
you should get a vector of logical values. If you run:
df$v2.1 >= df$varx & df$v3.1 <6 || df$v4.1 >= df$vary & df$v5.1 > 5
you should get a single logical value. In your case, that will give a single result from the ifelse(), which then gets recycled to fill df$v1.1.
From what I can tell df$v1.1 is already defined, so you only need to modify those rows that fail the test in your ifelse. The following might be easier:
df$v1.1[
which(
!(df$v2.1 >= df$varx & df$v3.1 <6) & !(df$v4.1 >= df$vary & df$v5.1 >5))
] <- NA
For every entry in rows i need to compute two variables as new columns in a data.frame depending conditional on more than 60 other columns. I would like your recommendation on how to realize that elegant (while and for, with, ifelse, foreach, by or ddply?). I don't like to do that manually like i did for the first cases in the example code and i don't care for performance.
Further: Probably i would not need to ask if i would have understood how to use functions like transform (with ddply or by) and what they do. Thus i hope you can recommend good tutorials on that, maybe relating to my case. I found a lot but in different context and was not able to comprehend it entrily or transcribe it for my case.
My case: I have three columns for each of 20 events representing the kind and date of that event. For each row I need to compute (and save to that data.frame) the difference in time between one special event (depending on whether a special kind happened before or after another) and a date fixed for every entry in rows. Furthermore i need to save the date of that event.
This is how i did (it works, but it is running only through the first cases):
#event.2 (1. event month), event.3 (1. event year), event.4 (1. event kind), event.5 (2. event month), event.6 (2. event year), ...
df$dit[(!is.na(df$event.2) & !is.na(df$event.3) & !is.na(df$event.4) & !is.na(df$event.5) & !is.na(df$event.6) & !is.na(df$event.7))
& (
(df$event.4 == 3 & ((1/12*df$event.2)+df$event.3) > df$fixdate) & (df$event.7 == 1 | df$event.7 == 2)
)] = ((1/12*df$event.2)+df$event.3) - df$fixdate
df$date[(!is.na(df$event.2) & !is.na(df$event.3) & !is.na(df$event.4) & !is.na(df$event.5) & !is.na(df$event.6) & !is.na(df$event.7))
& (
(df$event.4 == 3 & ((1/12*df$event.2)+df$event.3) > df$fixdate) & (df$event.7 == 1 | df$event.7 == 2)
)] = ((1/12*df$event.2)+df$event.3)
df$dit[(!is.na(df$event.2) & !is.na(df$event.3) & !is.na(df$event.4) & !is.na(df$event.5) & !is.na(df$event.6) & !is.na(df$event.7))
& (
(df$event.4 == 1 & ((1/12*df$event.2)+df$event.3) > df$fixdate)
| (df$event.4 == 2 & ((1/12*df$event.2)+df$event.3) > df$fixdate)
)] = 0
df$date[(!is.na(df$event.2) & !is.na(df$event.3) & !is.na(df$event.4) & !is.na(df$event.5) & !is.na(df$event.6) & !is.na(df$event.7))
& (
(df$event.4 == 1 & ((1/12*df$event.2)+df$event.3) > df$fixdate)
| (df$event.4 == 2 & ((1/12*df$event.2)+df$event.3) > df$fixdate)
)] = df$fixdate
df$dit[(!is.na(df$event.2) & !is.na(df$event.3) & !is.na(df$event.4) & !is.na(df$event.5) & !is.na(df$event.6) & !is.na(df$event.7))
& (
(
(df$event.4 == 1 & ((1/12*df$event.2)+df$event.3) < df$fixdate)
& (
(df$event.7 == 1 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
| (df$event.7 == 2 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
)
)
|
(
(df$event.4 == 2 & ((1/12*df$event.2)+df$event.3) < df$fixdate)
& (
(df$event.7 == 1 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
| (df$event.7 == 2 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
)
)
)] = ((1/12*df$event.5)+df$event.6) - df$fixdate
df$date[(!is.na(df$event.2) & !is.na(df$event.3) & !is.na(df$event.4) & !is.na(df$event.5) & !is.na(df$event.6) & !is.na(df$event.7))
& (
(
(df$event.4 == 1 & ((1/12*df$event.2)+df$event.3) < df$fixdate)
& (
(df$event.7 == 1 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
| (df$event.7 == 2 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
)
)
|
(
(df$event.4 == 2 & ((1/12*df$event.2)+df$event.3) < df$fixdate)
& (
(df$event.7 == 1 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
| (df$event.7 == 2 & ((1/12*df$event.5)+df$event.6) > df$fixdate)
)
)
)] = ((1/12*df$event.5)+df$event.6)
You can define your conditions as expressions and use them within transform. The idea is to factorize your conditions at most as possible .
COND1 <- expression(!is.na(event.2) & !is.na(event.3) &
!is.na(event.4) & !is.na(event.5) &
!is.na(event.6) & !is.na(event.7))
COND2 <- expression(event.4 == 3 & ((1/12*event.2)+event.3) > fixdate) &
(event.7 == 1 | event.7 == 2))
COND3 <- expression(event.4 == 1 & ((1/12*event.2)+event.3) > fixdate)
COND4 <- expression(event.4 == 2 & ((1/12*event.2)+event.3) > fixdate)
### you continue here with the rest of conditions....
Then using them within transform you can do something like:
transform(df, date = ifelse(eval(COND1) & eval(COND2),((1/12*event.2)+event.3),NA),
transform(df, date = ifelse(eval(COND1) & (eval(COND3)|eval(COND4)),fixdate,NA))
## Note also that the seond "dit" variable is deduced from "date"
transform(df,dit=date-fixdate)