-1

I'm still very new to R, I have no other coding experience, and I don't understand some of the fundamentals, so please bear with me.

I'm trying to do a multiple regression on the data set found at: https://studysites.sagepub.com/dsur/study/DSUR%20Data%20Files/Chapter%207/ChildAggression.dat

The website's answers don't mention any transformation of the data, but suggest one could just go ahead with the lm() function.

aggro <- read.delim("ChildAggression.dat", header = TRUE)
aggro.reg1 <- lm(Aggression ~ Parenting_Style + Sibling_Aggression, data = aggro)

Error in eval(predvars, data, env) : object 'Aggression' not found

I don't understand why it isn't finding the object. Any help is much appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

The default separator for read.delim is \t, but the file isn't tab separated. You want sep = "" instead.

Having read in the file as you did:

aggro <- read.delim("ChildAggression.dat", header = TRUE)

there are numerous ways to detect that something is wrong:

> dim(aggro) #number of columns is clearly wrong
[1] 666   1
> names(aggro) #only one long concatenated column name
[1] "Aggression.Television.Computer_Games.Sibling_Aggression.Diet.Parenting_Style"
> colnames(aggro) #only one long concatenated column name
[1] "Aggression.Television.Computer_Games.Sibling_Aggression.Diet.Parenting_Style"
joran
  • 169,992
  • 32
  • 429
  • 468