Aliases: flatten
Keywords:
### ** Examples options(stringsAsFactors=FALSE) x <- data.frame(driver = c("Bowser", "Peach"), occupation = c("Koopa", "Princess")) x$vehicle <- data.frame(model = c("Piranha Prowler", "Royal Racer")) x$vehicle$stats <- data.frame(speed = c(55, 34), weight = c(67, 24), drift = c(35, 32)) str(x)
'data.frame': 2 obs. of 3 variables: $ driver : chr "Bowser" "Peach" $ occupation: chr "Koopa" "Princess" $ vehicle :'data.frame': 2 obs. of 2 variables: ..$ model: chr "Piranha Prowler" "Royal Racer" ..$ stats:'data.frame': 2 obs. of 3 variables: .. ..$ speed : num 55 34 .. ..$ weight: num 67 24 .. ..$ drift : num 35 32
str(flatten(x))
'data.frame': 2 obs. of 6 variables: $ driver : chr "Bowser" "Peach" $ occupation : chr "Koopa" "Princess" $ vehicle.model : chr "Piranha Prowler" "Royal Racer" $ vehicle.stats.speed : num 55 34 $ vehicle.stats.weight: num 67 24 $ vehicle.stats.drift : num 35 32
str(flatten(x, recursive = FALSE))
'data.frame': 2 obs. of 4 variables: $ driver : chr "Bowser" "Peach" $ occupation : chr "Koopa" "Princess" $ vehicle.model: chr "Piranha Prowler" "Royal Racer" $ vehicle.stats:'data.frame': 2 obs. of 3 variables: ..$ speed : num 55 34 ..$ weight: num 67 24 ..$ drift : num 35 32
## Not run: ##D data1 <- fromJSON("https://api.github.com/users/hadley/repos") ##D colnames(data1) ##D colnames(data1$owner) ##D colnames(flatten(data1)) ##D ##D # or for short: ##D data2 <- fromJSON("https://api.github.com/users/hadley/repos", flatten = TRUE) ##D colnames(data2) ## End(Not run)