i have table like:
$v1 $v2 $v3 toto|380 peper|728a tomato|i765 toto|458 peper|798a ognion|l965 toto|3l0 ginger|2r8a lemon|i765
and split "|" , :
$v1 $v2 $v3 toto peper tomato toto peper ognion toto ginger lemon
i tried with:
split(data, sep="|")
but it's not working.
do have idea?
you looking sub
or gsub
, or possibly strsplit
--but not split
:
mydf[] <- lapply(mydf, function(x) { sub("\\|.*$", "", x) }) mydf ## x.v1 x.v2 x.v3 ## 1 toto peper tomato ## 2 toto peper ognion ## 3 toto ginger lemon
Comments
Post a Comment