Dear R helpers

I have following input

f = c(257, 520, 110). I need to generate a decreasing sequence (decreasing by 
100) which will give me an input (in a tabular form) like

257, 157, 57
520, 420, 320, 220, 120, 20
110, 10


I tried the following R code


f = c(257, 520, 110)
yy = matrix(data = NA, nrow = 3, ncol = 6)

for (i in 1:3)
     {
     value = NULL

     for (j in 1 : 6)
          {
          value = c(ans, seq(f[i], 1, by = -100))
          }
    yy[i,] = ans[i,j]
    }

I get following message

Error in ans[i, j] : incorrect number of dimensions. Also, I understand above 
logic will generate a result in (3 by 6) matrix format, while I need to 
generate only 3 numbers pertaining to first no. i.e. 257, 6 nos. beginning from 
520, and only 2 numbers beginning from 110. I also tried tapply etc.

Please guide

Vincy





        [[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