I advise against using row position as what determines which numbers are associated with each other. If the pairs of rows are explicitly labeled as belonging together, the processing is much easier. I invented the fact that each host/parasite pair belong to a Site. I also broke out each intermediate step as its own data frame so you can more easily inspect the logic of the processing.
library(tidyr)
library(dplyr)
HostPara <- data.frame(Site = c("A", "A", "B", "B", "C", "C", "D", "D", "E", "E" ),
Type = rep(c("parasite", "host"), 5),
Ca = c(12889, 8825, 14776, 9087, 13951, 7336, 17962, 7798, 15268, 7513),
K = c(21919, 18178, 32136, 24764, 31275, 23079, 35683, 26001, 35946, 29635),
Mg = c(3512, 2640, 3535, 1812, 4256, 1834, 4261, 2573, 4676, 2711))
HostPara
Site Type Ca K Mg
1 A parasite 12889 21919 3512
2 A host 8825 18178 2640
3 B parasite 14776 32136 3535
4 B host 9087 24764 1812
5 C parasite 13951 31275 4256
6 C host 7336 23079 1834
7 D parasite 17962 35683 4261
8 D host 7798 26001 2573
9 E parasite 15268 35946 4676
10 E host 7513 29635 2711
GathHostPara <- HostPara %>% gather(key = Metal, value = Value, Ca, K, Mg)
SummHostPara <- GathHostPara %>% group_by(Site, Type) %>%
summarize(Sum = sum(Value))
SpreadSummary <- SummHostPara %>% spread(key = Type, value = Sum)
SpreadSummary
# A tibble: 5 x 3
# Groups: Site [5]
Site host parasite
<fct> <dbl> <dbl>
1 A 29643 38320
2 B 35663 50447
3 C 32249 49482
4 D 36372 57906
5 E 39859 55890
Ratio <- SpreadSummary %>% mutate(Ratio = parasite/host)
Ratio
# A tibble: 5 x 4
# Groups: Site [5]
Site host parasite Ratio
<fct> <dbl> <dbl> <dbl>
1 A 29643 38320 1.29
2 B 35663 50447 1.41
3 C 32249 49482 1.53
4 D 36372 57906 1.59
5 E 39859 55890 1.40