Many Thanks JS
karim
On Thu, Mar 5, 2015 at 4:08 AM, JS Huang wrote:
> Hi,
>
> Here is one for preserving the first strings. as.numeric in the previous
> posting is not necessary.
>
> > temp
> $set1
> [1] "a" "b" "d" "x"
>
> $set2
> [1] "b" "c" "q" "m"
>
> $set3
> [1] "b" "f" "e" "k" "q" "h"
Hi,
Here is one for removing repeated strings.
> temp
$set1
[1] "a" "b" "d" "x"
$set2
[1] "b" "c" "q" "m"
$set3
[1] "b" "f" "e" "k" "q" "h"
> sapply(1:3,function(x){temp[[x]][as.numeric(table(unlist(temp))[temp[[x]]])==1]})
[[1]]
[1] "a" "d" "x"
[[2]]
[1] "c" "m"
[[3]]
[1] "f" "e" "k" "h"
Hi,
Here is one for preserving the first strings. as.numeric in the previous
posting is not necessary.
> temp
$set1
[1] "a" "b" "d" "x"
$set2
[1] "b" "c" "q" "m"
$set3
[1] "b" "f" "e" "k" "q" "h"
> sapply(1:length(temp),function(x){c <- list(); for (j in 1:x){c <-
> c(c,temp[[j]])}; temp[[x
Hi,
To avoid hardcoded 1:3, here is some revision.
> temp
$set1
[1] "a" "b" "d" "x"
$set2
[1] "b" "c" "q" "m"
$set3
[1] "b" "f" "e" "k" "q" "h"
> sapply(1:*length(temp)*,function(x){temp[[x]][as.numeric(table(unlist(temp))[temp[[x]]])==1]})
[[1]]
[1] "a" "d" "x"
[[2]]
[1] "c" "m"
[[3]]
[1]
Dear All,
here an example
temp <- list(set1=c("a","b","d","x"), set2=c("b","c","q","m"),
set3=c("b","f","e","k","q","h"))
preserve only the first one string
>temp
set1 a b d x
set2 c q m
set3 f e k h
OR
remove repeated string
>temp
set1 a d x
set2 c m
set3 f e k h
Thanks
[[alternativ
5 matches
Mail list logo