MATLAB: Grpstats for several variables

biostatisticsstatistics

Hello everybody,
i have values for Sodium, creatinine and many more variables for patients. I need to calculate mean median values of them. Should i use everytime mean(ds.Sodium) or is there a easier way to do that ? i ve been trying to use grpstats function i couldnt make it work. if someone would explain me i would be very happy. thank you

Best Answer

Have a look at the list of statistics that are accepted as character vectors. Note that 'median' is not one of the options.
Instead, you'll need to use a function handle to list 'median' as a stat.
stat1 = grpstats(ds, {'Sodyum', 'AST'} , {'mean', @median});
That fixes any syntax issues. If problesm persist, please describe the problem in detail and share the result of the following line (assuming ds is a table which appears to be the case).
head(ds) % if ds is a table