我想dplyr::select_if()可能是你要找的。例如
?...二、Dplyr能实现的小动作 1.arrange 排序按某一/两列值的大小,按照升/降对行排序。...4.select 按列筛选(选择符合要求的列) select(frame3,geneid,expression) #选择特定两列 select(frame3,-Sampleid) #反选,all but...,一个是dplyr里的bind_rows 按行拼接时,列数、列名需要一致 rbind(frame...
select columns while join DT1[DT2, .(z, i.mul)] left_join(select(DT2, x, y, mul), select(DT1, x, y, z)) # 3. aggregate while join DT1[DT2, .(sum(z) * i.mul), by = .EACHI] DF1 %>% group_by(x, y) %>% summarise(z = sum(z)) %>% inner_join(DF2...
# Select all but one column (e.g., listing_id) airbnb_listings %>% select(-listing_id) # Select all columns within a range airbnb_listings %>% select(country : year_listed) # Reorder columns using relocate() airbnb_listings %>% relocate(city, country) # Rename a column using renam...
How can I represent one column's values using multiple columns in R where one new column is conditional? Looking at similar questions, I could not find one that matched my need. If one does contain a solution, please share its link....
The OP's dataset has 30 columns where all the column names start with 'inq'. So, with starts_with, it returns all columns, and adding ends_with, it is checking an OR match, e.g. sf_df %>% select(starts_with("inq"), ends_with("5")) %>% ncol #[1] 30 ...
select(tbl, color) # A tibble: 5 × 1 # color # <fctr> # 1 blue # 2 black # 3 blue # 4 blue # 5 black # select all other columns except color column equals select value column select(tbl, -color) # A tibble: 5 × 1 ...
brazil <- brazil %>% select(-(6:7)) # Let's look at the first twenty rows. While we are at it we will # omit columns 6 and 7 since the have all missing values anyway brazil %>% slice (1:20) # A tibble: 20 x 7
functions to an arbitrary column and grouping variable of your choice based on string inputs… But that was not the end In one part of the Win-Vector blog they have the following challenge: To write such a function in dplyr can get quite hairy, quite quickly. Try it yourself, and see ...
dplyr: A grammar of data manipulation. Contribute to tidyverse/dplyr development by creating an account on GitHub.