LINKGUERRAS = "https://en.wikipedia.org/wiki/List_of_wars_by_death_toll"
library(htmltab)
ancient = htmltab(doc = LINKGUERRAS,
which ='//*[@id="mw-content-text"]/div/table[4]')
medieval = htmltab(doc = LINKGUERRAS,
which ='//*[@id="mw-content-text"]/div/table[6]')
Columns [Notes] seem to have no data and are removed. Use rm_nodata_cols = F to suppress this behavior
modern = htmltab(doc = LINKGUERRAS,
which ='//*[@id="mw-content-text"]/div/table[7]')
Columns [Notes] seem to have no data and are removed. Use rm_nodata_cols = F to suppress this behavior
names(modern)
[1] "War" "Deathrange" "Geometricmean" "Date" "Comabatants" "Location"
names(medieval)
[1] "War" "Deathrange" "Geometricmean" "Date" "Combatants" "Location"
names(modern)
[1] "War" "Deathrange" "Geometricmean" "Date" "Comabatants" "Location"
guerras1=ancient[,c("War","Location")]
guerras2=medieval[,c("War","Location")]
guerras3=modern[,c("War","Location")]
guerras=rbind(guerras1,guerras2,guerras3)
str(guerras)
'data.frame': 162 obs. of 2 variables:
$ War : chr "Conquests of Cyrus the Great" "Greco–Persian Wars" "Samnite Wars" "Wars of Alexander the Great" ...
$ Location: chr "Middle East" "Greece" "Italy" "Middle East / North Africa / Central Asia / India" ...
table(guerras$Location)
Afghanistan Algeria
3 3
Americas Angola
1 2
Balkan Peninsula Bangladesh
1 1
Bosnia British Isles
1 1
Burundi Caucasus region
1 1
Central Africa China
2 9
China / Vietnam Colombia
1 3
Congo Crimean Peninsula
4 1
Cuba East Asia
2 1
Eastern Europe Eastern Europe / Middle East / North Africa
4 1
England England / Wales
2 1
Ethiopia Eurasia
2 2
Europe Europe / Americas
4 2
Europe / Middle East ("Holy Land") Finland
1 1
France Germany
3 1
Greece Haiti
2 1
Iberian Peninsula India
1 4
India-Bangladesh Indonesia
1 1
Iraq Italy
5 1
Korea Laos
3 1
Lebanon Libya
1 1
Madagascar Manchuria
1 1
Mexico Middle East
4 7
Middle East / North Africa Middle East / North Africa / Central Asia / India
1 1
Middle East / North Africa / Southern Europe Middle East/North Africa
1 1
Mozambique Myanmar
1 1
New Guinea Nigeria
1 2
North Africa North America
1 1
North India / Pakistan Northeast India
1 2
Northern China Northern Europe
1 1
Pakistan Patagonia
1 1
Peru Philippines
2 3
Russia Rwanda
2 1
Scotland / England Sierra Leone
1 1
Somalia South Africa
1 1
South America Southeast Asia
1 2
Southeast Europe Southern Africa
1 1
Southern Europe Southern Europe / North Africa
1 2
Spain Sri Lanka
2 1
Sudan Syria
3 1
Tunisia Uganda
1 1
USA Venezuela
1 1
Vietnam Western Europe
1 4
Western Europe / North Africa Worldwide
2 7
Yemen
2
library(knitr)
dataTable=table(guerras$Location)
kable(dataTable)
Registered S3 methods overwritten by 'htmltools':
method from
print.html tools:rstudio
print.shiny.tag tools:rstudio
print.shiny.tag.list tools:rstudio
| Var1 | Freq |
|---|---|
| Afghanistan | 3 |
| Algeria | 3 |
| Americas | 1 |
| Angola | 2 |
| Balkan Peninsula | 1 |
| Bangladesh | 1 |
| Bosnia | 1 |
| British Isles | 1 |
| Burundi | 1 |
| Caucasus region | 1 |
| Central Africa | 2 |
| China | 9 |
| China / Vietnam | 1 |
| Colombia | 3 |
| Congo | 4 |
| Crimean Peninsula | 1 |
| Cuba | 2 |
| East Asia | 1 |
| Eastern Europe | 4 |
| Eastern Europe / Middle East / North Africa | 1 |
| England | 2 |
| England / Wales | 1 |
| Ethiopia | 2 |
| Eurasia | 2 |
| Europe | 4 |
| Europe / Americas | 2 |
| Europe / Middle East (“Holy Land”) | 1 |
| Finland | 1 |
| France | 3 |
| Germany | 1 |
| Greece | 2 |
| Haiti | 1 |
| Iberian Peninsula | 1 |
| India | 4 |
| India-Bangladesh | 1 |
| Indonesia | 1 |
| Iraq | 5 |
| Italy | 1 |
| Korea | 3 |
| Laos | 1 |
| Lebanon | 1 |
| Libya | 1 |
| Madagascar | 1 |
| Manchuria | 1 |
| Mexico | 4 |
| Middle East | 7 |
| Middle East / North Africa | 1 |
| Middle East / North Africa / Central Asia / India | 1 |
| Middle East / North Africa / Southern Europe | 1 |
| Middle East/North Africa | 1 |
| Mozambique | 1 |
| Myanmar | 1 |
| New Guinea | 1 |
| Nigeria | 2 |
| North Africa | 1 |
| North America | 1 |
| North India / Pakistan | 1 |
| Northeast India | 2 |
| Northern China | 1 |
| Northern Europe | 1 |
| Pakistan | 1 |
| Patagonia | 1 |
| Peru | 2 |
| Philippines | 3 |
| Russia | 2 |
| Rwanda | 1 |
| Scotland / England | 1 |
| Sierra Leone | 1 |
| Somalia | 1 |
| South Africa | 1 |
| South America | 1 |
| Southeast Asia | 2 |
| Southeast Europe | 1 |
| Southern Africa | 1 |
| Southern Europe | 1 |
| Southern Europe / North Africa | 2 |
| Spain | 2 |
| Sri Lanka | 1 |
| Sudan | 3 |
| Syria | 1 |
| Tunisia | 1 |
| Uganda | 1 |
| USA | 1 |
| Venezuela | 1 |
| Vietnam | 1 |
| Western Europe | 4 |
| Western Europe / North Africa | 2 |
| Worldwide | 7 |
| Yemen | 2 |
library(ggplot2)
base = ggplot(data=guerras,aes(x=Location))
bar1 = base + geom_bar()
bar1
bar1 = bar1 + labs(x="Pais/zona",
y="Cantidad",
title="Ubicacion de las Guerras en la historia",
subtitle = "Solo con mas 25000 muertos",
caption = "Fuente: Wikipedia")
bar1
bar1 + theme(axis.text.x = element_text(angle = 25,size=7,hjust = 1))
library(DescTools)
Mode(guerras$Location)
[1] "China"
library(DescTools)
Herfindahl(dataTable)
[1] 0.01851852
1/Herfindahl(dataTable)
[1] 54
This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
plot(cars)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.