Hey,

big help, thanks!
One little question remains, if I create
more then one string and table ...
---------------------

# generate an input string n long
set.seed(123)
n <- 300
lets_1 <- paste(sample(letters[1:5], n, replace = TRUE), collapse = "")
lets_2 <- paste(sample(letters[1:5], n, replace = TRUE), collapse = "")


# get rolling k-length sequences and count
k <- 3
table_1 <-table(substring(lets_1, 1:(n-k+1), k:n))
table_2 <-table(substring(lets_2, 1:(n-k+1), k:n))
-----------------------

is it possible to manipulate table_1 so that it contains zero entries
for all the substrings found in table_2 but not in table_1?

best regards
Immanuel






> Try this:
>
> # generate an input string n long
> set.seed(123)
> n <- 300
> lets <- paste(sample(letters[1:5], n, replace = TRUE), collapse = "")
>
> # get rolling k-length sequences and count
> k <- 3
> table(substring(lets, 1:(n-k+1), k:n))
>
>   


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to