Rstudio : Practicing linear regression

I am so stuck on this response right now. I’m not sure what I can to change in the script to include all the circumstances, like the weather.

It would help if you post your actual code instead of a picture. Also, can you talk more specifically about how you are stuck? Thanks

1 Like

Okay, I promise I’m not trying to be extra, however, this is exactly what I did:

pacman::p_load(pacman, rio )
data <- import ("C:\Users\kayka\OneDrive\Documents\\forestfires.csv")
head(data)
summary(data)
class(data)
typeof(data)
summary(forestfires)
head(forestfires)
sum(duplicated(forestfires))
my_dup<-forestfires[!duplicated(forestfires),]
month_conversion <- c("jan" = 1, "feb" = 2, "mar" = 3, "apr" = 4, "may" = 5, "jun" = 6, 
                      "jul" = 7, "aug" = 8, "sep" = 9, "oct" = 10, "nov" = 11, "dec" = 12)
day_conversion <- c("mon" = 1, "tue" = 2, "wed" = 3, "thu" = 4, "fri" = 5, "sat" = 6, "sun" = 7)
forestfires$month <- month_conversion[forestfires$month]
forestfires$day <- day_conversion[forestfires$day]
plot(forestfires)
library(ggplot2)
library(dplyr)
fires_by_month <- forestfires %>%
  group_by(month) %>%
  summarize(total_fires = n())
fires_by_month %>% 
  ggplot(aes(x = month, y = total_fires)) +
  geom_col() +
  labs(
    title = "Number of forest fires in data by month",
    y = "Fire count",
    x = "Month"
  )
fires_by_day <- forestfires%>%
  group_by(day)%>%
  summarize(total_fires =n())
fires_by_day%>% 
  ggplot(aes(x=day, y=total_fires))+
  geom_col()

library(tidyr)
forest_fires_long <- data %>% (cols = c("FFMC", "DMC", "DC", 
                                        "ISI", "temp", "RH", 
                                        "wind", "rain"),
                               names_to = "data_col",
                               values_to = "value"
)
library(tidyr)
forest_fires_long <- data %>% 
(
    cols = c("FFMC", "DMC", "DC", 
             "ISI", "temp", "RH", 
             "wind", "rain"),
    names_to = "data_col",
    values_to = "value"
  )
library(tidyr)
forest_fires_long <- forestfires %>%
  (cols = c("FFMC", "DMC", "DC", 
            "ISI", "temp", "RH", 
            "wind", "rain"),
   names_to = "data_col",
   values_to = "value"
  )

The response I was getting "Error : unexpected ‘,’ in: “ISI”, “temp”, “RH”, “wind”, “rain”).

This happens when I’m trying to include the weather circumstances (please forgive me if that is the wrong terminology for my description) Its but the challenge is to find fires that happen the most on Sunday to least on Wednesday.

Nice,
I really appreciate and sincerely thank for your time.

What did I do wrong?

library(tidyr)
forest_fires_long ← data %>% (cols = c(“FFMC”, “DMC”, “DC”,

  •                                     "ISI", "temp", "RH", 
    
  •                                     "wind", "rain"),
    

Error: unexpected ‘,’ in:
" “ISI”, “temp”, “RH”,
“wind”, “rain”),"

forest_fires_long ← data %>%

  • (
  • cols = c("FFMC", "DMC", "DC", 
    
  •          "ISI", "temp", "RH", 
    
  •          "wind", "rain"),
    

Error: unexpected ‘,’ in:
" “ISI”, “temp”, “RH”,
“wind”, “rain”),"

I’m still getting the same response

This Worked!
forest_fires_long ← forestfires %>%
pivot_longer(
cols = c(“FFMC”, “DMC”, “DC”,
“ISI”, “temp”, “RH”,
“wind”, “rain”),
names_to = “variable”,
values_to = “value”
)

and I was wrong about the ‘data’ it is under ‘forestfire’. SMH , Apologies.