You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查看R包adehabitat中widesII输出的个体选择比率表格?

Extracting Individual Selection Ratios from widesII() in adehabitat

Hey there! I’ve run into this exact situation before with adehabitat’s widesII() function—great catch that the default output only shows global averages, even though the plot function clearly uses individual-level data. Here’s how you can pull those individual selection ratios into a usable table:

  1. Save the widesII() output to a variable
    First, make sure you store the result of your widesII() call instead of just running it directly. For example:

    # Replace with your actual data and parameters
    my_selection <- widesII(used = my_used_data, available = my_available_data, ...)
    
  2. Dig into the object’s structure
    The widesII() output is a list that holds more data than it prints by default. Run str(my_selection) to see all components—you’ll notice a section called $reluse; this is where the individual selection ratios live.

  3. Extract the individual ratios as a table
    You can directly pull this component and convert it to a data frame for easy viewing:

    # Get the individual selection ratios matrix
    individual_ratios_matrix <- my_selection$reluse
    # Convert to a data frame for cleaner formatting
    individual_ratios_df <- as.data.frame(individual_ratios_matrix)
    

    This data frame will have resources as rows and individual animals as columns, with each cell holding the selection ratio for that individual-resource pair.

  4. Optional: Reshape for readability
    If you prefer a long-format table (one row per individual-resource combination), use the tidyr package to pivot it:

    library(tidyr)
    long_ratios <- pivot_longer(
      individual_ratios_df,
      cols = everything(),
      names_to = "Individual_ID",
      values_to = "Selection_Ratio"
    )
    # Add resource names as a column
    long_ratios$Resource <- rownames(individual_ratios_df)
    

The plot function you’re using under the hood is accessing this same $reluse component to generate individual line graphs, so this gives you the exact numerical values behind those plots.

内容的提问来源于stack exchange,提问作者user9447153

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:19:22