Hello. My question is in the subject line. Using R 4.1.3 on Windows 10. Commented MWE below. Thanks.
--Chris Ryan library(dplyr) library(lattice) ## fabricate a dataframe dd <- data.frame(agency = sample(LETTERS, size = 5), total = sample(100:200, size = 5), las = sample(20:40, size = 5)) dd <- dd %>% mutate(proportion = las/total, bubble = total/100) ## attempt to make a dotplot with symbol size proportional ## to the variable named total dotplot(agency ~ proportion, pch = 16, cex = bubble, data = dd) ## object 'bubble' not found dotplot(agency ~ proportion, pch = 16, cex = dd$bubble, data = dd) ## works ## also works in two commands external.bubble <- dd$bubble dotplot(agency ~ proportion, pch = 16, cex = external.bubble, data = dd) ## but how to chain it with pipes, dplyr-style, ## modifying the dataframe and then ## using the modified version in dotplot, all in one chain? dd %>% mutate(new.proportion = las/total, new.bubble = total/100) %>% dotplot(agency ~ new.proportion, pch = 16, cex = new.bubble, data = .) ## object 'new.bubble' not found dd %>% mutate(new.proportion = las/total, new.bubble = total/100) %>% dotplot(agency ~ new.proportion, pch = 16, cex = .$new.bubble, data = .) ## the .$new.bubble syntax seems to work, but I've never ## used or seen that before, and it seems weird. ## Is there a "proper" syntax? [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.