![]() ![]() Then you can unnest or manipulate list columns. One column quantile containing a list, the result of quantile(., probs=quant). Another solution is to work with list column. #> "lin_acc_mag_probs0" "vel_ang_unc_mag_probs0" #> "lin_acc_mag_median" "vel_ang_unc_mag_median" filter () picks cases based on their values. select () picks variables based on their names. #> "lin_acc_mag_max" "vel_ang_unc_mag_max" mutate () adds new variables that are functions of existing variables. # Apply these function in funs usint splicing.įuns(min, max, mean, median, sd, !!!lqfun)) Here is how to do it: # generate a vector with quantile probs you want (here 50) Apply these functions by splicing the list.Staying in the tidyverse, a solution is to use tidyeval. If you want lots of probabilities for quantile, you may not want to write everything by hand. #> # lin_acc_mag_quantile, vel_ang_unc_mag_quantile Ĭreated on by the reprex package (v0.2.1) #> # gra_x_quantile, gra_y_quantile, gra_z_quantile , #> # gra_z_sd, lin_acc_mag_sd, vel_ang_unc_mag_sd , ![]() #> # vel_ang_unc_mag_median, gra_x_sd, gra_y_sd , #> # vel_ang_unc_mag_mean, gra_x_median, gra_y_median , #> # gra_y_mean, gra_z_mean, lin_acc_mag_mean , #> # lin_acc_mag_max, vel_ang_unc_mag_max, gra_x_mean , with 24 more variables: gra_y_max, gra_z_max , ![]() #> gra_x_min gra_y_min gra_z_min lin_acc_mag_min vel_ang_unc_mag~ gra_x_max library(tidyverse)įuns(min, max, mean, median, sd, quantile(.,probs = c(0.25)), quantile(., probs = 0.75))) This is working if you separate the call the quantile for each probs as it expects a result of length one. Summarize_at(vars(gra_x, gra_y, gra_z, lin_acc_mag, vel_ang_unc_mag),įuns(min, max, mean, median, sd, quantile, probs = c(0.25, 0.75)))Įrror in summarise_impl(.data, dots) : Column gra_x_quantile must be Here is my sample df, please advise how to do this: df % I have 5 variables in my df, I want to summarize_at them using the following pattern for each variable: min, quantile(.25), median, mean, qunatile(.75), max, sd ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |