[R] Dynamic Creation and Use of Object Names

Dr Eberhard Lisse
Mon, 23 Aug 2021 06:37:54 -0000

Hi,

I have a function PICTURE() and do something like

	COUNTRY = 'Namibia'
	NAKURVE = PICTURE(COUNTRY)
	NAKURVE
	ggsave(paste0(tolower(COUNTRY),".png"), width = 16, height = 9)

	COUNTRY = ('Germany')
	DEKURVE = PICTURE(COUNTRY)
	DEKURVE
	ggsave(paste0(tolower(COUNTRY),".png"), width = 16, height = 9)

	COUNTRY = ('Netherlands')
	NLKURVE = PICTURE(COUNTRY)
	NLKURVE
	ggsave(paste0(tolower(COUNTRY),".png"), width = 16, height = 9)

[...]

	COUNTRYGRID=grid.arrange(NAKURVE, DEKURVE, NLKURVE,
				 ncol=3)
	COUNTRYGRID
	ggsave(paste0("R7.incidence.", Sys.Date(), ".png"),
COUNTRYGRID)

I am not able to figure out (and/or find on Google) how to do this in a
loop (of sorts), ie create the variables dynamically and add them to to
the grid (dynamically, ie adding more countries)

Any ideas?

greetings, el
--
To email me replace 'nospam' with 'el'