我有一个包含5列的表dk_apple_1,pineapple_dk,egg_dk_one,ice_44,shift3。如何选择带有dk字符的列名? 因此,结果我只选择了数据集的前三列。
答案 0 :(得分:3)
您还可以将<h1> Tous les articles ! </h1> <p> <%= link_to 'Créer un article',
new_article_path %> </p> <table>
<tr>
<th> Titre</th>
<th>Description</th>
</tr>
<% @articles.each do |article| %>
<tr>
<td><%= article.title %><td>
<td><%= article.description %><td>
<td><%= link_to 'Edit', edit_article_path(article)%></td>
<td><%= link_to 'Show', article_path(article)%></td>
<td><%= link_to 'Delet', article_path(article), method: :delete%></td>
</tr>
<%end%> </table> <%= link_to 'Home', root_path %>
用于基本的R解决方案:
grepl
请注意,df[grepl("dk", names(df), fixed=TRUE)]
选项仅意味着我们实际上并不需要使用完整的正则表达式引擎,而只是想要一个精确的子字符串匹配。
答案 1 :(得分:1)
一个选项。来自export const sampleData=[
{ x: 1, y: 2 },
{ x: 2, y: 3 },
{ x: 3, y: 5 },
{ x: 4, y: 4 },
{ x: 5, y: 7 }
]
的{{1}}
startsWith
答案 2 :(得分:0)
dplyr具有根据名称选择列的功能。 tidyr匹配列名称中的模式,因此使用tidyverse的dplyr和tidyr包
library(tidyverse)
df<- df %>%
dplyr::select(tidyr::contains("dk"))
参考tidyverse here