Hello,
If I open in jamovi a database in SPSS format generated with R and haven::write_sav (jamovi won't open the RData version of the same database), I realize that the data type of the factors is integer (as factors seems to be stored as integers in R). Is there a way to avoid having to change those data types in jamovi (from integer to text) ?
Thank you !
Pierre-Guillaume
Data type of R factors opened in jamovi
Data type of R factors opened in jamovi
Last edited by pgtpg on Thu Mar 26, 2020 9:38 pm, edited 1 time in total.
Re: Data type of R factors opened in jamovi
hi,
so this would be to do with the behaviour of haven::write_sav(). try converting your factors to character vectors and see if that gets you the behaviour you want.
cheers
so this would be to do with the behaviour of haven::write_sav(). try converting your factors to character vectors and see if that gets you the behaviour you want.
cheers
Re: Data type of R factors opened in jamovi
Thank you for your answer.
But the problem is, if I convert the factors to character vectors, I lose the benefit of factors, which are levels, very convenient to make R and also jamovi to produce analysis where variables values are sorted in a defined order.
Cheers
Pierre-Guillaume
But the problem is, if I convert the factors to character vectors, I lose the benefit of factors, which are levels, very convenient to make R and also jamovi to produce analysis where variables values are sorted in a defined order.
Cheers
Pierre-Guillaume
Last edited by pgtpg on Thu Mar 26, 2020 9:38 pm, edited 1 time in total.
Re: Data type of R factors opened in jamovi
hi,
i'm sure there's a way to do what you want, but i'm 99% sure that jamovi is doing everything correctly here, and it's on the haven side of things that you want to get correct.
take a look here (it's a bug report, but the example shows how to attach labels to factors in data frames):
https://github.com/tidyverse/haven/issues/193
jonathon
i'm sure there's a way to do what you want, but i'm 99% sure that jamovi is doing everything correctly here, and it's on the haven side of things that you want to get correct.
take a look here (it's a bug report, but the example shows how to attach labels to factors in data frames):
https://github.com/tidyverse/haven/issues/193
jonathon
Re: Data type of R factors opened in jamovi
Hi,
Thank you ! I'll try a few things to get that issue solved. And if I can't succeed, I'll just change the data types of the few variables "by hand" in jamovi.
Have a nice day !
Pierre-Guillaume
Thank you ! I'll try a few things to get that issue solved. And if I can't succeed, I'll just change the data types of the few variables "by hand" in jamovi.
Have a nice day !
Pierre-Guillaume
Last edited by pgtpg on Thu Mar 26, 2020 9:39 pm, edited 1 time in total.
Re: Data type of R factors opened in jamovi
Hi again,
And I just saw that jamovi considers factors, ordered (ordered = TRUE) or not, as ordinal variables. All of this seems to be linked with the nature of factors in R.
Thanks again !
Pierre-Guillaume
And I just saw that jamovi considers factors, ordered (ordered = TRUE) or not, as ordinal variables. All of this seems to be linked with the nature of factors in R.
Thanks again !
Pierre-Guillaume
Last edited by pgtpg on Thu Mar 26, 2020 9:39 pm, edited 1 time in total.
Re: Data type of R factors opened in jamovi
you can see the code we use to infer the measure type here:
https://github.com/jamovi/jamovi/blob/m ... tat.py#L92
we do a little trickery, where we adjust things if the user appears to have the column set up incorrectly, but mostly we honour what's contained in the .sav file.
if it's coming through as ordinal, that probably means it's specified as a 'scale' variable in the .sav file, with labels attached to it. this usually means the user actually wants an ordinal variable. so you probably need to do a little more trickery with haven to get the desired result
cheers
jonathon
https://github.com/jamovi/jamovi/blob/m ... tat.py#L92
we do a little trickery, where we adjust things if the user appears to have the column set up incorrectly, but mostly we honour what's contained in the .sav file.
if it's coming through as ordinal, that probably means it's specified as a 'scale' variable in the .sav file, with labels attached to it. this usually means the user actually wants an ordinal variable. so you probably need to do a little more trickery with haven to get the desired result
cheers
jonathon