Skip to content

Commit

Permalink
read_csv: add warning if duplicate col or row names
Browse files Browse the repository at this point in the history
- This is related to the problem that underlies Issue rqtl#209
  • Loading branch information
kbroman committed Oct 24, 2022
1 parent de7c938 commit 1accd5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- Give a better error message in `genoprob_to_snpprob()` if `snpinfo`
is missing the `sdp` column (Issue #207).

- In `read_cross()`, give warnings if there are duplicate column names
or duplicate row names in the file.


## qtl2 0.28 (2021-10-11)

Expand Down
9 changes: 8 additions & 1 deletion R/read_csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ read_csv <-
}
}

if(length(unique(colnames(x))) != ncol(x))
warning("duplicate column names in file ", filename)

# move first column to row names
if(rownames_included)
if(rownames_included) {
x <- firstcol2rownames(x, filename)

if(length(unique(rownames(x))) != nrow(x))
warning("duplicate row names in file ", filename)
}

# transpose if requested
if(transpose)
x <- as.data.frame(t(x), stringAsFactors=FALSE)
Expand Down

0 comments on commit 1accd5e

Please sign in to comment.