 Let me know if you see my screen. Yes. Okay. Good. Hello, everyone. Today I'm going to talk about using special health data as their representation with R Shiny and wrapping up all of this stuff into a custom report template. My talk will contain just 20 percent of Siri and other 80 will be about practice and the real world possible cases. But before we start, let me introduce myself. My name is Anastasia Kostya. I'm a data management specialist at DataBrew. I have a background in web development. A few years ago, I found R for myself, and again, my genre is a data analyst. Why R? Because it allows me to take part and contribute to healthcare projects. Projects are focused on enhancing life quality or oriented on reducing mortality referring to technology. But it is not about me. It is about special data analysis at least. So let's get started. The first point is what makes data special? We know that analyzing this data provides a better understanding of how each variable impacts individuals, communities, population, et cetera. Also, we know this data can be in two forms, Geometric and Geographic. Geometric data can be mapped on a two-dimensional flat surface where the Google Maps is a good example of Geometric data in action. Or Geographic data is information that can be mapped around the sphere. Also, there are vectors and Truster classification where vectors about polygons, lines, points, and Truster represents information presented in a pixel grid. But in fact, what makes data special? Geometric, Geographic, vectors, Trusters, lines, points, or maybe polygons. It is quite simple. Whenever our data is associated with locations, we think about it especially. When those locations are on the earth, we will often be a little more specific and call the data geospatial. A location is the most unambiguously described by a set of coordinates and a description of what coordinate system is being used. All right. The next term I would like to highlight during this session is Geoclustering. Geospatial clustering is a matter of grouping a set of special objects into groups called clusters. Usually, we create clusters by grouping items that share a high degree of similarity and separate clusters as dissimilar as possible. The goal of clustering is to make generalization and to reveal a relation between special and non-special attribute. At this point, that's it with the theory, and let's jump into real-world example to help us better understand clustering. Suppose you are the head of humanitarian mission in a city. You have set up defined number of coordinate centers or hubs in the city, and you want to assign each individual roads of household to a central hub taking into account commuting time, distance, costs, availability of roads, transportation, and so on. Since it is not feasible to examine the details of each household, you can group them into clusters based on the information and data you already know in a place. About neighborhoods, the household belong to. Referring to the map, you are some data in NGO and of course, Tideiverse packages and Leaflet, you can build interactive map with clusters split it in automated based on a static data you had. Here is a map built with the tools just mentioned. A cluster refers to a collection of data points aggregated together because of set and similarity. You will define target number K. In my case, it is five. You can have any number which refers to the number of centroids you need for the data set you are working with. A centroid is the imaginary or real location representing the cluster of the center of the cluster. In ideal world, all households will be added to a cluster at the beginning of the study. But in reality, however, it is very common for several households to be unintentionally omitted from gaining included in a cluster in initial creation of the groups. In order to add the omitted households to a cluster in the midst of the study or fieldwork, the researchers might have to have sent a fieldworker to manually gather information about the households to determine which cluster they should be assigned to. And then regenerate maps of the updated cluster based on the new data points added. This can be at least time consuming. Creating clusters in real world studies and clinical trials requires a lot of manual labor. It can consist of having sent fieldworkers to manually geolocate and map out each household, for instance. If a study is working with a third party data manager, it can also require intervention any time a new household needs to be added to a cluster. And usually it turns into a real problem for our search. But fortunately, with shiny and tidy geocoder, you can easily turn this issue into a good opportunity and build an excellent tool for this purpose. Why shiny? Because it is user-friendly, understandable and fast. Why tidy geocoder? Because it makes getting data from geocoding service easy. Tidy geocoder has fantastic geocode function which is super useful in the current case. There is no guarantees that fieldworker will have longitude, latitude, coordinates in a point format. He or she can just know address or street name or zip code and map additional households. How? Take a look, short demo. Here is the clustering demo dashboard. On the right side, you can see the initial map created before the trip with the cluster groups and the center of each group. And on the left side, you can see input fields. In this small demo, a fieldworker can indicate that he or she knows street name or zip code, enters information and click show the cluster. As soon as the show cluster button is pressed, you will see a purple point as a new lawyer on the map with the household assignment recommendation. Recommendation based on the shortest distance to the center and available routes. For example, fieldworker just knows street name. He or she enters this information into the text field. Press the button show cluster and see the result on the map without any third party assistance or complex calculation. Everything is straightforward and understandable. For quick sum up, I can tell that this approach and tool help to focus on research without wasting time on map editing as the end user can do it in a three clicks by his sub. Well, the second part of my talk is the custom report template. What does it mean? On the slide, you can see typical our markdown report generation flow. There are dozens of libraries that can assist you in generating PDF, wall document, HTML PowerPoint slides and so on. And I'm sure that 90% of you are familiar with markdown and use it at least once to create report. If not, you can scan your code and learn more about the stuff for yourself. But what if you need to report in a PDF format with the custom design specification like specific fields, fonts, colors or other particular aspects that cannot be done with traditional library. I was personally faced with such requests from client and based on my experience, you might get frustrated at first with the thought of whether or not it's possible to do a R and automatically populate it with your data. But no worries at all. The answer is yes, it is possible. How? The basic knowledge of HTML and CSS is really important ingredient here. Of course, knowledge of our string R package or any another package you prefer that provides functions that can glue expressions. HTML tools and page down packages and a little bit of creativity. You need to create our file with the custom R functions that returns valid HTML fragments as a starting point. Here is a precise example of what I mean exactly. For example, on line set you see the header box function as it takes two arguments, glues them with a string that consists of HTML text and returns fulfilled HTML fragment. Also pay attention that some texts have defined class names. It is about the second step. All right, according to the second step, it is required to create a CSS file with your style definition like font family, image, position, widths, heist, whatever. And here is a sample of CSS file with defined body style. After that, you need to connect the R file, a style CSS file and folder with images in a case you have them to the R markdown file. And here is a screenshot of the R markdown template where you can notice in the YAML output section connected style CSS and source to the HTML fragments wrapped into R function on line 16. The next step is obvious. It is rendering of the template created previously. I prefer to do it via external R file. You can do it via console just based on your preference and important node. It is not just simple template rendering, in my case. It also includes parameters with the custom data. After the rendering of R markdown file, you will receive HTML file with the custom design. To finish your report, you can use Chrome print function from page down package to convert HTML file into PDF file. And yeah, here we go. Report with custom design is created. And here's a short video as it proves my words and demonstrates this report in action. So it is absolutely doable without any abstract terms. You can add a download report feature with the custom design to shiny up in a general way. There is nothing complicated. Just follow described steps about invest some time and you will achieve desirable results, I promise you. So that's all for me. Thank you so much for your time. I hope it was useful for you. If you have any question, you can send me email or direct message in Twitter. And I will be happy to help you and thank you again and have a great day. Thank you so much Anastasia. This is really, really cool. And I had no idea about the Chrome print function, which I'm probably going to be using a lot in the future. So we do actually have a lot of, we have about, let's see. We have seven minutes for questions. No, nine minutes for questions. So please, so I don't see anything in the Q and A right now. Please type your questions either in the Q and A or the chat in the next minute or so. And if we don't have any questions, we'll just take a quick break.