How to use create-<breeds>-with between two breed turtle agents? - networking

I've been stuck by this issue for a long time. I have two networks in my model, so I want to create different types of links with different breed turtle agentsets.
Let's name the 1st turtle agentset T1 and the 2nd T2, so what I did is the following:
breed [T1s T1]
undirected-link-breed [TL1s TL1]
breed [T2s T2]
undirected-link-breed [TL2s TL2]
;;Got error report
ask T1s [create-TL1s-with other n-of 10 T1s]
The last line gave an error reporting that "You cannot use breeded and unbreeded links in the same world". I'm quite confused about what this means.
And then, I changed the last line to:
ask T1s [create-links-with other n-of 10 T1s]
It worked this time, but if that's the case, how can I define two different types of links, i.e., TL1 and TL2, with different turtle agentsets T1s and T2s?
Can anybody help me out? I really appreciate it!
Thanks

That error means that you've created some links that have no breed (probably with create-link-with) before creating links with a breed, or vice-versa. If you want to use link breeds, you can never use create-link-with, create-link-to, or create-link-from. You must always use create-<breed>-with, create-<breed>-to, and create-<breed>-from.
So, search your code for instances of create-link-with, create-link-to, or create-link-from and either delete them or change them to create-<breed>-with, create-<breed>-to, or create-<breed>-from. If you're still getting the error, call clear-all or clear-links to make sure you've removed all unbreeded links.

Related

Error while using "EpiEstim" and "ggplot2" libraries

First of all, I must say I'm completely noob in R. So I apologize in advance for asking for help with such a simple task. My task is to form a graph of COVID-19 cases for a certain period using data from the CSV file. Unfortunately, at the moment I cannot contact the person from the World Health Organization who provided the data and the script for launching. But I was left with an error that I cannot fix either myself, not with the help of Google.
script.R
library(EpiEstim)
library(ggplot2)
COVID<-read.csv("dataset.csv")
res_parametric_si<-estimate_R(COVID$I,method="parametric_si",config=make_config(list(mean_si=4,std_si=3)))
plot(res_parametric_si)
dataset.csv
Date,Suspected per day,Total suspected,Discarded/pending,Confirmed per day,Total confirmed,Deaths per day,Deaths Total,Case fatality rate,Daily confirmed,Recovered per day,Recovered total,Active cases,Tested with PCR,# of PCR tests total,average tests/ 7 days,Inf HCW,Inf HCW/d,Vent HCW,Susp per day
01-Jul-20,1239,91172,45285,889,45887,12,1185,2.58%,889,505,20053,24649,11109,676684,10073,6828,63,,1239
02-Jul-20,1249,92421,45658,876,46763,27,1212,2.59%,876,505,20558,24993,13167,689851,9966,6874,46,,1249
03-Jul-20,1288,93709,46032,914,47677,15,1227,2.57%,914,597,21155,25295,11825,701676,9915.7,6937,63,,1288
04-Jul-20,926,94635,46135,823,48500,22,1249,2.58%,823,221,21376,25875,9934,711610,9957,6990,53,,926
05-Jul-20,680,95315,46272,543,49043,13,1262,2.57%,543,327,21703,26078,6696,718306,9963.7,7030,40,,680
06-Jul-20,871,96186,46579,564,49607,21,1283,2.59%,564,490,22193,26131,9343,727649,10303.9,7046,16,,871
07-Jul-20,1170,97356,46942,807,50414,23,1306,2.59%,807,926,23119,25989,13568,741217,10806,7092,46,,1170
Error
Error in process_I(incid) (script.R#4): incid must be a vector or a dataframe with either i) a column called 'I', or ii) 2 columns called 'local' and 'imported'.
For the example data the issue seems to be that it does only cover 7 data points, and the configurator assumes that there it can window over more than 7 days. What worked for me was the following code (working in the sense that it does not throw an error).
config <- make_config(incid = COVID$Daily.confirmed,
method="parametric_si",
list(mean_si=4,std_si=3, t_start = c(2,3),t_end = c(6,7)))
res_parametric_si<-estimate_R(COVID$Daily.confirmed,method="parametric_si",config=config)
plot(res_parametric_si)

Morning Star Integration

I've been trying to make a comprehensive Google Sheet containing information about different stocks that can have stocks dynamically added and removed for a school project. To that end, I've done some research into loading data from tables with IMPORTHTML, and come up with this:
=IMPORTHTML(CONCAT("http://financials.morningstar.com/ratios/r.html?t=", B3),"table", 1)
Where B3 is NFLX or any other stock ticker that would be added. However, Sheets is returning with `Imported content is empty", and I've got no clue why.
Partial Answer:
yes, after a bit of fiddling I found that the best url to look at for Financial Parts is
http://financials.morningstar.com/finan/financials/getFinancePart.html?t=XNAS:NFLX&region=usa&culture=en-US&ops=clear
You can use this and combine it with
https://github.com/fastfedora/google-docs/blob/master/scripts/ImportJSON/Code.gs
which adds ImportJSON functionality to google sheets.
This should get you started. However the data comes as bunch of divs/tds that you would have to clean it up but it's possible after a bit of fiddling :)
I can't tell you where Ahmed Masud got the link (and I would like to know too). I get a lot
of data from morningstar and they can be strange. However, using his link, you can get the
Key Ratios and clean the resulting data with importhtml and also reference your B3 cell with this:
=arrayformula(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IMPORTHTML("http://financials.morningstar.com/finan/financials/getFinancePart.html?t=XNAS:"& B3 &"&region=usa&culture=en-US&ops=clear","table", 1), "<\/td>" , "" ),"<\/tr>",""),"<\/th>",""),"<\/thead>",""),"<\/span>",""))
Sorry, I put in the wrong formula. This will get the B3 entry.
This will get ownership:
=arrayformula(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IMPORTHTML("http://investors.morningstar.com/ownership/shareholders-overview.html?t=XNAS:"& B3 &"&region=usa&culture=en-US&ops=clear","table", 4), "<\/td>" , "" ),"<\/tr>",""),"<\/th>",""),"<\/thead>",""),"<\/span>",""))
Again the stock symbol should be in B3.

Python %s not working when printing another veriable

Me and my friend are working on a program that keeps track of swimmers times and all the times totaled is there aggregate. We also ask that the swimmers name which is equal to Name.
We are able to print out...
print('Swimmer had a total time of',aggregates[Name])
but the %Name stop the program from running properly, any suggestions to what we could use instead or maybe what we're doing wrong would be very helpful. Thanks!
print('''%s had a total aggregate time of
''',aggregates[Name] %Name)
Formatting print should be done like print("%s had a t..." % Name, aggregates[Name])

phpexcel select cell after freezePane()

A) I would like to have a PHPExcel-generated file to open with cell A1 selected. Not a problem: I can do that.
B) I would like to have a PHPExcel-generated file with frozen panes (at 'E6', but that's not the real issue). Again, not a problem: I can do that.
Now, when trying to do A and B, that's when I hit a real problem: the file always opens with cell E6 selected, no matter what I try...
I've tried using
$objPHPExcel->getActiveSheet()->freezePane('E6');
in different stages of the file construction (right at the beginning, at the end, in the middle), always with
$objPHPExcel->getActiveSheet()->setSelectedCell('A1');
AFTER freezing the panes, but no luck...
I searched and searched and found no solution to this (except a perhaps-related-but-unanswered request here at SO). Either I'm overlooking something obviously simple or I've uncovered a small bug... :-) Can someone help?
Many thanks in anticipation.
Looking at the code, The Excel2007 Writer overrides the selected cell when there's a split pane, changing it to the top-left cell of the split.
Quick and dirty fix in Classes/PHPExcel/Writer/Excel2007/Worksheet.php, change line 262 which should read
$activeCell = $topLeftCell;
to
$activeCell = empty($activeCell) ? $topLeftCell : $activeCell;
I haven't tested it fully, but it should work for now.... I really should be testing to see which "pane" the selected cell falls into, and setting appropriately in that pane

Undefined columns selected error in R

I apologize in advance because I'm extremely new to coding and was thrust into it just a few days ago by my boss for a project.
My data set is called s1. S1 has 123 variables and 4 of them have some form of "QISSUE" in their name. I want to take these four variables and duplicate them all, adding "Rec" to the end of each one (That way I can freely play with the new variables, while still maintaining the actual ones).
Running this line of code keeps giving me an error:
b<- llply(s1[,
str_c(names(s1)
[str_detect(names(s1), fixed("QISSUE"))],
"Rec")],table)
The error is as such:
Error in `[.data.frame`(s1, , str_c(names(s1)[str_detect(names(s1), fixed("QISSUE")) & :
undefined columns selected
Thank you!
Use this to get the subset. Of course there is other ways to do that with simpler code
b<- llply(s1[,
names(s1)[str_detect(names(s1), fixed("QISSUE"))]
],c)
nwnam=str_c(names(s1)[str_detect(names(s1), fixed("QISSUE"))],"Rec")
ndf=data.frame(do.call(cbind,b));colnames(ndf)=nwnam
ndf
# of course you can do
cbind(s1,ndf)

Resources