http_interactions:
- request:
    method: POST
    uri: https://api.anthropic.com/v1/messages
    body:
      string: '{"model":"claude-sonnet-4-5-20250929","messages":[{"role":"user","content":[{"type":"text","text":"\n  How
        can I compute the mean and median of variables a, b, c, and so on,\n  all
        the way up to z, grouped by age and sex.\n","cache_control":{"type":"ephemeral","ttl":"5m"}}]}],"stream":false,"max_tokens":4096}'
  response:
    status: 200
    headers:
      date: Thu, 06 Nov 2025 14:54:59 GMT
      content-type: application/json
      content-encoding: gzip
      anthropic-ratelimit-input-tokens-limit: '2000000'
      anthropic-ratelimit-input-tokens-remaining: '2000000'
      anthropic-ratelimit-input-tokens-reset: '2025-11-06T14:54:52Z'
      anthropic-ratelimit-output-tokens-limit: '400000'
      anthropic-ratelimit-output-tokens-remaining: '400000'
      anthropic-ratelimit-output-tokens-reset: '2025-11-06T14:54:59Z'
      anthropic-ratelimit-requests-limit: '4000'
      anthropic-ratelimit-requests-remaining: '3999'
      anthropic-ratelimit-requests-reset: '2025-11-06T14:54:50Z'
      retry-after: '8'
      anthropic-ratelimit-tokens-limit: '2400000'
      anthropic-ratelimit-tokens-remaining: '2400000'
      anthropic-ratelimit-tokens-reset: '2025-11-06T14:54:52Z'
      request-id: req_011CUrpzetVwdfDV6e7A456d
      strict-transport-security: max-age=31536000; includeSubDomains; preload
      anthropic-organization-id: bf3687d8-1b59-41eb-9761-a1fd70b24e7e
      x-envoy-upstream-service-time: '8374'
      cf-cache-status: DYNAMIC
      x-robots-tag: none
      server: cloudflare
      cf-ray: 99a56dafbfe3c0c0-DFW
    body:
      string: '{"model":"claude-sonnet-4-5-20250929","id":"msg_01QXJgFPo2Zgm2Mmbdqw7Bmk","type":"message","role":"assistant","content":[{"type":"text","text":"#
        Computing Mean and Median by Groups\n\nHere are several approaches depending
        on your tool:\n\n## **R (tidyverse)**\n```r\nlibrary(dplyr)\n\ndf %>%\n  group_by(age,
        sex) %>%\n  summarise(across(a:z, \n                   list(mean = ~mean(.,
        na.rm = TRUE),\n                        median = ~median(., na.rm = TRUE)),\n                   .names
        = \"{.col}_{.fn}\"))\n```\n\n## **Python (pandas)**\n```python\nimport pandas
        as pd\n\ndf.groupby([''age'', ''sex'']).agg(\n    {col: [''mean'', ''median'']
        for col in df.columns if col not in [''age'', ''sex'']}\n)\n```\n\nOr more
        explicitly for columns a-z:\n```python\ncols = [chr(i) for i in range(ord(''a''),
        ord(''z'')+1)]\ndf.groupby([''age'', ''sex''])[cols].agg([''mean'', ''median''])\n```\n\n##
        **SQL**\n```sql\nSELECT \n  age, \n  sex,\n  AVG(a) as a_mean, PERCENTILE_CONT(0.5)
        WITHIN GROUP (ORDER BY a) as a_median,\n  AVG(b) as b_mean, PERCENTILE_CONT(0.5)
        WITHIN GROUP (ORDER BY b) as b_median,\n  -- ... repeat for c through z\nFROM
        table\nGROUP BY age, sex\n```\n\n## **Base R**\n```r\naggregate(. ~ age +
        sex, \n          data = df, \n          FUN = function(x) c(mean = mean(x,
        na.rm = TRUE), \n                              median = median(x, na.rm =
        TRUE)))\n```\n\nWhich approach works best for you depends on your data format
        and preferred language!"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":45,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":440,"service_tier":"standard"}}'
  recorded_at: 2025-11-06 14:54:59
recorded_with: VCR-vcr/2.0.0
