0

I have data of a Likert scale questionnaire regarding alcohol consumption and cigarette smoking. I want to look for a correlation between the 2 variables in R but I am a complete R newbie and don’t understand why it doesn’t work. The code I tried:

CrossTable(Do.you.consume.alcohol, Do.you.smoke.cigarettes , chisq = TRUE , expected = TRUE)

That’s the error message I get:

Error in CrossTable(Do.you.consume.alcohol, Do.you.smoke.cigarettes ,  : 
object 'Do.you.consume.alcohol' not found.

Does anybody know why is the object not found?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 3
    First of all it would be nice if you provide your actual code. We can't help you with guessing what's wrong. Second it would be good if you provide a sample dataset. In R you can use dput(your_dataset) to provide it to other users. – pbraeutigm Aug 09 '21 at 07:18
  • thanks for the willingness to help! it might be a stupid question but how do i provide the sample dataset here? my code is: df <- read.csv("/Users/itamarmichaeli/Desktop/alcohol.and.smoking.csv") library(gplots) CrossTable(Do.you.consume.alcohol, Do.you.smoke.cigarettes , chisq = TRUE , expected = TRUE) – jim halpert Aug 09 '21 at 07:53
  • Try `df$Do.you.consume.alcohol` instead of simply `Do.you.consume.alcohol`. The same for the cigarettes. – Martin Gal Aug 09 '21 at 07:57
  • 2
    In R Studo you can use dput(your_dataset) to provide it to other users. https://stackoverflow.com/questions/49994249/example-of-using-dput – pbraeutigm Aug 09 '21 at 08:08

0 Answers0