Spotfire Support 2 Posted August 11, 2020 Share Posted August 11, 2020 I'm trying to use a document property to control whichcolumnfrom a data table is used as the first argument for the "aggregate" function, but am unsuccessful doing so. The script is workingfine when I use the actual column names, but when I attempt to use the document property as column name, the function returns "no rows to aggregate". Examples below. Successful script: aggregate(Table$Column1, by = list(Table$Column2), FUN = median, na.rm = TRUE) Unsuccessful script: aggregate(Table$DocProperty, by = list(Table$Column2), FUN = median, na.rm = TRUE) DocProperty is a string and currently holds the value "Column1". Link to comment Share on other sites More sharing options...
Fabian Duerr Posted August 11, 2020 Share Posted August 11, 2020 Follow this approach using dplyr library(dplyr) testdf Link to comment Share on other sites More sharing options...
Spotfire Support 2 Posted August 14, 2020 Author Share Posted August 14, 2020 Perfect, your suggestion to use dplyr with group_by and summarise worked perfectly. Thank you very much for the help! Link to comment Share on other sites More sharing options...
Fabian Duerr Posted August 14, 2020 Share Posted August 14, 2020 Thank you for the feedback! If you want to learn more about data manipulation in R (with dplyr) I can highly recommend this book/ebook: Data Manipulation in R by Stephanie Locke/ https://itsalocke.com/files/DataManipulationinR.pdf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now