Open main menu

kogic.kr β

Changes

Simple functions

180 bytes added, 13:34, 27 November 2018
no edit summary
<h1><span style="font-family:courier new,courier,monospace">Split the elements of a character vector like perl</spanp>[[YalPak_Rtip]]</h1p>
<h3 style="color:#aaa;font-style:italic;"h1><span style="font-family:courier new,courier,monospace">InputSplit the elements of a character vector and select an element</span></h3h1>
<div h3 style="backgroundcolor:#eeeaaa;borderfont-style:1px solid #ccc;padding:5px 10px;italic"><span style="font-family:courier new,courier,monospace">x &lt;- &quot;AAA@BBB&quot;Input</span></divh3>
<h3 div style="colorbackground:#aaaeee;border:1px solid #ccc;padding:5px 10px;"><span style="font-stylesize:italic;11px"><span style="font-family:courier new,courier,monospace">Codex &lt;- &quot;AAA@BBB&quot;</span></span></h3div>
<h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Code</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-size:11px"><span style="font-family:courier new,courier,monospace">split_pick &lt;- function(x , Div_str, Pick_num){<br />
&nbsp;&nbsp; &nbsp;return(as.character(as.data.table(strsplit(x, Div_str))[Pick_num]))&nbsp;<br />
}</span></span></div>
<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-size:11px"><span style="font-family:courier new,courier,monospace">split_pick(x, &quot;@&quot;, 2)</span></span></div>
<h3 style="color:#aaa;font-style:italic;"><span style="font-family:courier new,courier,monospace">Output</span></h3>
<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-size:11px"><span style="font-family:courier new,courier,monospace">&quot;BBB&quot;</span></span></div>
<p>&nbsp;</p>
1,007
edits