pixey
pixey

Reputation: 53

How to dynamically name jpeg filenames in R

Suppose i have n records for which i am trying to generate n images I am trying to give the file name as follows.

jpeg(file="/home/ttt...../percpackup"+str(i)+".jpeg")

Here 'i' runs from 1 to n . I am getting an error message as:

Error in "/home/ttt...../percpackup" +  :
  non-numeric argument to binary operator
Calls: jpeg -> checkIntFormat -> gsub
Execution halted

Upvotes: 1

Views: 106

Answers (1)

Virag Swami
Virag Swami

Reputation: 197

You can do something like :

(sapply(1:n , function(i){jpeg(paste0("/home/ttt...../percpackup", i, ".jpeg"))}))

Upvotes: 2

Related Questions