PhD Dissertation Data Explorer

GitHub Documents

This document is created using R Markdown format publishable in GitHub. This document contains codes that has been used to 1) Import survey data into R in single dataframe from single excel.xlsx file with data scattered in multiple tabs. 2) Explore and process survey data before analyzing it. Please contact Bijesh Mishra, PhD Student, Department of Natural Resource Ecology and Management (NREM) at Oklahma State University (OSU). Contact details is available on https://bijeshmishra.wordpress.com or website of the department of univeristy.

Including Code

You can include R code in the document as follows:

library("readxl")
library("plyr")
library("tibble")
library("tidyverse")
## ── Attaching packages ────────────────────────────── tidyverse 1.3.0 ──

## ✓ ggplot2 3.3.0     ✓ dplyr   0.8.5
## ✓ tidyr   1.0.2     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## ✓ purrr   0.3.3

## ── Conflicts ───────────────────────────────── tidyverse_conflicts() ──
## x dplyr::arrange()   masks plyr::arrange()
## x purrr::compact()   masks plyr::compact()
## x dplyr::count()     masks plyr::count()
## x dplyr::failwith()  masks plyr::failwith()
## x dplyr::filter()    masks stats::filter()
## x dplyr::id()        masks plyr::id()
## x dplyr::lag()       masks stats::lag()
## x dplyr::mutate()    masks plyr::mutate()
## x dplyr::rename()    masks plyr::rename()
## x dplyr::summarise() masks plyr::summarise()
## x dplyr::summarize() masks plyr::summarize()
library("gdata")
## gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.

## 

## gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.

## 
## Attaching package: 'gdata'

## The following objects are masked from 'package:dplyr':
## 
##     combine, first, last

## The following object is masked from 'package:purrr':
## 
##     keep

## The following object is masked from 'package:stats':
## 
##     nobs

## The following object is masked from 'package:utils':
## 
##     object.size

## The following object is masked from 'package:base':
## 
##     startsWith
library("dplyr")
library("ggplot2")
library("knitr") #publish to RPubs using RMarkDown
# library("XLConnect") # Needs Java.
# Write code below this line
excel_sheets(path = survey_data_path) #gives actual names of excel sheets.
## [1] "SecA"    "SecB"    "SecC"    "SecCQC4" "SecD"    "SecE"    "SecF"
survey_data_combo = (lapply(excel_sheets(path = survey_data_path), function(x) read_excel(path = survey_data_path, sheet = x))) #all data combined. rbind.fill(survey_data_combo) gives one data frame.
sec_a = survey_data_combo[[1]] # identical(survey_data_combo[[1]], sec_a)
sec_b = survey_data_combo[[2]] # identical(survey_data_combo[[2]], sec_b)
sec_c = survey_data_combo[[3]] # identical(survey_data_combo[[3]], sec_c)
sec_cqc4 = survey_data_combo[[4]] # identical(survey_data_combo[[4]], sec_cqc4)
sec_d = survey_data_combo[[5]] # identical(survey_data_combo[[5]], sec_d)
sec_e = survey_data_combo[[6]] # identical(survey_data_combo[[6]], sec_e)
sec_f = survey_data_combo[[7]] # identical(survey_data_combo[[7]], sec_f)
#Finish code above this line
# Write code below this line
survey_data_transform = do.call("rbind", survey_data) #change row into column.
# This is of classes "tbl_df" (tibble data frame), "tbl" (tibble) and "data.frame".
#Finish code above this line.

Including Plots

You can also embed plots, for example:

## Warning: Removed 1505 rows containing missing values (position_stack).

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot. This is an R Markdown format used for publishing markdown documents to GitHub. When you click the Knit button all R code chunks are run and a markdown file (.md) suitable for publishing to GitHub is generated.