Search code examples
r

Print result of a function in R


I am trying to find Mcdonald's omega for my data. And following this tutorial my R code looks like this:

if(!require('readr')) {
  install.packages('readr')
  library('readr')
}
library(psych)
my.data <- read.file("path to my .csv file")
omega(my.data)

But there is no output in the console. How can I see the Mcdonald's omega values for my data?

P.s. I have freshly installed Rstudio and this is my first R code, so I am sorry if the question is very simple...


Solution

  • I can see the following problems in your code:

    1. read.file() needs to be replaced with read_csv() or read.csv() based on the libraries being used in the code.
    2. print() function is missing - if you directly use omega (you may not be able to see the results always. use print(omega(my.data)).

    Corrections:

    1. my.data <- read_csv("path/to/your_file.csv")

    2. print(omega(my.data))

    Try this and see if that works.