In a pandas dataframe created like this:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(10, size=(6, 6)),
colu
A solution using dplyr package but you need to specify the row you want to select before hand
rowName2Match <- c("r1", "r5")
df1 <- df %>%
select(matches("2"):matches("4")) %>%
add_rownames() %>%
mutate(idRow = match(rowname, rowName2Match)) %>%
slice(which(!is.na(idRow))) %>%
select(-idRow)
df1
> df1
Source: local data frame [2 x 4]
rowname c2 c3 c4
1 r1 2 3 4
2 r5 6 7 8