Convert raw data to char format
To convert raw data in char format we need to use rawToChar() and pass variable_name$content in it just like we did in this example.
# installing packages
install.packages("httr")
# importing packages
library(httr)
# GET() method will store the raw
# data in r variable
r < - GET("https://w3wiki.org")
# rawToChar() will convert raw data
# to char and store in response variable
response < - rawToChar(r$content)
# print response
print(response)
Output:
How to Make HTTP request using httr package in R Language
In this article, we will learn how to make an HTTP request using the GET method in R Programming Language with httr library.
We will be covering basic steps to get you started by making HTTP requests and scrapping all the data from a site in a simple way. You can also use it to scrape data from any website and use it to access API and much more. HTTP requests might be complicated but R language syntax makes it much easier in comparison with other languages.