if-statement

Conditionally creating a new column

不羁的心 提交于 2020-01-05 07:47:13
问题 I am fairly certain this is a really obvious question, but I can't figure it out. Lets say I have the following dataset: test <- data.frame(A = c(1:10), B = c(1:10), C = c(1:10), P = c(1:10)) And I want to test, if there is a column called "P", create a new column called "Z" and put some content in it calculated from P. I wrote the following code (just to try and get it to conditionally create the column, I've not tried to get it to do anything with that yet!): Clean <- function(data) { if("P

SQL CONCAT IF Statement?

老子叫甜甜 提交于 2020-01-05 07:03:46
问题 Morning All, Im not to sure how i need to solve my following query... I have the following query which pulls back the desired records in SQL server... SELECT agenda.AgendaItemNumber,Agenda.AgendaName, AgendaType.AgendaTypeDescription, userdetails.fullName FROM Agenda JOIN AgendaType ON AgendaType.AgendaTypeID=Agenda.AgendaTypeID JOIN UserDetails ON Agenda.AgendaID = Userdetails.AgendaID WHERE agenda.AgendaTypeID = '2' AND AgendaItemNumber = AgendaItemNumber AND AgendaName = AgendaName AND

Deleting elements from a list if they do not follow 'if' 'or' statements

守給你的承諾、 提交于 2020-01-05 05:59:29
问题 I am trying to get rid of unwanted variables in a list. I need to have two condition: one is if making sure the values in my array are smaller than a variable A, and the other is making sure they are not equal to another variable B. This code dose not work: original_Ar = [0,1,2,3,4,5,6,7,8,9,10,11,12] new_Ar = [s for s in original_Ar if (s != 2) or (s < 10)] print (new_Ar) while if I split it into two statements (instead of the or statement) - they do work: original_Ar = [0,1,2,3,4,5,6,7,8,9

if condition in xPath/xQuery

别来无恙 提交于 2020-01-05 04:59:10
问题 To concatenate results from xpath, i'm using concat(normalize-space(.), ' ') (Thanks to Dimitre Novatchev). Now i'm wondering how to avoid adding after the last element... I'm thinking about something like: concat(normalize-space(.), if(XXXXX) then ' ' else '') but I couldn't figure out what condition do I have to use. For example, If I'm using xpathExpression/concat(normalize-space(.), ',') and the values requested are (strings) A & B & C & D, the output I'm expecting is A,B,C,D instead of

find and set as variable and if

半世苍凉 提交于 2020-01-05 04:34:28
问题 I'm stucked with using Find and set as variable. I cannot get the result I need. In first sheet I have a column Test with values x or (x). If the value is x I need to copy the value from column EN. If the value is (x) do not copy. the code copies values from column "EN" no matter x or (x) I must have probably an error in using Set stfound Dim ENcolumn Dim xcolumn Dim secrow Dim lastrow Dim totrow Worksheets("List1").Activate Worksheets("List1").Range("A1:C1").Find(What:="EN", MatchCase:=True,

MySQL - Retrieve row value from different table depending on value of row in a table

三世轮回 提交于 2020-01-05 04:32:09
问题 I have a feeling CASE should be used here but I am not sure. I'm trying to take the sex (m/f) from the general table and depending on the sex, get the build from the corresponding table. For example, when the sex is m, the query should know that by going to the males table and selecting the male_build. I put together an output along with a sample query to give an idea of what I'm trying to accomplish: members table member_id | member_name ------------------------ 1 Herb 2 Karen 3 Megan 4

Using user-inputted characters in If/Switch statements

試著忘記壹切 提交于 2020-01-05 04:20:11
问题 I am taking my first Java class, and am having a hard time finishing this assignment. The assignment itself is quite simple. All I have to do is prompt the user to input an integer, a character, then another integer. If the character inputted is +, the two integers should be added together. If the character inputted is -, the two integers should be subtracted. Etc... The problem is that I do not know how to accept a character from the user, then use it in my If/Switch statements. Here are my

Checking for a dictionary key which is a range of integers

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 02:32:45
问题 I'm building a dictionary of manufacturers. It would look something like this: mfgs = {17491: 'DS', 6543: 'AC'} In this scenario, I need to represent a range of integers that all refer to the same manufacturer. (e.g. 1 - 99 are all manufactured by DC) I've seen that you can create a dictionary key in which a range is represented. mfgs = {17491: 'DS', 6543: 'AC', (1,99): 'DC'} Later on, I will have an integer grabbed from an external file. Depending upon the value encountered, I will log the

PHP: Multiple conditions with NOT Equal (!=) operator is not working [duplicate]

那年仲夏 提交于 2020-01-04 17:52:25
问题 This question already has answers here : PHP if not equal(!=) and or (||) issue. Why doesnt this work? (6 answers) Closed last year . Hope u people will be fine. I’m working on a following code in which i want to use multiple php if conditions with multiple not operators (example is below), but when i execute following php code, it always returns true (mean content in always parenthesis always executed) even no condition is true. I want to ask what is the problem in following code. Is there

simplify IF statement with multiple OR || conditions for the same variable

半腔热情 提交于 2020-01-04 13:46:15
问题 Here's my code var something = "four"; if( something == "one" || something == "two" || something == "three" || something == "five" || something == "six" || something == "seven" ){ document.body.innerHTML = "<h1>yes</h1>"; }else{ document.body.innerHTML = "<h1>no</h1>"; } Is there a way to simplify the IF statement given that all the conditions regard the same variable? DEMO 回答1: Try this: var something = 4; if([1,2,3,5,6,7].indexOf(something) > -1) { document.body.innerHTML = "<h1>yes</h1>";