Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R: Get function with magick image #356

Open
Pablo-Erazo opened this issue Aug 16, 2022 · 0 comments
Open

R: Get function with magick image #356

Pablo-Erazo opened this issue Aug 16, 2022 · 0 comments

Comments

@Pablo-Erazo
Copy link

I've been trying to develop an R code that allows to extract the different parts of an agarose gel corresponding to different samples. For this I've tried to dynamically export the differente cropped images using loop (for) function in this way:

for (i in 1:length(get("project"))) {
image_write(get( "gel_",project[i] ), paste0("gel_", project[i] ,".jpg"),format = "jpg")
}
where variable:

  • project: contains the names of the projects. Ex.: UCE, ESPE, ST1
  • get("gel_",project[i]): calls for the cropped images. Ex.: variable named "gel_UCE" is an External pointer of class "magick-image"
  • paste0("gel_",project[i],".jpg"): generates the name of the cropped image for each project Ex.: for gel_UCE image creates names "gel_UCE.jpg"

Running this line independently works fine. However, I've been trying to create a function to run the code in one line. When I run the complete function (which includes the line I've shown), this error ocurrs.

image

It seems that the function "image_write" doesn't work when I try to dinamically export the images, by generating the variables with the get function. Is there a way to overcome this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant