Skip to content

Commit

Permalink
Ensure stringsAsFactors=FALSE for all reads
Browse files Browse the repository at this point in the history
  • Loading branch information
bpbond committed Feb 29, 2024
1 parent 3957fe0 commit 3ba4b9e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/read_data_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ wtf_read_LI78x0 <- function(file, model) {

# Read the data, construct TIMESTAMP, add metadata,
# and remove unneeded LI-COR DATE and TIME columns
dat <- read.table(textConnection(dat_raw), na.strings = "nan", header = TRUE)
dat <- read.table(textConnection(dat_raw),
na.strings = "nan",
header = TRUE,
stringsAsFactors = FALSE)
dat$TIMESTAMP <- lubridate::ymd_hms(paste(dat$DATE, dat$TIME), tz = tz)
dat$TZ <- tz
dat$SN <- sn
Expand Down Expand Up @@ -91,7 +94,9 @@ wtf_read_LGR915 <- function(file, tz = "UTC") {
dat_raw <- readLines(file)

# A single header line encodes version number, date, and serial number
dat <- read.csv(textConnection(dat_raw[-1]), check.names = FALSE)
dat <- read.csv(textConnection(dat_raw[-1]),
check.names = FALSE,
stringsAsFactors = FALSE)
dat$Time <- mdy_hms(dat$Time, tz = tz)
dat$SN <- trimws(gsub(".*SN:", "", dat_raw[1]))
dat$MODEL <- "915-0011"
Expand Down

0 comments on commit 3ba4b9e

Please sign in to comment.