I may be wrong, but I thought the original poster was trying to make a matrix ('metric' sp.) of values, R, so that R[i,j] == f(t[i], h[i]) for all i and j where f <- function(t, h)exp(-(t/eta*(1-h))^(beta*(1-h)) outer() would do that: R <- outer(t, h, function(t, h)exp(-(t/eta*(1-h))^(beta*(1-h)))) It dimensions are length(t) by length(h), 111 by 9, not the 110 by 10 mentioned in the post.
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of David Winsemius > Sent: Friday, September 09, 2011 1:25 PM > To: Halabi, Anan > Cc: r-help@R-project.org > Subject: Re: [R] Reliability metric > Importance: High > > > On Sep 9, 2011, at 3:14 PM, Halabi, Anan wrote: > > > > > Hi, > > Below is the code I write, > > I am trying to create a metric of h and t while the values is out of > > function R. > > First I have message warning > > It is only a warning. > > > Second, the metric is not created > > What "not created" means has already been question by Weylandt. What > you seem to have missed in your introductory material is the concept > of "recycling of arguments". Look at this code and its results: > > > (1:10) * (1:2) > # [1] 1 4 3 8 5 12 7 16 9 20 > > > (1:10) * (1:3) > # [1] 1 4 9 4 10 18 7 16 27 10 > Warning message: > In (1:10) * (1:3) : > longer object length is not a multiple of shorter object length > > -- > David. > > > > > >> h <- seq(0.1, 0.9, by=0.1) > >> t <- seq(0,11000, by=100) > >> z <- cbind(t) > >> eta=10000 > >> beta=2 > >> R <- array (1:1100, dim= c(110,10)) > >> R= exp(-(z/eta*(1-h))^(beta*(1-h))) > > Warning messages: > > 1: In z/eta * (1 - h) : > > longer object length is not a multiple of shorter object length > > 2: In (z/eta * (1 - h))^(beta * (1 - h)) : > > longer object length is not a multiple of shorter object length > >> R > > t > > [1,] 1.0000000 > > [2,] 0.9995586 > > [3,] 0.9974647 > > [4,] 0.9919725 > > [5,] 0.9801987 > > [6,] 0.9572081 > > [7,] 0.9141353 > > [8,] 0.8341665 > > [9,] 0.6833618 > > [10,] 0.9892125 > > [11,] 0.9825766 > > [12,] 0.9727664 > > [13,] 0.9583520 > > [14,] 0.9370675 > > [15,] 0.9051390 > > [16,] 0.8559267 > > [17,] 0.7769472 > > [18,] 0.6423128 > > [19,] 0.9629361 > > [20,] 0.9521001 > > [21,] 0.9382259 > > [22,] 0.9201104 > > [23,] 0.8958341 > > [24,] 0.8622051 > > [25,] 0.8136275 > > [26,] 0.7395534 > > [27,] 0.6175830 > > [28,] 0.9246320 > > [29,] 0.9127580 > > [30,] 0.8982795 > > [31,] 0.8800821 > > [32,] 0.8564152 > > [33,] 0.8244048 > > [34,] 0.7790512 > > [35,] 0.7109198 > > [36,] 0.5996181 > > [37,] 0.8767646 > > [38,] 0.8671159 > > [39,] 0.8550329 > > [40,] 0.8394499 > > [41,] 0.8187308 > > [42,] 0.7902253 > > [43,] 0.7493487 > > [44,] 0.6874269 > > [45,] 0.5854263 > > [46,] 0.8215803 > > [47,] 0.8170930 > > [48,] 0.8098560 > > [49,] 0.7988930 > > [50,] 0.7827045 > > [51,] 0.7588540 > > [52,] 0.7231046 > > [53,] 0.6673758 > > [54,] 0.5736597 > > [55,] 0.7611968 > > [56,] 0.7642511 > > [57,] 0.7637415 > > [58,] 0.7588504 > > [59,] 0.7482636 > > [60,] 0.7297788 > > [61,] 0.6994875 > > [62,] 0.6498159 > > [63,] 0.5635906 > > [64,] 0.6975913 > > [65,] 0.7098972 > > [66,] 0.7174446 > > [67,] 0.7196221 > > [68,] 0.7153381 > > [69,] 0.7026455 > > [70,] 0.6779572 > > [71,] 0.6341555 > > [72,] 0.5547793 > > [73,] 0.6325678 > > [74,] 0.6551296 > > [75,] 0.6715521 > > [76,] 0.6814181 > > [77,] 0.6838614 > > [78,] 0.6771931 > > [79,] 0.6581383 > > [80,] 0.6199984 > > [81,] 0.5469392 > > [82,] 0.5677232 > > [83,] 0.6008650 > > [84,] 0.6265229 > > [85,] 0.6443861 > > [86,] 0.6537698 > > [87,] 0.6532207 > > [88,] 0.6397566 > > [89,] 0.6070646 > > [90,] 0.5398727 > > [91,] 0.5044222 > > [92,] 0.5478565 > > [93,] 0.5827146 > > [94,] 0.6086282 > > [95,] 0.6250023 > > [96,] 0.6305684 > > [97,] 0.6226043 > > [98,] 0.5951486 > > [99,] 0.5334377 > > [100,] 0.4437834 > > [101,] 0.4967086 > > [102,] 0.5404019 > > [103,] 0.5742126 > > [104,] 0.5975006 > > [105,] 0.6091056 > > [106,] 0.6065193 > > [107,] 0.5840942 > > [108,] 0.5275280 > > [109,] 0.3866770 > > [110,] 0.4478912 > > [111,] 0.4997913 > >> length(R) > > [1] 111 > > > > Anan Halabi > > Reliability Eng, R&D > > HP Scitex > > Tel: 972-9-8924648 > > mobil: 972-52-6624231 > > > > > > [[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. > > David Winsemius, MD > West Hartford, CT > > ______________________________________________ > 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. ______________________________________________ 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.