0

I have a question about an R Markdown file. I want to convert a JSON file into a data frame, and I use the following code:

```{r}
install.packages("jsonlite")
library(rjson)
install.packages("rjson")
library(jsonlite)
```

```{r}
dfjson <- fromJSON(file= "/Users/sarah/JSON/fhir_dstu2/Aaron697_Stiedemann542_41166989-975d-4d17-b9de-17f94cb3eec1.json")
dfjson
str(dfjson)
```

```{r}
print(dfjson)
```

The problem is that as soon as I run the second chunk, I get the error message:

Error in fromJSON(file = "/Users/sarah/JSON/fhir_dstu2/Aaron697_Stiedemann542_41166989-975d-4d17-b9de-17f94cb3eec1.json") : 
  Argument "txt" is missing (without default value)

I don't understand what could be wrong. Do you guys have a solution for me?

Thanks already

shafee
  • 15,566
  • 3
  • 19
  • 47
  • I think your function call should be `fromJSON(txt = "/Users/sarah/JSON/fhir_dstu2/Aaron697_Stiedemann542_41166989-975d-4d17-b9de-17f94cb3eec1.json")` - i.e., replace `file` with `txt` – SymbolixAU Sep 19 '22 at 23:06

1 Answers1

0

Yes agree SymbolixAU's reply. Change 'file=' to 'tet=' and then it will automatically show the data as a dataframe.