Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Separators for the same file input R
    primarykey
    data
    text
    <p>I've had a look for answers, but have only found things referring to C or C#. I realise that much of R is written in C but my knowledge of it is non-existent. I am also relatively new to R. I am using the current Rstudio.</p> <p>This is similar to what I want, I think. <a href="https://stackoverflow.com/questions/17606321/read-the-data-efficiently-with-multiple-separating-lines-in-r">Read the data efficiently with multiple separating lines in R</a></p> <p>I have a csv file but one variable is a string with values separated by <code>_</code> and <code>-</code> And I would like to know if there is a package or extra code which does the following on the read. command.</p> <pre><code>"1","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_ANDROID","2013-08-31 13:39:55.0","2013-10-16 13:58:00.0",0,218,4,93,1377907200000 "2","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_ANDROID","2013-08-31 13:39:55.0","2013-10-16 13:58:00.0",0,390,5,157,1377993600000 "3","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_ANDROID","2013-08-31 13:39:55.0","2013-10-16 13:58:00.0",0,376,5,193,1.37808e+12 "4","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_ANDROID","2013-08-31 13:39:55.0","2013-10-16 13:58:00.0",1,35,1,15,1377907200000 "5","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_ANDROID","2013-08-31 13:39:55.0","2013-10-16 13:58:00.0",12,11258,117,2843,1377993600000 "6","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_ANDROID","2013-08-31 13:39:55.0","2013-10-16 13:58:00.0",5,4659,56,1826,1.37808e+12 "7","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_ANDROID","2013-08-31 13:39:55.0","2013-10-16 13:58:00.0",7,7296,136,2684,1377907200000 "8","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_IOS_IPAD","2013-08-31 13:18:21.0","2013-10-16 13:58:00.0",0,4533,35,1632,1377907200000 "9","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_IOS_IPAD","2013-08-31 13:18:21.0","2013-10-16 13:58:00.0",0,421,6,161,1377993600000 "10","Client1","Name2","*Name3_Name1_KB_MobApp_M-13-44_AU_PI Likes by KB_IOS_IPAD","2013-08-31 13:18:21.0","2013-10-16 13:58:00.0",0,57,2,23,1.37808e+12 </code></pre> <p>Example row:</p> <pre><code>Name Name1 *XYZ_Name3_KB_MobApp_M-18-25_AU_PI ANDROID 2013-09-32 14:39:55.0 2013-10-16 13:58:00.0 0 218 4 93 1377907200000 </code></pre> <p>So it's easy enough to read in </p> <pre><code>results &lt;- read.delim("~/results", header=F) </code></pre> <p>but then I still have the string *XYZ_Name3_KB_MobApp_M-18-25_AU_PI</p> <p>Desired output(separate by <code>_</code> and by <code>-</code>):</p> <pre><code>Name Name1 *XYZ Name3 KB MobApp M 18 25 AU PI ANDROID 2013-09-32 14:39:55.0 2013-10-16 13:58:00.0 0 218 4 93 1377907200000 </code></pre> <p>but not split up the time string.</p> <p>---- Thanks @Henrik and @AnandaMahto for the code and package. ----</p> <pre><code>library(splitstackshape) # split concatenated column by `_` df4 &lt;- concat.split(data = df3, split.col = "V3", sep = "_", drop = TRUE) # split the remaining concatenated part by `-` df5 &lt;- concat.split(data = df4, split.col = "V3_5", sep = "-", drop = TRUE) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload