RData2019$`Game Hour` <- as.character(RData2019$`Game Hour`)
RData2019$Date <- as.character(RData2019$Date)
RData2019$COMP <- as.integer(RData2019$COMP)
RData2019$DOLLAR <- as.integer(RData2019$DOLLAR)
RData2019$GROUP <- as.integer(RData2019$GROUP)
RData2019$NGHTLY <- as.integer(RData2019$NGHTLY)
RData2019$SEASON <- as.integer(RData2019$SEASON)
RData2019$SINGLE <- as.integer(RData2019$SINGLE)
RData2019$Day <- as.factor(RData2019$Day)
RData2019$OpeningDay <- as.factor(RData2019$OpeningDay)
RData2019$OpeningWeekend <- as.factor(RData2019$OpeningWeekend)
RData2019$PreASB <- as.factor(RData2019$PreASB)
RData2019$BOSNYY <- as.factor(RData2019$BOSNYY)
RData2019$Holiday <- as.factor(RData2019$Holiday)
RData2019$DayGame <- as.factor(RData2019$DayGame)
RData2019$WeekdayDayGame <- as.factor(RData2019$WeekdayDayGame)
RData2019$Bobblehead <- as.factor(RData2019$Bobblehead)
RData2019$Wearable <- as.factor(RData2019$Wearable)
RData2019$OtherGiveaway <- as.factor(RData2019$OtherGiveaway)
RData2019$Kids <- as.factor(RData2019$Kids)
RData2019$Concert <- as.factor(RData2019$Concert)
RData2019$SpecEvent <- as.factor(RData2019$SpecEvent)
RData2019$Friday <- as.factor(RData2019$Friday)
Model1 <- lm(SINGLE ~ OpeningDay + OpeningWeekend + PreASB + BOSNYY + Holiday +
DayGame + WeekdayDayGame + Bobblehead + Wearable + OtherGiveaway +
+ Kids + Concert + SpecEvent, data = RData2019)
ERROR
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘Summary’ for signature ‘"lm"’
>
I have the Model placed in my environment I can not get the summary of the model
You might either post a Reprex or at least show us the command that gave the error and perhaps
str(Model1)
.
coefficients : Named num [1:14] 6931.8 -3796.5 9028.3 85.6 -1556.9 ...
..- attr(*, "names")= chr [1:14] "(Intercept)" "OpeningDay" "OpeningWeekend" "PreASB" ...
residuals : Named num [1:81] 1.04e-12 6.92e+02 -6.92e+02 -4.12e+03 -4.52e+03 ...
..- attr(, "names")= chr [1:81] "1" "2" "3" "4" ...
effects : Named num [1:81] -75542 1745.3 -10727.6 -1000.7 -22.3 ...
..- attr(*, "names")= chr [1:81] "(Intercept)" "OpeningDay" "OpeningWeekend" "PreASB" ...
rank : int 14
fitted.values: Named num [1:81] 10128 16046 15678 7017 7017 ...
..- attr(*, "names")= chr [1:81] "1" "2" "3" "4" ...
assign : int [1:14] 0 1 2 3 4 5 6 7 8 9 ...
qr :List of 5
.. qr : num [1:81, 1:14] -9 0.111 0.111 0.111 0.111 ...
.. ..- attr(, "dimnames")=List of 2
.. .. .. : chr [1:81] "1" "2" "3" "4" ...
.. .. .. : chr [1:14] "(Intercept)" "OpeningDay" "OpeningWeekend" "PreASB" ...
.. ..- attr(, "assign")= int [1:14] 0 1 2 3 4 5 6 7 8 9 ...
.. qraux: num [1:14] 1.11 1.11 1.63 1.1 1 ...
.. pivot: int [1:14] 1 2 3 4 5 6 7 8 9 10 ...
.. tol : num 1e-07
.. rank : int 14
..- attr(, "class")= chr "qr"
df.residual : int 67
xlevels : Named list()
call : language lm(formula = SINGLE ~ OpeningDay + OpeningWeekend + PreASB + BOSNYY + Holiday + DayGame + WeekdayDayGame + ...
terms :Classes 'terms', 'formula' language SINGLE ~ OpeningDay + OpeningWeekend + PreASB + BOSNYY + Holiday + DayGame + WeekdayDayGame + Bobblehead + ...
.. ..- attr(, "variables")= language list(SINGLE, OpeningDay, OpeningWeekend, PreASB, BOSNYY, Holiday, DayGame, WeekdayDayGame, Bobblehead, Wearable, ...
.. ..- attr(, "factors")= int [1:14, 1:13] 0 1 0 0 0 0 0 0 0 0 ...
.. .. ..- attr(, "dimnames")=List of 2
.. .. .. .. : chr [1:14] "SINGLE" "OpeningDay" "OpeningWeekend" "PreASB" ...
.. .. .. .. : chr [1:13] "OpeningDay" "OpeningWeekend" "PreASB" "BOSNYY" ...
.. ..- attr(, "term.labels")= chr [1:13] "OpeningDay" "OpeningWeekend" "PreASB" "BOSNYY" ...
.. ..- attr(, "order")= int [1:13] 1 1 1 1 1 1 1 1 1 1 ...
.. ..- attr(, "intercept")= int 1
.. ..- attr(, "response")= int 1
.. ..- attr(, ".Environment")=<environment: R_GlobalEnv>
.. ..- attr(, "predvars")= language list(SINGLE, OpeningDay, OpeningWeekend, PreASB, BOSNYY, Holiday, DayGame, WeekdayDayGame, Bobblehead, Wearable, ...
.. ..- attr(, "dataClasses")= Named chr [1:14] "numeric" "numeric" "numeric" "numeric" ...
.. .. ..- attr(, "names")= chr [1:14] "SINGLE" "OpeningDay" "OpeningWeekend" "PreASB" ...
model :'data.frame': 81 obs. of 14 variables:
.. SINGLE : num [1:81] 10128 16738 14986 2898 2498 ...
.. OpeningDay : num [1:81] 1 0 0 0 0 0 0 0 0 0 ...
.. OpeningWeekend: num [1:81] 1 1 1 0 0 0 0 0 0 0 ...
.. PreASB : num [1:81] 1 1 1 1 1 1 1 1 1 1 ...
.. BOSNYY : num [1:81] 0 0 0 0 0 0 0 0 0 0 ...
.. Holiday : num [1:81] 0 0 0 0 0 0 0 0 0 0 ...
.. DayGame : num [1:81] 1 0 1 0 0 0 0 1 0 0 ...
.. WeekdayDayGame: num [1:81] 1 0 0 0 0 0 0 0 0 0 ...
.. Bobblehead : num [1:81] 0 0 0 0 0 0 0 0 0 0 ...
.. Wearable : num [1:81] 0 0 0 0 0 0 0 0 0 0 ...
.. OtherGiveaway : num [1:81] 0 0 1 0 0 0 0 0 0 0 ...
.. Kids : num [1:81] 0 0 0 0 0 0 0 0 0 0 ...
.. Concert : num [1:81] 0 0 0 0 0 0 0 0 0 0 ...
.. SpecEvent : num [1:81] 0 0 0 0 0 0 0 0 0 0 ...
..- attr(*, "terms")=Classes 'terms', 'formula' language SINGLE ~ OpeningDay + OpeningWeekend + PreASB + BOSNYY + Holiday + DayGame + WeekdayDayGame + Bobblehead + ...
.. .. ..- attr(*, "variables")= language list(SINGLE, OpeningDay, OpeningWeekend, PreASB, BOSNYY, Holiday, DayGame, WeekdayDayGame, Bobblehead, Wearable, ...
.. .. ..- attr(*, "factors")= int [1:14, 1:13] 0 1 0 0 0 0 0 0 0 0 ...
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. .. : chr [1:14] "SINGLE" "OpeningDay" "OpeningWeekend" "PreASB" ...
.. .. .. .. ..$ : chr [1:13] "OpeningDay" "OpeningWeekend" "PreASB" "BOSNYY" ...
.. .. ..- attr(, "term.labels")= chr [1:13] "OpeningDay" "OpeningWeekend" "PreASB" "BOSNYY" ...
.. .. ..- attr(, "order")= int [1:13] 1 1 1 1 1 1 1 1 1 1 ...
.. .. ..- attr(, "intercept")= int 1
.. .. ..- attr(, "response")= int 1
.. .. ..- attr(, ".Environment")=<environment: R_GlobalEnv>
.. .. ..- attr(, "predvars")= language list(SINGLE, OpeningDay, OpeningWeekend, PreASB, BOSNYY, Holiday, DayGame, WeekdayDayGame, Bobblehead, Wearable, ...
.. .. ..- attr(, "dataClasses")= Named chr [1:14] "numeric" "numeric" "numeric" "numeric" ...
.. .. .. ..- attr(*, "names")= chr [1:14] "SINGLE" "OpeningDay" "OpeningWeekend" "PreASB" ...
- attr(*, "class")= chr "lm"
Command was just Summary (Model 1) all previous code is in the original post
This may sound silly, but summary()
should have a lower case "s" and no space between the name and the parens.
That was it I just have one more question I have an as.factor with days of the week Monday Tuesday Wednesday Thursday how do I call out specific days.
You can use the labels argument to factor()
to create a factor with helpful labels.
how would i start this I am new to R and Rstudio
levels<-.factor
(Day) <---- Error in factor(Day) : object 'Day' not found
labels(Day) < ------ Error: unexpected symbol in "labels factor
Tried these from my light research I assumed I would have to call out the factor Day to find out the specific labels or levels in code but I can not get passed the errors.
I am trying to include Specific days from the as. factor $day into the model as separate so the code would be Rdata2019$friday <- as.factor Rdata2019$Friday.
I haven't tried this, but something like
RData2019$Day <- factor(RData2019$Day,labels = c("Sunday", "Monday"))
etc.
Here is my code
RData2019$Day <- factor(RData2019$Day,labels = C("Friday", "Saturday", "Sunday"))
Here Is My Error
object not interpretable as a factor
I need to call out those specific days as dependent variables in my LM() to see if it does affect those days.
Lowercase "c".
As a check, run distinct(RData2019$Day)
to be sure it has the values it's supposed to.
With Lowercase c
Code
RData2019$Day <- factor(RData2019$Day,labels = c("Friday", "Saturday", "Sunday"))
Error
Error in factor(RData2019$Day, labels = c("Friday", "Saturday", "Sunday")) :
invalid 'labels'; length 3 should be 1 or 7
Wit
I suspect there are 7 days, so you need seven labels. Try distinct()
to get a list of all possible values.
So i am having trouble with distinct ()
Code
distinct(RData2019$Day)
Error
Error in distinct(RData2019$Day) : could not find function "distinct"
I did a label(Rdata2019$Day)
This is what I recieved
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11"
[12] "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22"
[23] "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33"
[34] "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44"
[45] "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55"
[56] "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66"
[67] "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77"
[78] "78" "79" "80" "81"
Code
RData2019$Day <- factor(RData2019$Day,labels = c("Friday", "Saturday", "Sunday", "Monday", "Tuesday" , "Wednesday", "Thursday")
Result
RData2019$Day <- factor(RData2019$Day,labels = c("Friday", "Saturday", "Sunday", "Monday", "Tuesday" , "Wednesday", "Thursday"))
Looks like it works here
But then when I tray to call out Friday as a factor because I need to use in the model
I get this Error
Error in $<-.data.frame
(*tmp*
, Friday, value = integer(0)) :
replacement has 0 rows, data has 81
I forgot the distinct()
is part of tidyverse, so you need to do library(tidyverse)
first.
It looks like Day
isn't the day of the week. You're going to have to find out what the variable means before you can assign a label.
Code
library(tidyverse)
distinct(RData2019$Day)
Error
Error in UseMethod("distinct") :
no applicable method for 'distinct' applied to an object of class "factor"