[R] How to loop over two files ...

Ivan Krylov
Sat, 20 Jun 2020 08:47:53 -0000

On Fri, 19 Jun 2020 19:36:41 -0500
Ana Marija <sokovic.anamarija at gmail.com> wrote:

> Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1),
> "\n"),  : argument 1 (type 'list') cannot be handled by
'cat'

It might be a good idea to try to solve problems like this yourself
instead of waiting for hours for someone to reply. All the required
information is there in the error message: write() fails because r is a
list. Why is r a list? It's returned from GET(), so let's read its
documentation.

httr::GET() returns a response object, not a string [1]. Try passing
as.character(r) or content(r,'text') instead of just r to write(...) or
use a different way of extracting the actual response from the response
object.

--
Best regards,
Ivan

[1] https://httr.r-lib.org/reference/GET.html