Hi there,

is there a way to make the following code generic, so that i can paste()
the columns in tmp1 depending on the dimensions given in embed()?

> tmp1 <- embed(as.vector(shrinkTable$AOIname), dimension = 2);
> tmp1
       [,1]   [,2]
 [1,] "AOI4" "AOI1"
 [2,] "AOI6" "AOI4"
 [3,] "AOI4" "AOI6"
> tmp2 <- paste(tmp1[, 2], tmp1[, 1], sep = ">");
> tmp2
 [1] "AOI1>AOI4" "AOI4>AOI6" "AOI6>AOI4"

for dimension = 3 this would look like this:

> tmp1 <- embed(as.vector(shrinkTable$AOIname), dimension = 3);
> tmp1
      [,1]   [,2]   [,3]
 [1,] "AOI6" "AOI4" "AOI1"
 [2,] "AOI4" "AOI6" "AOI4"
> tmp2 <- paste(tmp1[ ,3], tmp1[, 2], tmp1[, 1], sep = ">");
> tmp2
 [1] "AOI1>AOI4>AOI6" "AOI4>AOI6>AOI4"

Any ideas?

Thanks for your help,


Robert Lischke

______________________________________________
[email protected] 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