#TURIIFKSDKFMCS

#LIBRERIADS

library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.2
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(gt)
## Warning: package 'gt' was built under R version 4.5.2
library(readxl)
library(readr)
library(gt)

setwd("C:/Users/HP/Desktop/new_york_excel")

datos <- read_csv("Oil__Gas____Other_Regulated_Wells__Beginning_1860 (3).csv")
## Rows: 47390 Columns: 52
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (31): Well Name, Company Name, Well Type, Map Symbol, Well Status, Statu...
## dbl (20): API Well Number, County Code, API Hole Number, Sidetrack, Completi...
## lgl  (1): Financial Security
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Condado <- datos$`County Code` 
TDFcondado <- as.data.frame(table(Condado))
colnames(TDFcondado) <- c("Condado","Freq")

#calculos de tabla de frecuencia

TDFcondado$Freq <- as.numeric(TDFcondado$Freq)
TDFcondado <- TDFcondado %>%
  
mutate(
  Condado = Condado,
  ni = Freq,
  hi = round(Freq/sum(Freq)*100, 2)
)

# filas de condados 
TDFcondado <- TDFcondado[, c("Condado", "ni", "hi")]



#agrupaciones
total_ni <- sum(TDFcondado$ni)
total_hi <- 100
TDFCONDADOCOMPLETOOO <- rbind(TDFcondado,
                              data.frame(Condado = "Total",
                                         ni = total_ni,
                                         hi = total_hi))
print(TDFCONDADOCOMPLETOOO)
##    Condado    ni     hi
## 1        1    19   0.04
## 2        3 16663  35.16
## 3        5    20   0.04
## 4        7    70   0.15
## 5        9 12053  25.43
## 6       11   493   1.04
## 7       13  6406  13.52
## 8       15   235   0.50
## 9       17   201   0.42
## 10      19     1   0.00
## 11      23    30   0.06
## 12      25    39   0.08
## 13      27    10   0.02
## 14      29  3585   7.56
## 15      31     3   0.01
## 16      35     5   0.01
## 17      37   893   1.88
## 18      39     3   0.01
## 19      43    14   0.03
## 20      45    15   0.03
## 21      49    11   0.02
## 22      51   458   0.97
## 23      53   144   0.30
## 24      55    33   0.07
## 25      57     9   0.02
## 26      59     4   0.01
## 27      61   213   0.45
## 28      63    16   0.03
## 29      65    73   0.15
## 30      67   295   0.62
## 31      69   365   0.77
## 32      71    21   0.04
## 33      73    30   0.06
## 34      75   215   0.45
## 35      77    20   0.04
## 36      81    12   0.03
## 37      85     2   0.00
## 38      87     7   0.01
## 39      89     1   0.00
## 40      91     5   0.01
## 41      93     2   0.00
## 42      95     4   0.01
## 43      97   448   0.95
## 44      99   457   0.96
## 45     101  2084   4.40
## 46     105     3   0.01
## 47     107   126   0.27
## 48     109   110   0.23
## 49     111    10   0.02
## 50     113     2   0.00
## 51     115     3   0.01
## 52     117    38   0.08
## 53     119    61   0.13
## 54     121  1186   2.50
## 55     123   164   0.35
## 56   Total 47390 100.00
#tabla bonita 
gt(TDFCONDADOCOMPLETOOO) %>%
  tab_header(
    title = md("*Cuadro No.1*"),
    subtitle = "Distribución de pozos petrolíferos por condado en Nueva York") %>%
  cols_align(align = "center", columns = everything()) %>%
  tab_style(
    style = list(cell_fill(color = "#2E4053"), cell_text(color = "white", weight = "bold")),
    locations = cells_title()
  ) %>%
  tab_style(
    style = list(cell_fill(color = "#F2F3F4"), cell_text(weight = "bold", color = "#2E4053")),
    locations = cells_column_labels()
  ) %>%
  tab_options(
    table.border.top.color = "#2E4053",
    table.border.bottom.color = "#2E4053",
    column_labels.border.bottom.color = "#2E4053",
    data_row.padding = px(6)
  )
Cuadro No.1
Distribución de pozos petrolíferos por condado en Nueva York
Condado ni hi
1 19 0.04
3 16663 35.16
5 20 0.04
7 70 0.15
9 12053 25.43
11 493 1.04
13 6406 13.52
15 235 0.50
17 201 0.42
19 1 0.00
23 30 0.06
25 39 0.08
27 10 0.02
29 3585 7.56
31 3 0.01
35 5 0.01
37 893 1.88
39 3 0.01
43 14 0.03
45 15 0.03
49 11 0.02
51 458 0.97
53 144 0.30
55 33 0.07
57 9 0.02
59 4 0.01
61 213 0.45
63 16 0.03
65 73 0.15
67 295 0.62
69 365 0.77
71 21 0.04
73 30 0.06
75 215 0.45
77 20 0.04
81 12 0.03
85 2 0.00
87 7 0.01
89 1 0.00
91 5 0.01
93 2 0.00
95 4 0.01
97 448 0.95
99 457 0.96
101 2084 4.40
105 3 0.01
107 126 0.27
109 110 0.23
111 10 0.02
113 2 0.00
115 3 0.01
117 38 0.08
119 61 0.13
121 1186 2.50
123 164 0.35
Total 47390 100.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.