Hi everyone,
I'm doing a mediation analysis using complex sample survey. But when I try to upload data from SPSS into R, It gives me an error that data is not numeric, even though is numeric...I looked at others that had similar issues and it seems that commas were an issue and I tried to add the argument "stringsAsFactors=false", but code still not working....
read.csv("C:/...pathcases.sav", stringsAsFactors = FALSE)
(I put the actual C:/ path to the dataset in the code).
Gives this error:
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to contain embedded nulls
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 2 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 3 appears to contain embedded nulls
4: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'C:/...path cases.sav'
I also tried to reformat before, but still didn't work..
library('tidyverse')
152,821" %>% factor %>% str_replace(',', '') %>% as.numeric
I'm at a loss...how can I make R see that the data uploaded is numeric/or how to convert it from factor to numeric, so I can run the medication analysis ? (I'm doing survey mediation analysis using med.fit.BRR.
The dependent variable that I have is coded as numeric: cognition score raging from 20-35 for 16000 participants.
Thank you!!