restructure data table based on date and other categorical variables

1 次查看(过去 30 天)
I have a data table with 4 variables: d18O (water chemistry measurement), Site, Date and Depth
Site, Date and Depth are all categorical. d18O is the data.
I'm wondering if there is an efficient way to compare d18O collected from the same site, on the same date, at DIFFERENT depths. Some dates do not include d18O collected from multiple depths at the same site, but many do.
I'm completely at a loss of how to code this. I've been doing it manually in excel, but my actual dataset is much larger than what I've attached here and it's extremely inefficient.
Any ideas greatly appreciated.

采纳的回答

Voss
Voss 2023-10-24
T = readtable('data_test.csv')
T = 113×4 table
d18O Site Date Depth ______ ____ _____ _____ -11.57 1004 43773 20 -12.63 1004 43773 80 -12.8 1004 43802 20 -13.01 1004 43802 80 -13.9 1004 43838 20 -13.11 1004 43838 80 -13.99 1004 43865 20 -12.97 1004 43865 80 -13.98 1004 43899 20 -12.94 1004 43899 80 -13.29 1004 43927 20 -13.11 1004 43927 80 -12.87 1004 43959 20 -12.99 1004 43959 80 -11.84 1004 43984 20 -11.59 1004 43984 20
T_summary = groupsummary(T,{'Site','Date'},@(x){x},{'d18O','Depth'});
T_summary = removevars(T_summary,'GroupCount');
T_summary = renamevars(T_summary,{'fun1_d18O','fun1_Depth'},{'d18O','Depth'})
T_summary = 64×4 table
Site Date d18O Depth ____ _____ ____________ ____________ 1004 43773 {2×1 double} {2×1 double} 1004 43802 {2×1 double} {2×1 double} 1004 43838 {2×1 double} {2×1 double} 1004 43865 {2×1 double} {2×1 double} 1004 43899 {2×1 double} {2×1 double} 1004 43927 {2×1 double} {2×1 double} 1004 43959 {2×1 double} {2×1 double} 1004 43984 {3×1 double} {3×1 double} 1004 44018 {2×1 double} {2×1 double} 1004 44075 {2×1 double} {2×1 double} 1004 44102 {[-11.5600]} {[ 20]} 1004 44144 {2×1 double} {2×1 double} 1004 44166 {2×1 double} {2×1 double} 1004 44204 {2×1 double} {2×1 double} 1004 44235 {2×1 double} {2×1 double} 1004 44263 {2×1 double} {2×1 double}

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by