Post #2312768
2026-05-07 23:15 UTC
@LeafyEricScott@hachyderm.io I'm not sure about R (haven't used it in a _long_ time), but in Haskell I'd create a datatype for the row (Row Double String (Maybe Bool)) and create a parser that splits based on ',' (or whatever delimiter) and reads in each field. As might have been apparent, we allow for the third field in the data type to be `Nothing` or `Just `, and an Integer can be parsed as a Double, so no problem there either.
Replies (1)
-
@chiraag@mastodon.online 2026-05-07 23:21
@LeafyEricScott@hachyderm.io My parse function is: parse = ((\y -> case y of { [ai,bi] -> Row (read ai :: Double) bi Nothing; [ai,bi,ci] -> Row (read ai :: Double) bi (Just (read ci :: Bool)); _ -> error "Wrong number of fields" }) . LS.splitOn ",") (Yes, I could generalize this over a user-supplied delimiter, but you get the idea). I would think there would be a way in R to specify that a column is optional, but perhaps not...