0

I have this code in Gauss.

if prodc((lowerlb2[.,2] .le thxseq[.,2]).*(thxseq[.,2] .le upperlb2[.,2]))==1; count_bb[2,2] = count_bb[2,2] 1; endif;

Any help for executing this particular statement in R will be appreciated.

Shreya
  • 159
  • 1
  • 9
  • What have you tried so far and why didn't it work? Please provide some input data and the expected output based on that input data. – Limey Mar 16 '22 at 10:28
  • Well, I am very new to R and zero knowledge in Gauss as well, for the time being I tried to replace prodc with apply(m,1, prod) which essentially returns the product of all the elements in each column. But it doesn't work. – Shreya Mar 16 '22 at 10:32

1 Answers1

0

I do not have access to your data e.g. lowerlb2, but this is how to do the example in the documentation in R:

In Gauss:

x = { 1 2 3,
      4 5 6,
      7 8 9 };

y = prodc(x);

     28
y =  80
    162

In R:

library(tidyverse)

data <- tribble(
  ~a, ~b, ~c,
  1, 2, 3,
  4, 5, 6,
  7, 8, 9
)

lapply(data, prod)
#> $a
#> [1] 28
#> 
#> $b
#> [1] 80
#> 
#> $c
#> [1] 162

Note that lapply instead of apply is used.

There is a free book at https://r4ds.had.co.nz/ to learn data analysis in R using the tidyverse.

danlooo
  • 10,067
  • 2
  • 8
  • 22