如何查看R包adehabitat中widesII输出的个体选择比率表格?
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:
Save the
widesII()output to a variable
First, make sure you store the result of yourwidesII()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, ...)Dig into the object’s structure
ThewidesII()output is a list that holds more data than it prints by default. Runstr(my_selection)to see all components—you’ll notice a section called$reluse; this is where the individual selection ratios live.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.
Optional: Reshape for readability
If you prefer a long-format table (one row per individual-resource combination), use thetidyrpackage 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

