Skip to content

Instantly share code, notes, and snippets.

@nareshjois
Last active February 7, 2018 13:40
Show Gist options
  • Save nareshjois/6adfda5a3b3bd7cc504d60f5dd5e0261 to your computer and use it in GitHub Desktop.
Save nareshjois/6adfda5a3b3bd7cc504d60f5dd5e0261 to your computer and use it in GitHub Desktop.
R Expression representation of JSON

For a Given Input

rnorm(c(10,20,30), 10, sd = 1)

The Output

{
    "errors": null, // In [{ line: number, column: number, message: string }]
    "tree": [
        {
            "func": {
                "value": "rnorm",
                "position": 0
            },
            "params": [
                {
                    "name": null,
                    "value": {
                        "func": {
                            "value": "c",
                            "position": 6
                        },
                        "params": [
                            {
                                "name": "",
                                "value": "10",
                                "position": 8
                            },
                            {
                                "name": "",
                                "value": "20",
                                "position": 11
                            },
                            {
                                "name": "",
                                "value": "30",
                                "position": 14
                            }
                        ]
                    }
                },
                {
                    "name": "",
                    "value": "10",
                    "position": 19
                },
                {
                    "name": "sd",
                    "value": "1",
                    "position": 23
                }
            ]
        }
    ]
}    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment