AmynthasData<-read.table("AmynthasCollectionsDissections2015.csv",header=TRUE,sep=",",stringsAsFactors = F)
head(AmynthasData)
##   Site ID Length Date.Sampled Date.Dissected Life.Stage.of.Host.Earthworm
## 1   CW  1     61       7.9.15        7.14.15                     juvenile
## 2   CW  2     62       7.9.15        7.14.15                     juvenile
## 3   CW  3     90       7.9.15        7.14.15                     juvenile
## 4   CW  4     71       7.9.15        7.14.15                     juvenile
## 5   CW  5     72       7.9.15        7.14.15                     juvenile
## 6   CW  6     71       7.9.15        7.14.15                     juvenile
##   State.of.Seminal.Vesicle  X
## 1                        0 NA
## 2                       NA NA
## 3                       NA NA
## 4                        0 NA
## 5                       NA NA
## 6                        0 NA
tail(AmynthasData)
##     Site  ID Length Date.Sampled Date.Dissected
## 376   HF 106     88      10.5.15        10.7.15
## 377   HF 107     92      10.5.15        10.7.15
## 378   HF 108    104      10.5.15        10.7.15
## 379   HF 109    119      10.5.15        10.7.15
## 380   HF 110    105      10.5.15        10.7.15
## 381   HF 111    105      10.5.15        10.7.15
##     Life.Stage.of.Host.Earthworm State.of.Seminal.Vesicle  X
## 376                        adult                        4 NA
## 377                        adult                        2 NA
## 378                        adult                        3 NA
## 379                        adult                        3 NA
## 380                        adult                        2 NA
## 381                        adult                        2 NA
str(AmynthasData)
## 'data.frame':    381 obs. of  8 variables:
##  $ Site                        : chr  "CW" "CW" "CW" "CW" ...
##  $ ID                          : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Length                      : chr  "61" "62" "90" "71" ...
##  $ Date.Sampled                : chr  "7.9.15" "7.9.15" "7.9.15" "7.9.15" ...
##  $ Date.Dissected              : chr  "7.14.15" "7.14.15" "7.14.15" "7.14.15" ...
##  $ Life.Stage.of.Host.Earthworm: chr  "juvenile" "juvenile" "juvenile" "juvenile" ...
##  $ State.of.Seminal.Vesicle    : int  0 NA NA 0 NA 0 0 1 0 0 ...
##  $ X                           : logi  NA NA NA NA NA NA ...
table(AmynthasData)
## < table of extent 5 x 136 x 92 x 33 x 46 x 2 x 5 x 0 >
summary(AmynthasData)
##      Site                 ID           Length          Date.Sampled      
##  Length:381         Min.   :  1.0   Length:381         Length:381        
##  Class :character   1st Qu.: 32.0   Class :character   Class :character  
##  Mode  :character   Median : 64.0   Mode  :character   Mode  :character  
##                     Mean   : 64.5                                        
##                     3rd Qu.: 96.0                                        
##                     Max.   :136.0                                        
##                                                                          
##  Date.Dissected     Life.Stage.of.Host.Earthworm State.of.Seminal.Vesicle
##  Length:381         Length:381                   Min.   :0.000           
##  Class :character   Class :character             1st Qu.:2.000           
##  Mode  :character   Mode  :character             Median :3.000           
##                                                  Mean   :2.916           
##                                                  3rd Qu.:4.000           
##                                                  Max.   :4.000           
##                                                  NA's   :11              
##     X          
##  Mode:logical  
##  NA's:381      
##                
##                
##                
##                
## 

Regular Expression Problems

Problem 1

Given: First String Second 1.22 3.4 Second More Text 1.555555 2.2220 Third x 3 124

Solution: Find What: \s{2,} Replace with: ,

First String,Second,1.22,3.4
Second,More Text,1.555555,2.2220
Third,x,3,124

Problem 2

Given:
Ballif, Bryan, University of Vermont Ellison, Aaron, Harvard Forest Record, Sydne, Bryn Mawr

Solution: Find What: (\w+), (\w+), (\w+\s.*) Replace with: \2 \1 \(\3\)

Bryan Ballif (University of Vermont)
Aaron Ellison (Harvard Forest)
Sydne Record (Bryn Mawr)

Problem 3

Given:
0001 Georgia Horseshoe.mp3 0002 Billy In The Lowground.mp3 003 Cherokee Shuffle.mp3 0004 Walking Cane.mp3

Solution: Find What: (\S.\w{2}\d\s{1}) Replace with: \1\n

0001 Georgia Horseshoe.mp3
0002 Billy In The Lowground.mp3
0003 Cherokee Shuffle.mp3
0004 Walking Cane.mp3

Problem 4

Given: Camponotus,pennsylvanicus,10.2,44 Camponotus,herculeanus,10.5,3 Myrmica,punctiventris,12.2,4 Lasius,neoniger,3.3,55

Solution a: Find What: (\w)\w+,(\w+),\d+\.\d, Replace with: \1_\2,

C_pennsylvanicus,44
C_herculeanus,3
M_punctiventris,4
L_neoniger,55

Solution b: Find What: (\w)\w+,(\w{4})\w+,\d+\.\d, Replace with: \1_\2,

C_penn,44
C_herc,3
M_punc,4
L_neon,55