-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegex.Rmd
More file actions
24 lines (21 loc) · 689 Bytes
/
Regex.Rmd
File metadata and controls
24 lines (21 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
title: "A4_Chen_Edward"
author: "Edward Chen"
date: "`r Sys.Date()`"
output: html_document
---
# BIOL432 Assignment 4
## https://github.com/DwardEE
```{r, warning=FALSE, message=FALSE}
# Importing dplyr library
library("dplyr")
# Read the csv with the measurements
MData <- read.csv("measurements.csv")
# Implementing the Sp column
MData <- MData %>% mutate(Sp = gsub("([A-Z])([a-z]+) ([a-z]+)", "\\1. \\3", species_sample))
# Removing the old species_sample column and moving Sp to the left of the dataframe
MeasShort <- MData %>% select(Sp, everything()) %>% select(-species_sample)
MeasShort
# Exporting the data frame
write.csv(MeasShort, "MeasShort.csv", row.names = FALSE)
```