All Questions
Tagged with conditional-statements function
389 questions
0
votes
0
answers
25
views
Ignore empty cell in case of condition
I have :
id= c("2019-08-01", "2019-08-06", "2019-08-10")
bid = c("2", "4", "7")
ask = c("3", NA, "8")
df1 = data.frame(...
1
vote
3
answers
56
views
For every instance if "A" in Column1, create a new column with all values associated with "A" from Column2
Here is an example data frame:
df <- data.frame(Key = c(rep("A", 2), rep("B", 4), rep("C", 3), rep("D", 2)),
DataID = round(runif(11, min = ...
0
votes
0
answers
46
views
How to call an R function conditional on a printed string?
I'm using the tesseract package to mine text from a very large (>500K) set of scanned documents. Some of the documents are rotated the wrong way, so when I call tesseract::ocr on those, the ...
0
votes
0
answers
15
views
Coding and Plotting Haar Wavelet
I am trying to plot Haar Wavelet function using the code below:
#define the t variable
#define the range of the time domain
L = 10
#Define the number of points in the time domain
n = 100
#define the ...
-1
votes
1
answer
46
views
Checking return value of multiple functions in main function, if all functions return False, print ("not involved") [duplicate]
I want to write a code with many functions in it if the output of all functions in the code is False, the code will return "not involved".
Something like the below code:
def func1():
...
-1
votes
1
answer
60
views
Problem while implementing a function in a conditional bash command using background operator (&)
I'm working on a Bash script where I need to show a spinner animation function while checking if a specified Git remote exists. The script snippet for checking the Git remote is as follows:
read ...
0
votes
2
answers
49
views
Function for zeroing time at risk after positive
I am having trouble developing a function for the purpose of zeroing out the "have" column (which is days in-between collection) for 21 days AFTER a positive result, by identifier. At this ...
0
votes
1
answer
25
views
How can I ensure that my code properly handles the asynchronous nature of the Geolocation API callback in JavaScript? [closed]
I am trying to get the end users location and if they are within a service area (poly) let them know. I have managed to get everything functional except the conditional for the output.
I am grabbing ...
2
votes
2
answers
251
views
conditional statements are not getting evaluated inside Makefile function
I have a function in a Makefile where I am trying to evaluate input parameters in ifeq statements like below:
define set_target_dts
ifeq ($(1),virgo)
@echo "Building for Virgo"
...
0
votes
0
answers
87
views
Creating an R function with an argument that determines the language of a column(s) levels
I'm trying to create a function that changes a column's language based on one of the arguments.
Let's say you have a dataset with values for species, written in English. So, for example, there's a ...
-2
votes
1
answer
71
views
How compare if a variable (x) is greater than another variable (y) by a certain value. For example, if x > y by 2, print("Hooray!")
So I'm trying to make a rock, paper, scissors game and I'm trying to make it so that if the user (or computer) either gets 3 points OR the user's (or computer's) score is greater by 2 (like a best 2 ...
1
vote
2
answers
205
views
Condition on arguments of a function in Julia
It is possible to specify the argument type for a function in Julia like : addition(x::Int64,y::Int64). I can, simultaneously, define another function with the same name : addition(x::Float64,y::Int64)...
-1
votes
10
answers
217
views
How do I make my if/else if statement more compact/readable? [duplicate]
I have made a simple Rock Paper Scissors game that can be played in the console. It uses a series of if/else if statements to compare the inputs by the user against the computers selections and ...
3
votes
4
answers
186
views
Assigning multiple variables within a one-line conditional
In my class on Julia, we were shown this basic implementation of a bubble sort:
function bubble_sort!(a)
n = length(a)
for i in 1:n-1
for j in 1:n-i
if a[j] > a[j+1]
...
2
votes
1
answer
212
views
How to insert some functions inside other function to track score for a game?
I am new to javascript and I'm trying to do the rock-paper-scrissors game from the odin project: https://www.theodinproject.com/lessons/foundations-rock-paper-scissors. The functions that get an input ...