Beginner for an Assignment! Error message constant

Hoping someone can help...
We have been instructed as part of a research assignment to use RStudio for data analysis....while I am computer literate I am not this level!

I have imported the data set using the click options, I have installed and accessed the library for car, QuantPsyc, reshape and mediation. A youtube recommended Lavaan so that's there too. I have given it the command to read my CSV and still the same error. I'm sure this is something basic but as I said I am a beginner beginner and this is not fun!
Here is my script so far....This is my second file attempt, my first came up with the same errors

library(readr)
Warning message:
R graphics engine version 14 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
Assignment_Data_Updated <- read_csv("Assignment_Data_Updated.csv")

-- Column specification --------------------------------------
cols(
Rel.Sat = col_double(),
LifeSat = col_double(),
Wellbeing = col_double(),
Gender = col_character(),
Age = col_double()
)

View(Assignment_Data_Updated)

Satisfaction <- lm (Wellbeing ~ LifeSat, data = Rel.Sat)
Error in is.data.frame(data) : object 'Rel.Sat' not found
library (readr)
df <- read_csv("Assignment_Data_Updated.csv")

-- Column specification --------------------------------------
cols(
Rel.Sat = col_double(),
LifeSat = col_double(),
Wellbeing = col_double(),
Gender = col_character(),
Age = col_double()
)

SatisfactionModel <- lm (Wellbeing ~ LifeSat, data = Rel.Sat)
Error in is.data.frame(data) : object 'Rel.Sat' not found
install.packages("lavaan")
Installing package into ‘C:/Users/User/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
also installing the dependencies ‘tmvnsim’, ‘mnormt’, ‘pbivnorm’

The downloaded binary packages are in
C:\Users\User\AppData\Local\Temp\RtmpGK3u15\downloaded_packages

library (lavaan)
This is lavaan 0.6-8
lavaan is FREE software! Please report any bugs.
SatisfactionModel <- lm (Wellbeing ~ LifeSat, data = Rel.Sat)
Error in is.data.frame(data) : object 'Rel.Sat' not found

1 Like

The data argument to lm should be the data frame you read. Try this.

Assignment_Data_Updated <- read_csv("Assignment_Data_Updated.csv")
Satisfaction <- lm (Wellbeing ~ LifeSat, data = Assignment_Data_Updated)
summary(Satisfaction)
1 Like

Can you tell us which versions of RStudio and R that you are using?

 sessionInfo()

will give you the R version.

That worked! thank you!

As I'm running a mediation analysis and that was path c, would path a be:

SatisfactionModel <- lm(Rel.Sat ~ LifeSat, data = Assignment_Data_Updated) summary(Satisfaction)

and paths b and c:

SatisfactionModel <- lm (Wellbeing ~ LifeSat + Rel.Sat, data = Assignment_Data_Updated) Summary(Satisfaction)

I received an error that the latest version was not compatible with my OS so I'm running R i386 4.1.0 and the older Studio 1.1.463

Hmmmm there's obviously another flaw in my code as my summary isn't bringing up the latest formula but the original one....and I had to type in Call:
lm(formula = Wellbeing ~ LifeSat + Rel.Sat, data = Assignment_Data_Updated) to get the summary that I got

Unless I am only supposed to get the coefficient here not the full summary as I did for the first formula summary

If there is a website that anyone can recommend (I've already downloaded the PDF for R for dummies!) that might explain these basics please share....I need to run a regression analysis too!

humm, there are some reports of incompatibilities with something like ggplot2 and R 4,1.x but I do not remember them affecting things like lm()

Can you give us a reproducible example (reprex)

We probably need to step through tnhe code to get a feel for what is happening.

A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with.

What is your OS?

This was my first summary that was from Arthur.t's solution

Satisfaction <- lm (Wellbeing ~ LifeSat, data = Assignment_Data_Updated)
summary(Satisfaction)

Call:
lm(formula = Wellbeing ~ LifeSat, data = Assignment_Data_Updated)

Residuals:
Min 1Q Median 3Q Max
-4.0313 -0.8293 0.2667 0.8298 2.9131

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.57149 0.49694 5.175 5.80e-07 ***
LifeSat 0.81823 0.09129 8.963 3.05e-16 ***

Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.313 on 189 degrees of freedom
Multiple R-squared: 0.2983, Adjusted R-squared: 0.2945
F-statistic: 80.33 on 1 and 189 DF, p-value: 3.054e-16

I tried to then duplicate that for path a and then b and c together...this was my result (it won't let me reply with links although I can't see any links in there)

Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘Summary’ for signature ‘"lm"’
and the summary just gives me:
Coefficients:
(Intercept) LifeSat Rel.Sat
1.2508 0.7351 0.2884

just tried to sample data:
dput()
Error in dput() : argument "x" is missing, with no default

Turns out I was using my renamed model instead of the original modelXY/modelXMY

Thank you so much for your time and help I appreciate it! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.