-6

I have a simple data set (lets just call it data) containing 100 values and i wish to call them one at a time for entry into an equation (i cant post this particular equation here).

The problem im having is that from the equation there needs to be two outputs (probability), and when i call the data set directly, it does not give the desired output. Entering the numbers manually from the dataset gives the correct output (checked manually).

There are two streams of input as evidenced by the two outputs, is there something simple im missing regarding the input of a simple dataset?

EDIT the dataset which just a sample of 100 numbers needs to be entered in the equation i have. another value is to be subtracted from each entry in the dataset so unfortunately the solution below wont work.

the equation has two main sets of information feeding it in the form of two means, and other global parameters. From this, two prob values are calculated, one for each option.

However linking the above 100 value matrix results in 100 values being created which make no sense anyway. Putting in the first value manually from the matrix into the equation results in the correct output - 2 values (checked by hand)

Thanks

4

1 回答 1

2

如果您有一个包含 100 个值的向量和一个为每次调用返回两个值的函数,那么这应该可以工作:

res <- sapply( vec, f) 

您应该得到一个列表或两列矩阵,具体取决于f-function 为您提供的返回对象的类型。

于 2012-07-31T22:34:37.920 回答