Hello!
I'm using RStudio 2023.06.1, R 4.3.0, on a Windows 10.
I am reading a ".sav" (SPSS) file, directly converting it into data.frame, and extracting and reformating some columns. Nothing advanced.
I use foreign::read.spss with to.data.frame=TRUE
The possible problem is that the file has German characters, also in the column names. It is all correctly recognized, at least when run manually on the console. Everything works fine.
When I run Ctrl+Shift+S I get errors which seem to fall exactly in such columns with German character "ä ö ü".
The error I get is "arguments imply differing number of rows", so it is not saying the column doesn't exist, but it is apparently returning an empty vector.
I also tried opening the .sav file with haven::read_sav, but there I cannot even open the file. Once again, it works 100% fine run on the console, but with "Run all" I get "Error in xtfrm.data.frame(x) : cannot xtfrm data frames", which I don't even know what is about.
Edit: when I ask colnames() the column name comes correctly as "WSTÜGOK2"
I am trying to get the values with $WSTÜGOK2.
When I try [,"WSTÜGOK2"] and run, I get the error
... "WSTÃœGOK2") : undefined columns selected
So depending on how I run the code the encoding used is different? How to work like this? and how to work around this, if the colnames() returns the column name correctly but the Run understands my script in wrong encoding?
Does anyone have a light on this? I'm very clueless right now.
Thank you very much!