madeleineudell / LowRankModels.jl

LowRankModels.jl is a julia package for modeling and fitting generalized low rank models.
Other
190 stars 65 forks source link

Working with the "psych" Rdataset and converting NaN to NA in a dataframe #45

Closed NandanaSengupta closed 9 years ago

NandanaSengupta commented 9 years ago

Hi,

Just wanted to let you know that the basic example in the README file is not working right now because of the presence of NaN values. Currently running

import RDatasets df = RDatasets.dataset("psych", "msq") glrm, labels = GLRM(df,2)

returns the error "ERROR: Observed value in entry (1, 9) is NaN."

It would be useful to have an option in the GLRM command to treat NaN as NA. In the absence of that could you let me know how to convert NaN values to NA in a Julia DataFrame? It seems to be a non-trivial problem (I (unsuccessfully) tried many variants of "df[isnan(df)] = NA" ).

Thanks! Nandana

madeleineudell commented 9 years ago

Sure! Just preprocess the data frame with NaNs_to_NAs!(df) or call GLRM(df, 2; NaNs_to_NAs = true). I've changed the example to use the latter option, and updated the README.

NandanaSengupta commented 9 years ago

Great thanks! I did manage to code the NaNs to NAs -- but my code wasn't general, so this helps a lot.