appendData: append new data to data list

Description Usage Arguments Value Examples

View source: R/appendData.R

Description

This function allows to create, append data to be passed to the https://github.com/npellet/visualizer. Prior to this, the list have to be parsed and stored as a json file. This file can be either stored locally or stored on https://gist.github.com.

Usage

1
appendData(data, variable, variableName, type)

Arguments

data

data, if it exists

variable

new dataset

variableName

name of the dataset. The name of the data must be exposed to the https://github.com/npellet/visualizer using the exposeData.R function.

type

type of the data. The types currently supported are

  • "1D Y array"

  • "1D XY array"

  • "table"

  • "chart"

  • "multiChart"

  • "score"

  • "color"

Value

a list object with the data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
x <- seq(from = 0, to = pi, by = 0.1)

#simple array
d <- appendData(variableName = "simpleArray", variable = cos(x), type = "1D Y array")
d <- appendData(data = d, variableName = "simpleArray2", variable = sin(x), type = "1D Y array")

#XY array
xy = data.frame( x = x, y = sin(x) )
d <- appendData(data = d, variableName = "simpleArray3", variable = xy, type = "1D XY array")

#chart
chart <- data.frame("x" = x,
                    "y" = cos(3*x),
                    "highlight" = seq_along(x) - 1,
                    "info"= paste0("ID: ", 0:31)
                    )

d <- appendData(data = d, variableName = "chart", variable = chart, type = "chart")

opts = list(
"trackMouseLabelRouding" = 1,
"trackMouse" = "false",
"lineToZero" = "false",
"trackMouseLabel" = "false",
"lineColor" = "red",
"autoPeakPickingNb" = 4,
"markers" = list(
  "fillColor" = "transparent",
  "zoom" = 1,
  "show" = "false",
  "type" = 1,
  "strokeColor" = "false",
  "strokeWidth" = 1
),
"lineStyle" = 1,
"autoPeakPickingMinDistance" = 10,
"label" = "",
"autoPeakPicking" = "false",
"flip" = "false"
)

chart1 <- data.frame("x" = x,
                     "y" = cos(3*x),
                     "highlight" = seq_along(x) - 1,
                     "info"= paste0("cosID: ", 0:31)
                     )

chart2 <- data.frame("x" = x,
                     "y" = sin(3*x),
                     "highlight" = seq_along(x) - 1,
                     "info"= paste0("sinID: ", 0:31)
                     )

chart = list( list(chart=chart1, options=opts), list(chart=chart2, options=opts))
d <- appendData( data = d, variableName = "multiChart", variable = chart, type = "multiChart")

#saveJSON(d, "~/", "data.json")
v <- new('visualization')
push(v, 'data', d)
#visualize(v)

jwist/visualizeR documentation built on Dec. 1, 2019, 5:11 p.m.