Leaflet circles do not appear in Rmarkdown output - leaflet
I use the code below in RStudio v0.99.902 to create a map of circles in leaflet:
library(leaflet)
map <- leaflet(data) %>%
addTiles() %>% setView(-77.4,40.1,6) %>%
addCircles(~data$INTPTLON,data$INTPTLAT,radius=(54),runif(90, -2, -1), runif(90, 53, 54), runif(90, 10, 500))
map
And here is my data:
structure(list(zipcode = numeric(0), Group.1 = structure(integer(0), .Label = c("09:52:08AM",
"11222", "15025", "15062", "15101", "15104", "15108", "15132",
"15136", "15143", "15145", "15201", "15203", "15210", "15212",
"15213", "15215", "15216", "15221", "15222", "15228", "15235",
"15423", "15459", "15561", "15642", "15644", "15681", "15697",
"15701", "15717", "15728", "15748", "15920", "15931", "16101",
"16105", "16151", "16201", "16335", "16365", "16412", "16501",
"16503", "16505", "16507", "16509", "16801", "16875", "17025",
"17033", "17042", "17068", "17255", "17315", "17317", "17325",
"17347", "17356", "17403", "17522", "17543", "17601", "17602",
"17603", "17754", "17837", "17951", "18040", "18102", "18109",
"18229", "18232", "18431", "18505", "18512", "18634", "18702",
"18944", "19014", "19020", "19063", "19072", "19086", "19102",
"19103", "19104", "19106", "19107", "19111", "19116", "19118",
"19121", "19124", "19125", "19131", "19132", "19139", "19140",
"19141", "19142", "19143", "19144", "19145", "19146", "19148",
"19151", "19401", "19403", "19438", "19464", "19522", "19533",
"19604"), class = "factor"), jobScr = numeric(0), ProgD1 = numeric(0),
ad51 = numeric(0), ad52 = numeric(0), ad53 = numeric(0),
ad54 = numeric(0), ad55 = numeric(0), ad56 = numeric(0),
ad57 = numeric(0), ProgD5 = numeric(0), ProgD6 = numeric(0),
ProgD7 = numeric(0), ProgD8 = numeric(0), ad9a = numeric(0),
ad9b = numeric(0), ad9c = numeric(0), ad9d = numeric(0),
Q02_Eff1 = numeric(0), Q03_Eff2 = numeric(0), Q04_Eff3 = numeric(0),
Q05_Eff4 = numeric(0), Q06_Eff5 = numeric(0), Q07_Eff6 = numeric(0),
Q08_Eff7 = numeric(0), Q09_Eff8 = numeric(0), Q10_Eff9 = numeric(0),
Q11_Eff10 = numeric(0), Q12_Eff11 = numeric(0), Q13_Eff12 = numeric(0),
ds22 = numeric(0), Academic = numeric(0), STEMfld = numeric(0),
STEMfld2 = numeric(0), sex = numeric(0), occupation = numeric(0),
Other12 = numeric(0), ageRange = numeric(0), STEMfld3 = numeric(0),
Time = numeric(0), Date = numeric(0), Duration = numeric(0),
CLASSFP = structure(integer(0), .Label = "B5", class = "factor"),
MTFCC = structure(integer(0), .Label = "G6350", class = "factor"),
FUNCSTAT = structure(integer(0), .Label = "S", class = "factor"),
ALAND = integer(0), AWATER = integer(0), INTPTLAT = numeric(0),
INTPTLON = numeric(0)), .Names = c("zipcode", "Group.1",
"jobScr", "ProgD1", "ad51", "ad52", "ad53", "ad54", "ad55", "ad56",
"ad57", "ProgD5", "ProgD6", "ProgD7", "ProgD8", "ad9a", "ad9b",
"ad9c", "ad9d", "Q02_Eff1", "Q03_Eff2", "Q04_Eff3", "Q05_Eff4",
"Q06_Eff5", "Q07_Eff6", "Q08_Eff7", "Q09_Eff8", "Q10_Eff9", "Q11_Eff10",
"Q12_Eff11", "Q13_Eff12", "ds22", "Academic", "STEMfld", "STEMfld2",
"sex", "occupation", "Other12", "ageRange", "STEMfld3", "Time",
"Date", "Duration", "CLASSFP", "MTFCC", "FUNCSTAT", "ALAND",
"AWATER", "INTPTLAT", "INTPTLON"), row.names = integer(0), class = "data.frame")
leaflet map of circles in Penna.
The code produces a fine map in the console/viewer, however, when i place the code in Rmarkdown, the background map works but the DOTS DISAPPEAR. There are no errors or warnings. Any ideas how to fix?
Related
OpenXML Excel C# Update Stylesheet and add new Style to existing Stylesheet
I need to add another style to an existing stylesheet. I created this style using the OpenXML Productivity Tools. Unfortunately I can't manage to add this style to the existing stylesheet. The stylesheet is always overwritten. Do I need to adjust the counts (borders, fills, etc)? Or is there a better way? void AppendStylesToStylesheet(WorkbookStylesPart workbookStylesPart) { var styleSheet = workbookStylesPart.Stylesheet; var fonts1 = new Fonts { Count = 1U, KnownFonts = true }; var font1 = new Font(); font1.Append(new FontSize { Val = 11D }); font1.Append(new Color { Theme = 1U }); font1.Append(new FontName { Val = "Calibri" }); font1.Append(new FontFamilyNumbering { Val = 2 }); font1.Append(new FontScheme { Val = FontSchemeValues.Minor }); fonts1.Append(font1); var fills1 = new Fills { Count = 3U }; var fill1 = new Fill(); fill1.Append(new PatternFill { PatternType = PatternValues.None }); var fill2 = new Fill(); fill2.Append(new PatternFill { PatternType = PatternValues.Gray125 }); var fill3 = new Fill(); var patternFill3 = new PatternFill { PatternType = PatternValues.Solid }; patternFill3.Append(new ForegroundColor { Theme = 0U, Tint = -4.9989318521683403E-2D }); patternFill3.Append(new BackgroundColor { Indexed = 64U }); fill3.Append(patternFill3); fills1.Append(fill1); fills1.Append(fill2); fills1.Append(fill3); var borders1 = new Borders { Count = 2U }; var border1 = new Border(); var leftBorder1 = new LeftBorder(); var rightBorder1 = new RightBorder(); var topBorder1 = new TopBorder(); var bottomBorder1 = new BottomBorder(); var diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); var border2 = new Border(); var leftBorder2 = new LeftBorder(); var rightBorder2 = new RightBorder(); var topBorder2 = new TopBorder { Style = BorderStyleValues.Dotted }; topBorder2.Append(new Color { Theme = 0U, Tint = -0.24994659260841701D }); var bottomBorder2 = new BottomBorder { Style = BorderStyleValues.Dotted }; bottomBorder2.Append(new Color { Theme = 0U, Tint = -0.24994659260841701D }); var diagonalBorder2 = new DiagonalBorder(); border2.Append(leftBorder2); border2.Append(rightBorder2); border2.Append(topBorder2); border2.Append(bottomBorder2); border2.Append(diagonalBorder2); borders1.Append(border1); borders1.Append(border2); var cellStyleFormats1 = new CellStyleFormats { Count = 1U }; cellStyleFormats1.Append(new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U }); var cellFormats1 = new CellFormats { Count = 3U }; var cellFormat2 = new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U }; var cellFormat3 = new CellFormat { NumberFormatId = 14U, FontId = 0U, FillId = 2U, BorderId = 1U, FormatId = 0U, ApplyNumberFormat = true, ApplyFill = true, ApplyBorder = true, ApplyAlignment = true }; var alignment1 = new Alignment { Vertical = VerticalAlignmentValues.Center }; cellFormat3.Append(alignment1); var cellFormat4 = new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyAlignment = true }; var alignment2 = new Alignment { Vertical = VerticalAlignmentValues.Center }; cellFormat4.Append(alignment2); cellFormats1.Append(cellFormat2); cellFormats1.Append(cellFormat3); cellFormats1.Append(cellFormat4); var cellStyles1 = new CellStyles { Count = 1U }; var cellStyle1 = new CellStyle { Name = "Standard", FormatId = 0U, BuiltinId = 0U }; cellStyles1.Append(cellStyle1); var differentialFormats1 = new DifferentialFormats { Count = 0U }; var tableStyles1 = new TableStyles { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" }; var colors1 = new Colors(); var mruColors1 = new MruColors(); var color4 = new Color { Rgb = "FFFFFFCC" }; mruColors1.Append(color4); colors1.Append(mruColors1); var stylesheetExtensionList1 = new StylesheetExtensionList(); var stylesheetExtension1 = new StylesheetExtension { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); var slicerStyles1 = new X14.SlicerStyles { DefaultSlicerStyle = "SlicerStyleLight1" }; stylesheetExtension1.Append(slicerStyles1); var stylesheetExtension2 = new StylesheetExtension { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" }; stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); var timelineStyles1 = new X15.TimelineStyles { DefaultTimelineStyle = "TimeSlicerStyleLight1" }; stylesheetExtension2.Append(timelineStyles1); stylesheetExtensionList1.Append(stylesheetExtension1); stylesheetExtensionList1.Append(stylesheetExtension2); styleSheet.Append(fonts1); styleSheet.Append(fills1); styleSheet.Append(borders1); styleSheet.Append(cellStyleFormats1); styleSheet.Append(cellFormats1); styleSheet.Append(cellStyles1); styleSheet.Append(differentialFormats1); styleSheet.Append(tableStyles1); styleSheet.Append(colors1); styleSheet.Append(stylesheetExtensionList1); styleSheet.Save(); }
equation displays "Cannot convert value of type 'String' to expected argument type 'Int'"
I'm trying to display a number on a label that is calculated by values entered in a textfield box. However, I am getting this error where I am trying to do the equation. My code is below. Any idea what I need to change to allow it to display that answer? func calculateRewardPoints() -> Int { if currentLevelStepper.value == 1 { resultHeaderLabel.text = "60 Required Forge Points for Lvl 1" rewardLinkOne.text = "10" rewardLinkTwo.text = "5" rewardLinkThree.text = "0" rewardLinkFour.text = "0" rewardLinkFive.text = "0" var roundone = round(((Double(bonusinput.isTextNumber().1) + Double(100)) / Double(100) ) * Double(10) ) var roundtwo = round(((Double(bonusinput.isTextNumber().1) + Double(100)) / Double(100) ) * Double(5) ) var roundthree = round(((Double(bonusinput.isTextNumber().1) + Double(100)) / Double(100) ) * Double(5) ) var roundfour = round(((Double(bonusinput.isTextNumber().1) + Double(100)) / Double(100) ) * Double(5) ) var roundfive = round(((Double(bonusinput.isTextNumber().1) + Double(100)) / Double(100) ) * Double(5) ) rateRewardLinkOne.text = String(roundone) rateRewardLinkTwo.text = String(roundtwo) rateRewardLinkThree.text = String(roundthree) rateRewardLinkFour.text = String(roundfour) rateRewardLinkFive.text = String(roundfive) //rateRewardLinkFive.text = String( ( (Double(bonusinput.isTextNumber().1) + Double(100)) / Double(100) ) * Double(5) ) fpSecureLinkOne.text = "40" fpSecureLinkTwo.text = "40" fpSecureLinkThree.text = "45" fpSecureLinkFour.text = "45" fpSecureLinkFive.text = "45" /*(A)*/ var totalfp = 60 /*(B)*/ var fpadded = String(Int(fpinput.isTextNumber().1)) /*(C1)*/ var baserewardone = 10 /*(C2)*/ var baserewardtwo = 5 /*(C3)*/ var baserewardthree = 0 /*(C4)*/ var baserewardfour = 0 /*(c5)*/ var baserewardfive = 0 /*(D)*/ var arcbonus = ((bonusinput.isTextNumber().1) + 100) / 100 var squaredone = (baserewardone * arcbonus) * 2 var squaredtwo = (baserewardtwo * arcbonus) * 2 var squaredthree = (baserewardthree * arcbonus) * 2 var squaredfour = (baserewardfour * arcbonus) * 2 var squaredfive = (baserewardfive * arcbonus) * 2 var securefpthree = 45 var securefpfour = 45 var securefpfive = 45 // Where error occurs // I need the fpSecure labels to be ( (A-B) - ((C*D)*2) ) fpSecureLinkOne.text = String((totalfp - fpadded) - squaredone) }
This is called string interpolation "\(your number)"
Union tables with LINQ query for custom Model
I have 3 tables(in origin its 6 but shorter better here) they all have have a key column in common I want to filter and union all these tables using linq Here what I did so far, actually it works but you will understand me why I post this since you saw the code below var query = (from icr in ictetkikRadyoloji where icr.CommanId == userId select new MyCustomModel { ID = icr.ID, IstemTarihi = icr.IstemTarihi, Laboratuvar = icr.Laboratuvar, Sonuc = icr.Sonuc, HastaGuid = "-", Type_ = "1" }).Union(from icb in ictetkikBakteriyoloji where icb.CommanId == userId select new MyCustomModel { ID = icb.ID, IstemTarihi = icb.IstemTarihi, Laboratuvar = icb.Laboratuvar, Sonuc = "-", HastaGuid ="someGuid", Type_ = "2" }).Union(from icbk in ictetkikBiyokimya where icbk.CommanId == userId select new MyCustomModel { ID = icbk.ID, IstemTarihi = DateTime.Now, Laboratuvar = icbk.Laboratuvar, Sonuc = "-", HastaGuid ="SomeGuid", Type_ = "3" }); You see its so ugly and its uglier than this in origin :( how can I make this little bit more beauty, since they all return entities as specific Model(MyCustomModel) I feel like it can be..
You could first perform projection and then union over all cases. The only additional data that projection should have is CommanId. You can use anonymous types, so you don't have to create another class just for intermediate projection. After that you can specify your filter just once and do final projection to MyCustomModel. For example: var unionQuery = (from icr in ictetkikRadyoloji select new { ID = icr.ID, IstemTarihi = icr.IstemTarihi, Laboratuvar = icr.Laboratuvar, Sonuc = icr.Sonuc, HastaGuid = "-", Type_ = "1", CommanId = icr.CommanId }).Union( (from icb in ictetkikBakteriyoloji select new { ID = icb.ID, IstemTarihi = icb.IstemTarihi, Laboratuvar = icb.Laboratuvar, Sonuc = "-", HastaGuid = "someGuid", Type_ = "2", CommanId = icb.CommanId })).Union( (from icbk in ictetkikBiyokimya select new { ID = icbk.ID, IstemTarihi = DateTime.Now, Laboratuvar = icbk.Laboratuvar, Sonuc = "-", HastaGuid = "SomeGuid", Type_ = "3", CommanId = icbk.CommanId })); var query = from i in unionQuery where i.CommanId = userId select new MyCustomModel { ID = i.ID, IstemTarihi = i.IstemTarihi, Laboratuvar = i.Laboratuvar, Sonuc = "-", HastaGuid = "SomeGuid", Type_ = "3", }; Alternatively you could add property CommanId to MyCustomModel and then you don't need final projection and anonymous types.
You have two options: 1. Get List of Lists var query = (from icr in ictetkikRadyoloji where icr.CommanId == userId select new List<MyCustomModel>() { new MyCustomModel() { ID = icr.ID, IstemTarihi = icr.IstemTarihi, Laboratuvar = icr.Laboratuvar, Sonuc = icr.Sonuc, HastaGuid = "-", Type_ = "1" }, new MyCustomModel { ID = icb.ID, IstemTarihi = icb.IstemTarihi, Laboratuvar = icb.Laboratuvar, Sonuc = "-", HastaGuid = "someGuid", Type_ = "2" }, new MyCustomModel { ID = icbk.ID, IstemTarihi = DateTime.Now, Laboratuvar = icbk.Laboratuvar, Sonuc = "-", HastaGuid = "SomeGuid", Type_ = "3" } }); 2. Use loop through Objects Load objects to memory and make 3 different copies of each object. var result = new List<MyCustomModel>(); var query = (from icr in ictetkikRadyoloji where icr.CommanId == userId select icr) .ToList() .ForEach(x => { result.Add(new MyCustomModel() { ID = icr.ID, IstemTarihi = icr.IstemTarihi, Laboratuvar = icr.Laboratuvar, Sonuc = icr.Sonuc, HastaGuid = "-", Type_ = "1" }); result.Add(new MyCustomModel() { ID = icr.ID, IstemTarihi = icr.IstemTarihi, Laboratuvar = icr.Laboratuvar, Sonuc = "-", HastaGuid = "someGuid", Type_ = "2" }); result.Add(new MyCustomModel() { ID = icr.ID, IstemTarihi = DateTime.Now, Laboratuvar = icr.Laboratuvar, Sonuc = "-", HastaGuid = "SomeGuid", Type_ = "3" }); });
Swift accessing key from dictionary returning null
I have a dictionary. When I try to access that dictionary, it is returning a null value when it should definately be returning an actual value. I'm stumped. Any help is always appreciated. if let d = response.result.value { print(d) //prints correct data let prices = d["prices"] as? [[String:AnyObject?]] print(prices) //prints nil let best_price = prices?[0] let price = best_price?["price"] as? String print(price) //prints nil } Console: { item = { "item_number" = 57; image = "http://example.com/tent.jpg"; name = "Small Red Tent"; }; prices = ( { link = "http://example.com/id=19"; price = "58.15"; rating = "3.64"; "vendor_id" = 50; }, { link = "http://example.com/id=50"; price = "58.14"; rating = "5.00"; "vendor_id" = 110; }, { link = "http://example.com/id=26"; price = "50.40"; rating = "4.71"; "vendor_id" = 73; }, { link = "http://example.com/id=12"; price = "47.16"; rating = "4.00"; "vendor_id" = 1; }, { link = "http://example.com/id=13"; price = "45.75"; rating = "3.90"; "vendor_id" = 25; }, { link = "http://example.com/id=16"; price = "41.32"; rating = "3.02"; "vendor_id" = 16; }, { link = "http://example.com/id=1"; price = "36.59"; rating = "4.84"; "vendor_id" = 51; }, { link = "http://example.com/id=2"; price = "36.29"; rating = "3.26"; "vendor_id" = 43; }, { link = "http://example.com/id=13"; price = "34.59"; rating = "4.14"; "vendor_id" = 48; }, { link = "http://example.com/id=3"; price = "32.00"; rating = "4.29"; "vendor_id" = 53; }, { link = "http://example.com/id=4"; price = "24.50"; rating = "4.16"; "vendor_id" = 8; }, { link = "http://example.com/id=5"; price = "15.00"; rating = "4.87"; "vendor_id" = 39; }, { link = "http://example.com/id=6"; price = "0.00"; rating = "3.00"; "vendor_id" = 65; } ); } nil nil
So the solution was proposed by Larme solved the problem. let prices = d["prices"] as? [AnyObject] Although I never figured out why casting d["prices"] as? [[String:AnyObject?]] wouldn't also work.
how to parse this in iphone
{ education = ( { school = { id = 108102169223234; name = psss; }; type = College; year = { id = 142833822398097; name = 2010; }; } ); email = "amvijaycse#gmail.com"; "first_name" = Vijay; gender = male; id = 100000782204693; "last_name" = Kumar; link = "http://www.facebook.com/profile.php?id=100000782204693"; locale = "en_US"; location = { id = 106377336067638; name = "Bangalore, India"; }; name = "Vijay Kumar"; timezone = "5.5"; "updated_time" = "2010-11-21T07:45:11+0000"; } i needed email,firstname,lastname.
[EDIT: Removed because it was inaccurate]