Import your data
read_csv("myData2.csv")
## Rows: 83 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): DAMAGE_COSTS, Damage_Cost_Per_Acre, Rate
## dbl (4): YEAR, NUMBER_FIRES, ACRES_BURNED, Average_Acres_Burned_Per_Fire
##
## ℹ 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.
## # A tibble: 83 × 7
## YEAR NUMBER_FIRES ACRES_BURNED DAMAGE_COSTS Damage_Cost_Per_Acre
## <dbl> <dbl> <dbl> <chr> <chr>
## 1 1933 1994 129210 $318,636 $2.47
## 2 1934 2338 363052 $563,710 $1.55
## 3 1935 1447 127262 $165,543 $1.30
## 4 1936 3805 756696 $1,877,147 $2.48
## 5 1937 2907 71312 $151,584 $2.13
## 6 1938 4150 221061 $404,225 $1.83
## 7 1939 2491 513620 $847,579 $1.65
## 8 1940 4497 156015 $272,178 $1.74
## 9 1941 5460 278599 $515,737 $1.85
## 10 1942 5236 573597 $1,484,864 $2.59
## # ℹ 73 more rows
## # ℹ 2 more variables: Average_Acres_Burned_Per_Fire <dbl>, Rate <chr>
read_csv("myData2.csv", skip = 1)
## Rows: 82 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): $318,636, $2.47, 318636/129210
## dbl (4): 1933, 1994, 129210, 64.8
##
## ℹ 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.
## # A tibble: 82 × 7
## `1933` `1994` `129210` `$318,636` `$2.47` `64.8` `318636/129210`
## <dbl> <dbl> <dbl> <chr> <chr> <dbl> <chr>
## 1 1934 2338 363052 $563,710 $1.55 155. 563710/363052
## 2 1935 1447 127262 $165,543 $1.30 88.0 165543/127262
## 3 1936 3805 756696 $1,877,147 $2.48 199. 1877147/756696
## 4 1937 2907 71312 $151,584 $2.13 24.5 151584/71312
## 5 1938 4150 221061 $404,225 $1.83 53.3 404225/221061
## 6 1939 2491 513620 $847,579 $1.65 206. 847579/513620
## 7 1940 4497 156015 $272,178 $1.74 34.7 272178/156015
## 8 1941 5460 278599 $515,737 $1.85 51.0 515737/278599
## 9 1942 5236 573597 $1,484,864 $2.59 110. 1484864/573597
## 10 1943 2163 553328 $1,502,027 $2.71 256. 1502027/553328
## # ℹ 72 more rows
read_csv("myData2.csv", skip = 1, col_names = FALSE)
## Rows: 83 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): X4, X5, X7
## dbl (4): X1, X2, X3, X6
##
## ℹ 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.
## # A tibble: 83 × 7
## X1 X2 X3 X4 X5 X6 X7
## <dbl> <dbl> <dbl> <chr> <chr> <dbl> <chr>
## 1 1933 1994 129210 $318,636 $2.47 64.8 318636/129210
## 2 1934 2338 363052 $563,710 $1.55 155. 563710/363052
## 3 1935 1447 127262 $165,543 $1.30 88.0 165543/127262
## 4 1936 3805 756696 $1,877,147 $2.48 199. 1877147/756696
## 5 1937 2907 71312 $151,584 $2.13 24.5 151584/71312
## 6 1938 4150 221061 $404,225 $1.83 53.3 404225/221061
## 7 1939 2491 513620 $847,579 $1.65 206. 847579/513620
## 8 1940 4497 156015 $272,178 $1.74 34.7 272178/156015
## 9 1941 5460 278599 $515,737 $1.85 51.0 515737/278599
## 10 1942 5236 573597 $1,484,864 $2.59 110. 1484864/573597
## # ℹ 73 more rows
fires <- read_csv("myData2.csv")
## Rows: 83 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): DAMAGE_COSTS, Damage_Cost_Per_Acre, Rate
## dbl (4): YEAR, NUMBER_FIRES, ACRES_BURNED, Average_Acres_Burned_Per_Fire
##
## ℹ 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.
Separating and Uniting
fires %>%
separate(Rate, into = c("Damage","Acres"), sep = "/")
## # A tibble: 83 × 8
## YEAR NUMBER_FIRES ACRES_BURNED DAMAGE_COSTS Damage_Cost_Per_Acre
## <dbl> <dbl> <dbl> <chr> <chr>
## 1 1933 1994 129210 $318,636 $2.47
## 2 1934 2338 363052 $563,710 $1.55
## 3 1935 1447 127262 $165,543 $1.30
## 4 1936 3805 756696 $1,877,147 $2.48
## 5 1937 2907 71312 $151,584 $2.13
## 6 1938 4150 221061 $404,225 $1.83
## 7 1939 2491 513620 $847,579 $1.65
## 8 1940 4497 156015 $272,178 $1.74
## 9 1941 5460 278599 $515,737 $1.85
## 10 1942 5236 573597 $1,484,864 $2.59
## # ℹ 73 more rows
## # ℹ 3 more variables: Average_Acres_Burned_Per_Fire <dbl>, Damage <chr>,
## # Acres <chr>
fires %>%
unite(rate2, ACRES_BURNED, NUMBER_FIRES, sep = "/")
## # A tibble: 83 × 6
## YEAR rate2 DAMAGE_COSTS Damage_Cost_Per_Acre Average_Acres_Burned…¹ Rate
## <dbl> <chr> <chr> <chr> <dbl> <chr>
## 1 1933 129210/… $318,636 $2.47 64.8 3186…
## 2 1934 363052/… $563,710 $1.55 155. 5637…
## 3 1935 127262/… $165,543 $1.30 88.0 1655…
## 4 1936 756696/… $1,877,147 $2.48 199. 1877…
## 5 1937 71312/2… $151,584 $2.13 24.5 1515…
## 6 1938 221061/… $404,225 $1.83 53.3 4042…
## 7 1939 513620/… $847,579 $1.65 206. 8475…
## 8 1940 156015/… $272,178 $1.74 34.7 2721…
## 9 1941 278599/… $515,737 $1.85 51.0 5157…
## 10 1942 573597/… $1,484,864 $2.59 110. 1484…
## # ℹ 73 more rows
## # ℹ abbreviated name: ¹Average_Acres_Burned_Per_Fire