"""Send a small table to R via RInterpreter and read it back."""

import emzed

with emzed.r.RInterpreter(do_log=False) as rip:
    print()

    rip.mz0 = 100
    rip.execute(
        """
        tab <- data.frame(
            mz = c(mz0, 2*mz0, 3*mz0),
            intensity = c(1000, 1500, 1300)
        )
        print(tab)

        other_var <- 17
        mz0 <- mz0 + 1
        """
    )
    mz0 = rip.mz0
    other_var = rip.other_var
    print(f"mz0 from R: {mz0}")
    print(f"other_var from R: {other_var}")
    print()
    table = rip.get_df_as_table("tab")
    print(table)
