if-statement

compare values in R when within a string of letters

血红的双手。 提交于 2019-12-25 16:59:17
问题 I need to check if the values of two columns fulfil certain conditions, but the value in one column is within a string of letters. If the value of CURRENT_ID is equal to the value of CURRENT_TEXT_1 or CURRENT_TEXT_2 plus 2, when CURRENT_TEXT_1 or CURRENT_TEXT_2 are equal to DISPLAY_BOUNDARY, then I need in the OUTPUT column a value of 1, otherwise a value of zero. Here are some example lines of my datafile ( df ) and the output I would like to obtain: PARTICIPANT ITEM CONDITION CURRENT_TEXT_1

When making a very simple multiple choice story in Python, can i call a line to repeat if neither of the options are selected [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 16:49:27
问题 This question already has answers here : Asking the user for input until they give a valid response (19 answers) Closed 3 years ago . d1a = input ("Do you want to: A) Approach the house. B) Approach the stable. [A/B]? : ") if d1a == "A": print ("You approach the cottage.") elif d1a == "B": print ("You approach the stables.") else I have only just started learning python and it is my first language so I am just playing about with it, Is it possible for the else statement to ask for the input

Bash Script with if, elif, else

不羁岁月 提交于 2019-12-25 10:02:18
问题 Okay so this is an assignment so I will not put in the exact script here but I am really desperate at this point because I cannot figure something as basic as if's. So I am basically checking if the two arguments that are written in the command line are appropriate (user needs to type it correctly) or it will echo a specific error message. However, when I put in a command with 100% correct arguments, I get the error echo message from the first conditional ALWAYS (even if I switch around the

PHP If Statement conditions not working

浪尽此生 提交于 2019-12-25 09:36:55
问题 if($InboundTextBody === 'Help' OR 'help'){ echo 'help'; } elseif($InboundTextBody === 'Reset'){ echo 'send reset message'; } elseif($InboundTextBody === 'Start'){ echo 'send start message'; } if($InboundTextBody === 'Help' || 'help'){ echo 'help'; } If my $InboundTextBody has the word Help. It will echo Help. If the $InboundTextBody has the word Reset it still echo help. it never echo reset. I need the or in my statement just in case the $InboundTextBody text has up case or lower case text

If..else statement based off array function results

和自甴很熟 提交于 2019-12-25 09:28:26
问题 What I want to happen is to have different URLs be provided based of what the array function result is. Basically, if collectTags is equal to "church" or "concert" it links to A.com else it links to B.com. Here's the code I currently have: caption : function( instance, item ) { var caption, link, collectTags, tags; caption = $(this).data('caption'); link = '<a href="' + item.src + '">Download image</a>'; collectTags = $(this).parent().attr("class").split(' '); tags = $.map(collectTags

Syntax Errors in VBA

笑着哭i 提交于 2019-12-25 09:15:28
问题 I keep getting errors (either else without if or loop without do) in this, and I really have no idea why... can anyone help?! Thanks! Do Until (Range("I4").Value = 0) For i = 2 To lLastrow If Range("G" & i).Value = 0 Then i = i + 1 ElseIf Range("G" & i).Value < 0 Then Do Until (Range("G" & i).Value = 0) For j = 0 To i If Range("F" & i - j).Value < 0 Then Range("F" & i - j).Value = Range("F" & i - j).Value + 1 Else: j = j + 1 End If Application.Calculate Loop ElseIf Range("G" & i).Value > 0

Errors in if statements in R Shiny checkBoxGroupInput

做~自己de王妃 提交于 2019-12-25 08:45:19
问题 I am getting errors in my if statements with checkBoxGroupInput in my R Shiny App. Please ignore the fact that all the plots I want to output are the same - I will change this later. Here is the code: library(shiny) library(leaflet) library(DT) library(ggplot2) library(dplyr) r_colors <- rgb(t(col2rgb(colors()) / 255)) names(r_colors) <- colors() plotdata <- read.csv("C:/Users/Anatoly/Documents/Collatz/RenameLater/RenameLater/MapsAndSuch/RShinyCoral.csv") colnames(plotdata) <- c("Year1",

Re-prompting the user for data input with an if statement

陌路散爱 提交于 2019-12-25 08:42:04
问题 I'm trying to prompt for a first/last name in this code, but I cannot figure out how to re-prompt a user for the name if they forget to fill out the field. Right now if my code does not get any input and the user clicks onwards, I have it so a message box will pop up and then the program will close. I want to be able to just re-prompt for the exact same step without it getting all out of order. This is what I have so far: public void getValues(){ firstName = JOptionPane.showInputDialog(null,

Combine two Bash while loop statements

[亡魂溺海] 提交于 2019-12-25 08:37:47
问题 I am trying to combine 2 different logical statements in a single while loop, but having trouble getting the logic correct so that 2 different checks can be evaluated in the same loop. For example, I have the following 2 logical statements. Logic 1 Determine if the entered username is blank and if it is ask the user to re-enter a different username. echo -ne "User Name [uid]$blue:$reset " read USERNAME USERNAME=$(echo "$USERNAME" | tr "[:upper:]" "[:lower:]") while [[ -z "$USERNAME" ]]; do

Total not adding up

Deadly 提交于 2019-12-25 08:29:13
问题 I'm working on a classwork in high school comp sci class and i have come across this problem. the total is not adding. can someone tell me why? import javax.swing.*; public class TimeSheets { public static void main(String[] args) { String loc; String[] day = new String[7]; String time1; String time2; int location; double total = 0; int num = 1; int x = 0; int y = 0; double clock1 = 0; double clock2 = 0; double hour; loc = JOptionPane.showInputDialog(null, "Enter your Work Location");