Combine Plots into a Single Grid

Communicating results in graphical format is a very common task in research. During my career, I can’t tell you how many times I’d have several Excel graphs that I rearranged in PowerPoint, to create a single grid layout to save as a png file for presentation in a manuscript. Every time you wanted to change a small feature in the figure, it resulted in extra work. That all changed when I started to use R for all of my research needs.
Read More…

R Tools for Research Publication

Reproducibe Research When writing a manuscript or developing a data story, I use RMarkdown. RMarkdown enables authors to prepare reproducible research documents, which ties specific instructions to data analysis and experimental data so that scholarship can be recreated, better understood and verified. Packages in R for this purpose can be split into groups for: literate programming, package reproducibility, code/data formatting tools, format convertors, and object caching. The primary way that R facilitates reproducible research is using a document that is a combination of content and data analysis code.
Read More…

dplyr Compared to data.table

A few of my recent posts included manipulation of data inside the data.table by using special characters in the j and by positions. Another very popular approach is to use the dplyr package, rather than data.table. dplyr is a grammar of data manipulation, which includes arrange, filter, mutate, select, and summarise, all of which can be used with other functions, such as the group_by function or even logical operators. For comparison, I provide the similar action with data.
Read More…

DailyR ggplot2 Theme Assistant

Dear Friends, I’ve decided to show you ggplot2 Theme Assistant. I’m using a recent blog that can be found here about the scatter plot. The purpose of the Theme Assitant is to provide a RStudio Addin to enable users to make easy adjustments to your gg plot theme. I’m sure you will see the power of the tool in the demo. If you enjoy these type of videos, please like, share, and subscribe!
Read More…

Indexing Rows in Data.Table

During the day (and night), I’m a military scientist at Ft. Detrick. I have to tell you…I use R to do everything on a daily basis. Whether it’s a hard core research project, administrative tasks, such as a manpower analysis, financial modeling, or communicating my work to senior leaders with reproducible research documents in RMarkdown, I use R. R adds efficiency, effectiveness and innovation to the way I manage and perform daily tasks.
Read More…

Assigning Columns as Factors in Data.Table

I love working with data.table, but there are a few options that always trip me up. Well, I guess there are a lot of things that do. The best way to avoid these pitfalls are to write functions that handle the tasks for you. You can setup a R script that loads when you need the functions. Selecting specific columns in data.table, and converting them to factors or numerical is a good example.
Read More…

DailyR bare_combine() RStudio Addins

Ever have a string of values and you need to turn it into R code? Use the bare_combine() function! For example, let’s say I have the following list of values in some text, excel sheet or pdf. And, you copy into your editor: Paris, New York, Los Angeles, London, Liverpool, Brussels However, you want the list of values above in R code format, such as this: c("Paris", "New York", "Los Angeles", "London", "Liverpool", "Brussels") But, you’re exhausted about the thought of placing all of those quotes.
Read More…

DailyR rvest web scraping

Dear Friends, extracting data from the web is an important skill to have in data science. R provides many packages to ‘scrape’ data. In this post, I use the rvest package to scrape data from the top premier league scorers from a BBC site. I’m a huge Liverpool fan and want to check out how teams and players are doing. First, browse the BBC website and inspected the url. Use the inspect feature from your browser to inspect the data and appropriate xpath.
Read More…

DailyR ggplot2 scatterplot

Dear Friends, I’ve decided to start up a series of posts called ‘#DailyR.’ My goal is to provide some example code to perform common tasks using R. I also want to spend a few days a week on slightly more complicated tasks, and perhaps throw in a little python every once in a while. If you like the content, please like and share! Until next time! Major Steps Use theme_set to try various pre-set themes Use options to turn off scientific notation Use geom_point for a simple scatter plot Create a Scatter Plot library(ggplot2) # load package library(cowplot) theme_set(theme_cowplot()) # pre-set theme data("iris") # load data set options(scipen=999) # turns off scientific notation gg <- ggplot(iris, aes(x = Sepal.
Read More…

Likert Scale Analysis

Recently, I worked with researchers at Deaconess Hospital and the University of Southern Indiana. I consulted on a project to analyze Likert data and discovered the long standing controversy on the topic, which was intriguing. Here, I share a little background on Likert data, considerations about the analysis, and basic R code to perform an analysis. In the future, I’ll make available a workflow for to analyze Likert data, and develop a RShiny app to analyze and visualize the results for a standard survey.
Read More…