You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading data with read_csv (and probably other read_* functions), I sometimes need to read only some columns and also rename them. When I try to do this with one call to read_csv, I would expect that when I use both the col_select and col_names keywords, I have to provide only new names for the selected columns, but instead, in order for the function to produce the desired output, I have to provide names for all columns in the file, which is somewhat annoying, at least in my particular use case.
In the below example, I think it is much more natural to use the 1. test case, however the result I expect is produced only by the 2. function call, the 1st one giving an error.
library("readr")
# Create test filereadr::write_csv(data.frame(array(1:24, c(6, 4))), "test.csv")
# TEST CASES:# 1. Attempt (and fail) to select AND remane simultaneouslyreadr::read_csv("test.csv", col_select=2:3, skip=1, col_names= paste0("col", 2:3))
# 2. Working (but unpleasant) solution: provide new names for ALL columnsreadr::read_csv("test.csv", col_select=2:3, skip=1, col_names= paste0("col", 1:4))
The text was updated successfully, but these errors were encountered:
When reading data with
read_csv
(and probably otherread_*
functions), I sometimes need to read only some columns and also rename them. When I try to do this with one call toread_csv
, I would expect that when I use both thecol_select
andcol_names
keywords, I have to provide only new names for the selected columns, but instead, in order for the function to produce the desired output, I have to provide names for all columns in the file, which is somewhat annoying, at least in my particular use case.In the below example, I think it is much more natural to use the 1. test case, however the result I expect is produced only by the 2. function call, the 1st one giving an error.
The text was updated successfully, but these errors were encountered: