Home > Enterprise >  Print output of a table in R-Viewer
Print output of a table in R-Viewer

Time:11-03

I want to print out a specific value or cell of a table and want to display it in the viewer. The cell contains a image. I tried some packages like plot but cant get the image printed out in the viewer. Although i can print it out in the console. I need a package which supports the print out in the viewer. Do you have any suggestions?

CodePudding user response:

I think you should be able to use the "magick" package for this like so:

install.packages("magick")
library(magick)

icon_OK <- image_read("PathToSomeImage")
icon_NOK <- image_read("PathToSomeImage")

result1$ICON <- if(result1$TREND>0)icon_OK 
if(result1$TREND<0) icon_NOK

To print the image you stored in the ICON column on the first row can be printed in the viewer as follows:

print(result1[1,2])

If you get an error when loading the package regarding the 'Rcpp' package, then reinstall it as follows:

install.packages("Rcpp")

It should be noted that you can no longer print/view the dataframe as a whole because there are now pictures in the dataframe. Therefore, you can only inspect individual elements as far as I know.

  • Related