lanselibai
lanselibai

Reputation: 1273

Why "image_read_svg" could not work in R?

I think I followed correctly from here. But why I got the error?

> library(magick)
Warning message:
package ‘magick’ was built under R version 3.2.5 
> tiger <- image_read_svg('http://jeroen.github.io/images/tiger.svg', width = 400)
Error: could not find function "image_read_svg"

The version of magick is 0.4, how to install a newer version? I tried install.packages("magick") but it is still 0.4

> packageVersion("magick")
[1] ‘0.4’

Upvotes: 2

Views: 2104

Answers (2)

Tania
Tania

Reputation: 166

I had an error with this function in magick version 2.2. Not same exact, but related enough that this may be useful:

Error in loadNamespace(name) : there is no package called ‘rsvg’

My error is due to R package rsvg not being installed automatically during my installation of magick. This may be your problem also. Installing it manually made function magick::image_read_svg work.

install.packages("rsvg")
library(rsvg)
library(magick)
tiger <- image_read_svg('http://jeroen.github.io/images/tiger.svg', width = 400)
print(tiger)

You should see a tiger image.

Upvotes: 3

user3603486
user3603486

Reputation:

Maybe your version of magick does not have that function. We can check using apicheck (my own package, available on github).

library(apicheck)
when_fun_exists("magick::image_read_svg") # this will take some time...

But I am showing off. We could also just check the NEWS file on CRAN:

1.8

  • Export image_read_svg() and image_read_pdf()

Bet your version is before 1.8. You can check using packageVersion.

Upvotes: 1

Related Questions