I have a row of strings like this :
[1] X Royal.Perth.Hospital
[3] X.1 X.2
[5] X.3 X.4
[7] X.5 X.6
[9] Fremantle.Hospital X.7
[11] X.8 X.9
[13] X.10 X.11
[15] X.12
Princess.Margaret.Hospital.For.Children
[17] X.13 X.14
[19] X.15 X.16
[21] X.17 X.18
[23] King.Edward.Memorial.Hospital.For.Women X.19
[25] X.20 X.21
[27] X.22 X.23
[29] X.24 Sir.Charles.Gairdner.Hospital
[31] X.25 X.26
[33] X.27 X.28
[35] X.29 X.30
[37] Armadale.Kelmscott.District.Memorial.Hospital X.31
[39] X.32 X.33
[41] X.34 X.35
[43] X.36 Swan.District.Hospital
[45] X.37 X.38
[47] X.39 X.40
[49] X.41 X.42
[51] Rockingham.General.Hospital X.43
[53] X.44 X.45
[55] X.46 X.47
[57] X.48 Joondalup.Health.Campus
[59] X.49 X.50
[61] X.51 X.52
[63] X.53 X.54
I want to count the number of times the word Hospital occured in the row. Note: the last hospital does not have the word "hospital" in it's name instead it has a 'health campus' in it's name.
I tried using the function
occurences<-table(unlist(myrow))
occurences["Hospitals"]
but couldn't count the number of hospitals in the row.
The output should look like :
Hospitals : 8
Health campus: 1
Total Hospitals = 9