I'm probably missing something dumb here but I'm using a filter command to only include certain values in a characteristic. They are still showing in the table but display NA. Is there a way to prevent them from appearing at all?
sample output
gts.fmlh.dc.arrival.triagestart.area = fmlh.dc |>
filter(primary_care_area == "Blue" | primary_care_area == "Green" |primary_care_area == "Red" | primary_care_area == "Yellow" | primary_care_area == "Midtrack" | primary_care_area == "Trauma") |>
select(primary_care_area, arrival_to_triage_start) |>
tbl_continuous(
variable = arrival_to_triage_start,
statistic = ~"Median {median} \n Mean {mean}",
label = list(
primary_care_area ~ "Team",
arrival_to_triage_start ~ "Door to Triage")
Related
enter image description hereI'm making an inventory system code and I'm a bit stuck finding a solution to the substraction problem, when I choose "ADD" and entering the input the formula wasn't getting the accurate outcome. For example, if I input Paper001 then its quantity, the output is fine at first but when input another item, the deduction instead becoming addition or sometimes doesn't do anything.
I tried dividing the values in the dictionary in 3 conditions but it turns out even worse.
while True:
try:
bg = float(input("Enter your budget : "))
print("-----------------------------------------------------------")
print(" Item name Item code Item price(Per set) \n")
print("1.Bond Paper : Paper001 100 PHP\n2.Yellow Paper : Paper002 50 PHP\n3.Intermediate Paper : Paper003 20 PHP\n\n")
s = bg
except ValueError:
print("PRINT NUMBER AS A AMOUNT")
continue
else:
break
a ={"name":[], "quant":[], "price":[]}
# converting dictionary to list for further updation
b = list(a.values())
# variable na value of "name" from dictionary 'a'
na = b[0]
# variable qu value of "quant" from dictionary 'a'
qu = b[1]
# This loop terminates when user select 2.EXIT option when asked
# in try it will ask user for an option as an integer (1 or 2)
# if correct then proceed else continue asking options
while True:
try:
print("-----------------------------------------------------------")
ch = int(input("1.ADD\n2.STORAGE LIST\n3.Customer purchase\n4.EXIT\nEnter your choice : "))
except ValueError:
print("\nERROR: Choose only digits from the given option")
continue
else:
# check the budget is greater than zero and option selected
# by user is 1 i.e. to add an item
if ch == 1 and s>0:
p_list={'Paper001':100,'Paper002':50,'Paper003':20}
pn = input("Enter item code : ")
if pn in p_list.keys():
q = int(input("Enter quantity : "))
else:
print("-----------------------------------------------------------")
print("Code is invalid")
continue
#checks if item name is already in the list
if pn in na:
ind = na.index(pn)
# remove quantity from "quant" index of the product
qu.remove(qu[ind])
# new value will be added to the previous value of user's quantity
qu.insert(ind, q)
tpr = (q+q)*p_list[pn]
print(f" Total product price:",tpr)
s = bg-tpr
print("\namount left", s)
else:
# append value of in "name", "quantity", "price"
na.append(pn)
# as na = b[0] it will append all the value in the
# list eg: "name"🙁"rice"]
qu.append(q)
# after appending new value the sum in price
# as to be calculated
tpr = q*p_list[pn]
print("\nTotal product price:",tpr)
s = bg-tpr
if s==0:
print("No more budget left")
print("\nAmount left :", s)
elif s>0:
print("\nAmount left :", s)
else:
print("Insufficient budget. Cannot buy item.")
print("Please restart and re-enter your budget.")
break
elif ch ==2 :
print("\n\n\nStorage list")
print("Item name Stocks ")
for i in range(len(na)):
print(f"{na[i]} {qu[i]}")
continue
elif ch == 3:
print("-----------------------------------------------------------")
p_list={'Paper001':100,'Paper002':50,'Paper003':20}
print("\n\n\nStorage list")
print("Item name Stocks ")
for i in range(len(na)):
print(f"{na[i]} {qu[i]}")
co = input("\nEnter customer's order : ")
if co in p_list.keys():
q = int(input("Enter quantity : "))
sl = qu[i]-q
print("Item is sold!")
print("Stocks left :",sl)
if sl <=0:
print("Please add new items!")
else:
print("-----------------------------------------------------------")
print("Code is invalid")
continue
elif ch==4:
print("")
print("\nThank your for shopping with us!")
break
elif s==0:
print("NO BUDGET LEFT. UNABLE TO ADD ITEMS.")
else:
print("ERROR: Choose only the digits given from the option.")
I have a set of data like this:
I love
Hong Kong
I love Hong Kong and Japan.
and Japan.
test.
just a
This is just a test.
I would like to keep the longest ones while removing those partially matched with them. the desired result:
I love Hong Kong and Japan.
This is just a test.
but the actual result is
I love
I love Hong Kong and Japan.
This is just a test.
Here are my code in AHK:
FileEncoding, UTF-8
FileSelectFile, FileName
FileRead, Var, %FileName%
lines_master := StrSplit(Var, "`r`n")
l :=lines_master.MaxIndex()
lines_temp :=[]
Remaining_List =
count_match = 0
While l > 1
{
for i, element in lines_master
{
if (i == 1)
{
master :=element
}
Else
{
if !InStr(master, element)
{
lines_temp.Insert(element)
count_match := count_match + 1
}
}
}
x := l - 1
if (count_match == x)
{
lines_temp.Insert(master)
}
else
{
Remaining_List .=master . "`r`n"
}
count_match = 0
lines_master :=lines_temp
lines_temp :=[]
l :=lines_master.MaxIndex()
}
FileAppend, %Remaining_List%, F:\result.txt, UTF-8
Exit
if I sort the list by length in words, it works. However, I would like to know how to refine the code and make it work no matter what order the list of strings is in.
thank you.
I'd like to append an s to the end of a string, if the value of a variable is > 1.
There are obviously several ways to accomplish this - for example:
if(points == 1) {
points_as_string = "1 Point"
} else {
points_as_string = "\(points) Points"
}
A shorter version could be:
points_as_string = (points == 1 ? "1 Point" : "\(points) Points")
An even shorter version would be:
points_as_string = "\(points) Point" + (points == 1 ? "" : "s")
Is it possible to write something even shorter than that, or is that as good as it gets?
Only very slightly shorter:
points_as_string = "\(points) Point\(points == 1 ? "" : "s")"
Here is a shorter version that uses a dictionary lookup and the nil coalescing operator ??:
points_as_string = "\(points) Point\([1:""][points] ?? "s")"
I've programmed a summary chart, and I'm trying to add a "Totals" line that will sum up three columns. The exercise is comprised of a number of questions, and the participant can increase, decrease or maintain a certain dollar amount. The column B total shows the initial values (where the slider starts off on). The column C shows the amount the participant either increased or decreased and the last column shows the resulting dollar amount. (B + C)
Here's an example of the summary chart
Column A --- B ------ C------ D
Question 1 | 100$ | +28$ | 128$ |
Question 2 | 150$ | (10$) | 140$ |
Totals ------| 250$ | +18$ | 268$ |
So far I've been able to program the totals for column B and D, but I can't figure out how to show a total for column C.
class window.CustomSimulator extends window.TaxSimulator
constructor: (#options = {}) ->
super
#updateTable()
update: ->
super
#updateTable()
updateTable: ->
self = this
$table = $('<table class="table table-condensed"><thead><tr><th>Category</th><th>Before</th><th>Your Choice</th><th>After</th></tr></table>')
$tbody = $('<tbody></tbody>')
before_total = 0
after_total = 0
#scope.find('.slider').each ->
$this = $(this)
$parents = $this.parents('tr')
category = $parents.find('.header').clone().children().remove().end().text().replace(/How would you adjust service levels and property tax funding for /, '').replace('?', '')
before = self.tipScaler($this, $this.data('initial'))
your_choice = $parents.find('.value').text()
after = $parents.find('.tip-content').text()
if $parents.find('.key').text() == 'Decrease:'
css_class = 'decrease'
your_choice = "(#{your_choice})"
else
css_class = 'increase'
$tr = $("""<tr><td>#{category}</td><td>#{before}</td><td class="table-#{css_class}">#{your_choice}</td><td>#{after}</td></tr>""")
$tbody.append($tr)
before_total += parseFloat(before.replace('$', ''))
after_total += parseFloat(after.replace('$', ''))
before_total = SimulatorHelper.number_to_currency(before_total, precision: 2, strip_insignificant_zeros: true)
after_total = SimulatorHelper.number_to_currency(after_total, precision: 2, strip_insignificant_zeros: true)
$("""<tfoot><tr><th>Totals</th><th>#{before_total}</th></th><th><th>#{after_total}</th></tr></tfoot>""").appendTo($table)
$table.append($tbody)
$('#summary-table').html($table)
I'm pretty new at this so I'm not sure if this is enough information.
Thanks!
I am using the Select Expert to filter on a combination of 3 fields:
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
or
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
In this case it only matches:
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
If I swap the statements around:
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
or
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
Then it only handles
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
It seems to completely ignore the second part of the OR statement. Any idea how to implement an OR in CR?
I've never used CR with a CSV file before, so I don't know how it's handling those empty strings. Try setting the selection formula to "Default Values for Nulls" instead of "Exception for Nulls" with this:
{flatfile_csv.site} = "L"
and
(
{flatfile_csv.burnsnorm}="1"
or {flatfile_csv.burnsguar}="1"
)