Dear All,
I have a function that it works in all of data.

dim(data)
24(sample)   2600(variable)
data


          [1]        [2]         [3]       [4]  ...   [2600]

[1] 10.73140 9.89450 9.12233 8.33994 9.43412 [2] 10.58010 10.02023 8.69257
8.46640 9.05038 [3] 10.80644 9.59991 8.71311 8.64168 9.08396 [4] 10.85874
9.16161 9.27786 9.10818 9.70617 [5] 10.89607 10.02847 8.81274 8.77573
9.12501

...
[24]  10.71652   9.71979     9.23088   8.87465   9.49099

Now I want that the function works on 100 subgroups of data.

I determined this subgroups by subgroup matrix

dim(subgroup)

100(subgroup)  2600(variable)

Subgroup

         [1]     [2]      [3]    [4]... [2600]
[1]       1      0         0       0         0
[2]       1      0         0       0         0
[3]       1      0         0       0         0
[4]       0      1         0       0         0
[5]       0      0         1       0         0
...
[100]     0      0         1       0         0



the elements of subgroup are 1 ( show us the variable belongs the subgroup)
or 0 (show us the variable does not belong the subgroup)



result <- apply(subgroup , 1, function(z) func_LL(data[which(z==1),]))

but I saw this error

Error in ncol(data) : subscript out of bounds
while our dimensions are correct, I think:(
Thanks a lot for your guide.

Best Regards,
Soheila

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