Bug 17289 - Inconsistent NA handling in scan()
Summary: Inconsistent NA handling in scan()
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.3.*
Hardware: All Windows 64-bit
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-06-16 16:10 UTC by floid.r.gilbert
Modified: 2017-06-16 16:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description floid.r.gilbert 2017-06-16 16:10:04 UTC
The scan() function's NA handling is inconsistent for different target data types when na.strings = NULL.

# Throws error (good)
scan(text = c("1 NA"), what = integer(), na.strings = NULL, quiet = TRUE)
# Does not throw error (bad)
scan(text = c("1 NA"), what = double(), na.strings = NULL, quiet = TRUE)

# The same goes for NA constant.
# Throws error (good)
scan(text = c("1", NA), what = integer(), na.strings = NULL, quiet = TRUE)
# Does not throw error (bad)
scan(text = c("1", NA), what = double(), na.strings = NULL, quiet = TRUE)