Coding in R, Part 1

“What Do I Love About R”;
“What Does R Mean to Me”;
“What Do I Want to R When I Grow Up”;
When I started this “Why I Love R” blog post most of my introductory sentences felt very… generic. So instead, I’m decided to write about why I enjoy coding in R more than I enjoy coding in other programming languages that I’m equally proficient in. For this blog post in particular, I will be using Java as my comparison language, given its readability and popularity.
When I program in Java (or any strongly-typed language for that matter), I feel a strong need -no, a compulsion– for structure, order and a designated skeleton.

FOR (INT I = 0; I < MAX; I++).

It’s very repetitive, very tedious and almost Orwellian in a way: if you stray from the structure, the entire program falls apart. There isn’t much room for freedom of expression when it comes to Java, and while that’s very smart in terms of practicality, it doesn’t leave much leeway for creativity in structure.

Strongly Typed vs Weakly Typed:
While there isn’t a definitive consensus within the coding community about the definitions of strongly- and weakly- typed languages, I have found two ways to comfortably differentiate between them:
Does your language:

  • … permit the type of a variable (and, hence, the type of values it references) to change within the lifetime of that variable?
  • … perform checks for type constraint violations before execution rather than during execution?
  • … forbid or require explicit indication for conversions between different types?
  • … prevent disabling or evading the type system on a language-level?
  • … have a complex, fine-grained type system with compound types?
  • … force the type of its data objects to remain the same over the lifetime of the objects?

If the answer is yes to most of these, your language is strongly-typed. Otherwise, weakly-typed it is.
Strongly-Typed code ditty: (Java)
(Although Java is a weakly-typed language, I want to express the form in which Java acknowledges types)

 int x = 5;            // x now holds the number 5.
 System.out.println(x) // Output: 5
 x = "Hello";          // This will throw an error because x has been designated an integer and not a String.
 (String) x = "Hello"; // However, Java has the ability to 'cast' an integer to get around the type system.
 System.out.println(x) // Output: Hello

Weakly-Typed code ditty: (R)

 x <- 5               // x now holds the number 5.
 print(x)             // Output: 5
 x <- "Hello"         // x now holds the string Hello.
 print(x)             // Output: Hello
source 1 | source 2 | source 3

  1. Freedom/Fluidity
  2. Multi-Solutioned / Interactabilitiy
  3. Open Source Libraries
  4. RStudio (IDE)
  5. Plots, Graphs, Charts, oh my!

Freedom / Fluidity

“Writing in Java or C is like being on a no-fat or no-carb diet; you’re restricted by what you eat and that’s that.. But writing in R is like being on a no-fat and no-carb diet at the same time, except you get to choose when either apply; ‘Right now I’m on a no-fat diet, time for carbs! Wait, now I’m on a no-carbs diet, eating ALL the fat!’. It’s so flexible!”
When I write in R, I have the ability to structure my code however I feel is most aesthetically pleasing. The only requirement R has in reference to code structure is that functions must be written before they are called, which isn’t an issue in Java.
Take the following R code samples; this program reverses the letters in a given word:

Example 1a:

reverseText = function (word) {
  newWord <- character()
  for (i in nchar(word):1){
    newWord <- paste0(newWord, substr(word, i, i))
  return (newWord)
output: olleh
Example 1b:

reverseText = function (word) {
  newWord <- character()
  for (i in nchar(word):1){
    newWord <- paste0(newWord, substr(word, i, i))
  return (newWord)
output: Error in eval(expr, envir, enclos) : 
could not find function "reverseText"

When you source an R program, your code will be read from top to bottom and execute in a similar fashion. In Example 1a, the function reverseText() gets read into the system first, so when reverseText(“hello”) gets read in, the program knows what function to execute. The reason Example 1b fails at line 1 is because when the system reads in the line reverseText(“hello”), it is actively searching for the function reverseText(), which does not yet exist in the system: eek!
Take the following Java code samples; this program also reverses the letters in a given word:

Example 2a:

public class sample{
  public static void main(String[] args){
 public static String reverseText(String word){
   int max = word.length() - 1;
   String newWord = "";
   for (int i = 0; i <= max; i++){
     newWord += word.charAt(max - i);
   return newWord;
output: olleh
Example 2b:

public class sample{
 public static String reverseText(String word){
   int max = word.length() - 1;
   String newWord = "";
   for (int i = 0; i <= max; i++){
     newWord += word.charAt(max - i);
   return newWord;
  public static void main(String[] args){
output: olleh

To be short and sweet, we see that nothing different happens between the two variations. This is because Java requires you to run your code through a compiler and R doesn’t. This is where the separation between the two types of languages occurs. Java is a language with which you must complete your code, compile, and then run the whole program (which must be written in a particular structure/outline or everything falls apart), where as R allows you to write your code, basically, however you’d like… as long as you write your information from top to bottom.

Multi-Solutioned / Interactivity

In many languages, we are constrained to one function, one library, one method to solve a particular problem. Sure, we can usually restructure how problems are solved, but we tend to end up limited to one or two particular set of functions. In R, if you want to create a scatterplot, you can write any of the following:

plot(table$x, table$y)
with(table, plot(x, y))
ggplot(table, aes(x, y)) + geom_point()
plot_ly(data = table, x = x, y = y, mode = "markers", filename="r-docs/simple-scatter")

Having leeway to perform single tasks in multiple ways makes R a wonderful language because it embraces creativity and personalization in each programmer’s code.
Also, R allows you to interact not only with R itself, but also with a slew of other programming languages like Java, C, Python, SQL, HTML, CSS, etc. This gives developers the opportunity to interweave the strong points of other languages with the free flow of R. For one, if you have the desire to connect to a SQL database through R, you can import the library RODBC and you can basically write in SQL…. in R. The following is a prime example:

# This sets up the connection to the database (re: imaginary credentials)
driver <- "driver={SQL Server};server=server.website.com,12345;database=db;uid=user;pwd=password"
mainConn <- odbcDriverConnect(driver)
# sqlFetch grabs the table with a particular name from the database you're accessing.
names <- sqlFetch(mainConn, "NameTable")
# sqlQuery does exactly that: it runs a query written in SQL
# this function can insert, alter or retrieve elements from a SQL database!
sqlQuery(mainConn, "INSERT INTO NameTable (FirstName, LastName, FavoriteLanguage) VALUES ("Cassie", "Lebauer", "R"))"
sampleData <- sqlQuery(mainConn, "SELECT * FROM NameTable WHERE FirstName = Cassie ORDER BY LastName")


5 reasons you need a project manager right now.


project manager

Is this you? It doesn’t have to be.

You’ve just had the next greatest idea. You have a great team, but you’re finding it difficult to keep your project on schedule when you have a million other things to do. You think you are on budget, but haven’t had the time to really do the numbers. You’d love to investigate whether or not you’re doing things in the most efficient way, but you have 50 phone calls to return and twice as many emails. Your marketer just spent three quarters of your budget, and now your developer can’t give a proper estimate on when the first deliverable will be ready. And you have a business to run.  Sounds like someone needs a project manager right quick!

Before starting your next project, ask yourself if you are really equipped to do the following:


  1. Schedule creation: You’ve agreed to deliver goods by a certain date. Who will manage how long the steps in between will take?
  1. Risk Assessment: It’s the project manager’s job to avoid unnecessary risk for your business.
  1. Streamlining: Don’t waste time doing unnecessary steps. The project manager will evaluate your process and guide you down the most efficient path.
  1. Cost control: No one wants to overspend. PMs use industry-standard methodologies and procedures to help you stay on budget.
  1. Quality assurance: A good project manager will develop milestones along the duration of your project that will ensure you are providing the highest-quality product, resulting in happy customers and repeat business.


Don’t go it alone. S&A Technologies offers affordable project management services to bring your project to completion on budget and on schedule. You focus on your deliverable. Let S&A Technologies focus on how you get there.  Call or email for a free consultation.

The Google Maps Experience

It’s time for your site to let users see where things are located.

If your online presence needs to invoke geographical locations as part of the consumable information, like business location, serviceable area, branch locations, or even current location ( for moveable objects), you don’t only have to show data about these locations. In many cases an address would satisfy a user’s need just fine, but in other cases, the user would probably want to invoke a map application to get a visual idea of where things are located.

Invoking a map application actually means “to navigate away from your site”, causing the user to lose focus of the things that matter (your site), and probably drift away and get lost in the infinite vastness of the internet. You don’t want that! To prevent Map-drift-awayness and to keep your users attention on the beautiful things that your business has to offer, you can provide a “Map View”.

A Map View is a graphical representation of a geographical location, and only needs a little markup and some JavaScript to get running on your site. If your site has only one piece of information that could use a Map View, no problem! A few lines of markup can render a static map on your page with street information and neighboring landmarks. How about many locations? For a few locations, it’s possible to render many different maps. Feeling fancy? Your site can include a single Map View with many locations marked with pretty icons, and then these icons can also bind to methods that would allow you to modify information on the page. For example: hours of operation, services provided, prices, staff information, or just nice pictures of the place. These are basic ideas that are not hard to implement, but represent a drastic improvement from an unordered list of addresses and hours of operation information. Now, how do we get this working? Enter the Google Maps API.

The Google Maps API, provided by the nice people of Google, is an interface that allows developers access to map methods, map objects, and map-related components. These accessors are the only tools needed to provide a fantastic Map View on your site. If your site only needs a static view of your business location, go to this site to see how easy can it be. Moreover, if your business site is in need of something slightly sophisticated, like multiple marker rendering with event driven behavior, the documentation in this other site would be very helpful. For web applications and sites that depend on only Map Views, the best approach would be to seek a professional service, like S&A Technologies.

The picture here is a snapshot of an application that we have developed at S&A Technologies, and it’s called “Currant_Platform_PowerUser_Screen2CurrantGRID”. This geolocation-based emergency management system takes full advantage of the Google Maps API libraries, and its web and mobile application uses the API’s main components to render a full-view map that can be manipulated by authorized users. The application captures the user’s current location with the help of the Geolocation Maps API, renders a number of markers representing emergency situations in the user’s vicinity, and allows users to report incidents by clicking on a map’s locations. CurrantGRID serves as testimony of the advantages that can be obtained from using the Google Maps API. If your application or site needs some map pimping, give us a call. We will be happy to help you!

Impact of Big Data Analytics in the Healthcare Industry

The healthcare industry is facing unprecedented challenges during the last years: patent expirations, the push for generics, increasing costs, lower margins, tighter Food and Drug Administration (FDA) compliance and lower Research and Development (R&D) productivity. As the R&D productivity has declined during the last years and most of the blockbusters became generic, many pharma companies could become economically unsustainable. However, several opportunities are coming with the digital revolution.

DSC05711-BDuring the last years, pharmaceutical companies have been collecting large amounts of R&D data into medical databases; payers and providers have also digitized their patients’ records. In addition, it has become easier to collect and analyze data gathered across different sources. This can be very important in the healthcare industry, as data about a single patient can be collected from payers, hospitals, clinics, laboratories, pharmacies, and many others. Now, healthcare stakeholders – the pharmaceutical industry, payers, and providers – have access to a really valuable and powerful resource of information.

But what are the benefits of big data analytics for the healthcare industry? The McKinsey Global Institute estimates that applying efficient data strategies could generate about $100 billion annually in the US healthcare system. This could be achieved by optimizing innovation, improving the efficiency of research during clinical trials in the pharma industry, as well as creating new tools for physicians, patients, and payers. Let’s look at the specific example of the pharmaceutical industry. The pharmaceutical industry has been under a lot of pressure recently because of losses related to patent expirations, cost constraints in healthcare systems, and the growing demand in regulatory requirements. During the last few years, the number of new drug approvals has not been directly proportional to the increase in R&D expenditures. Despite the increase in R&D spending, the number of innovative new medicine approvals by the FDA is decreasing.

Utilizing big data analytics well can help pharmaceutical companies to identify potential new drugs and develop them more efficiently. Currently, physicians and pharmaceutical companies still rely mainly on textbooks and on very small clinical trials, usually with healthy patients having just one disease. However, most of the real world patients have more than one health problem. A potential benefit of big data analytics is to find potential patients to enroll in clinical trials based on, for example, social media profiles, genetic information, and information collected in the Electronic Health Records (EHR) and not just on the evaluation of physicians. This could help to adjust to smaller groups, and, therefore, be less expensive.

Another potential benefit could be with the use of data from wearables (See our previous post) . Pharmaceutical companies can use smart devices to gather large quantities of real world data that was not available for R&D teams in the past. This kind of information could be used to analyze drug efficacy on an ongoing and real time basis.


Why Manufacturers Need Custom Applications

Mechatronics is more than just a portmanteau of “mechanics” and “electronics.” Mechatronics, integrating mechanics, electronics, control theory, and computer science, has changed the face of modern manufacturing.

Manufacturing today involves multiple processes and high-tech engineering. Mechatronics has improved and optimized functionality on many levels. It has allowed manufacturers to reduce manpower requirements in favor of technological advances.

What it hasn’t been able to do, however, is answer the “old-fashioned” questions.

Where are things stored? How are we tracking output? How are inefficiencies identified? Is billing done according to actual output and not estimations? Is there waste that can be repurposed? How are estimates done?

Manufacturers today need solutions that they never needed before. Can your company answer these questions easily? S&A Technologies has been answering them for our clients for years, via custom applications such as inventory systems, custom ERP systems, and management decision applications.

Big-data in Manufacturing and Healthcare


No one doubts the advantages of using big-data. According to McKinsey, companies using data and analytics deep into their operations typically see productivity and profit increases that are five to six percent higher than competitors not using data. Big-data analytics are already making impacts in finance, retail and social networks. In order to stay competitive, manufacturing and healthcare/life sciences organizations are now adopting information systems to generate huge volumes of primary and secondary data.

But how can big-data improve manufacturing or healthcare organizations?

In recent years, manufacturers, by implementing programs as Six Sigma were able to improve quality product and reduce dramatically the waste in their production processes. Manufacturing environments in pharmaceuticals, chemicals and life sciences have complex processes that make it difficult to identify where further improvements can be made. The increase in complexity is the main reason manufacturers have a hard time diagnosing and correcting process flows, if they do not use big data as a tool. Analytics can be the answer for those problems. Managers can use advanced analytics to understand the historical process data. Taking this data and applying statistics and other mathematical tools can identify unseen patterns and relationships in the data.

Medical recording and medical devices have enabled the aggregation of R&D data in electronic databases for several years now. This data can hold important R&D information for future developments, if it can be mined properly. Pharmaceutical companies, payers and providers are now beginning to analyze big-data to obtain more insight. For example pharma companies can gather data to understand what treatments are more effective, identify patterns related to the side effects of drugs, hospital re-admissions, or any other information that can help treat patients and reduce costs. See the McKinsey Report Video here.
Many innovative companies in the private sector are creating applications and analytical tools to help patients, physicians and other healthcare stakeholders to identify value and opportunities. The wearables (See Our Blog Post) are out there collecting tons of data that need to be analysed to create insightful information.

The Big Data revolution is still in the early stages and most of its potential for value creation in any organization is still unclaimed. Big-data initiatives have the potential to transform healthcare and manufacturing as they have done already with other industries.

Is your organization prepared to embrace the Big-data era? S&A Technologies can help you. Call us for a quote.

Wearable Technology, The Next Smartphone

Wearable technology has gained traction over the past several years from smart watches to google glass, but very recently this technology has been making headlines with the introduction of Apple’s iWatch. Apple has it right, wearables are the next big thing. Wearables have the ability to collect real-time bio-physical and spatial data and can revolutionizing the way we can stay connected.

The New Normal

Over the years as Schmitt and Associates we have helped you grow your business, and now we have evolved as well.