Search
 
SCRIPT & CODE EXAMPLE
 

R

r select column names starting with

#  Data
df <- data.frame( ABC_1 = runif(3),
            ABC_2 = runif(3),
            XYZ_1 = runif(3),
            XYZ_2 = runif(3) )

#      ABC_1     ABC_2     XYZ_1     XYZ_2
#1 0.3792645 0.3614199 0.9793573 0.7139381
#2 0.1313246 0.9746691 0.7276705 0.0126057
#3 0.7282680 0.6518444 0.9531389 0.9673290

#  Use grepl
df[ , grepl( "ABC" , names( df ) ) ]
#      ABC_1     ABC_2
#1 0.3792645 0.3614199
#2 0.1313246 0.9746691
#3 0.7282680 0.6518444

#  grepl returns logical vector like this which is what we use to subset columns
grepl( "ABC" , names( df ) )
#[1]  TRUE  TRUE FALSE FALSE
Comment

r select columns by name

bd %>% select(var, anio, yor)
Comment

PREVIOUS NEXT
Code Example
R :: change color theme of fill R 
R :: sumif in r 
R :: timestamp conversion from excel R 
R :: change font color in geom_text in ggplot2 in R 
R :: barplot_density 
R :: print in r 
R :: r - if value in a df is between two number then add 1 
Rust :: get random enum rust 
Rust :: bevy window descriptor 
Rust :: convert string to i32 rust 
Rust :: remove file rust 
Rust :: rust read lines from stdin and return a vec 
Rust :: debug rust 
Rust :: rust javascript 
Rust :: rust iterate vector backwards 
Rust :: pause rust 
Rust :: string and str to string rust 
Rust :: rust loop vector by size 
Rust :: armanriazi•rust•static 
Rust :: greater than equal to rust 
Rust :: rust what does the double colon mean? 
Rust :: blank struct rust 
Rust :: trait in rust 
Lua :: base64 decode lua 
Lua :: how to stop a renderstepped loop in lua 
Lua :: roblox studio lua for loop 
Lua :: lua hello world function 
Lua :: repeat until in lua 
Lua :: lua f animation 
Lua :: Set core GUI Roblox 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =