I got this data:
> str(gaDataExt)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 2 obs. of 5 variables:
$ date : POSIXct, format: "2016-05-24" "2016-05-31"
$ deviceCategory: chr "desktop" "desktop"
$ users : int 1 2
$ sessions : int 1 2
$ pageviews : int 11 85
- attr(*, "profileInfo")=List of 6
..$ profileId : chr "25439551"
..$ accountId : chr "12543305"
..$ webPropertyId : chr "UA-12543305-1"
..$ internalWebPropertyId: chr "26790206"
..$ profileName : chr "www.ciao.ch"
..$ tableId : chr "ga:25439551"
- attr(*, "query")=List of 8
..$ start.date : chr "30daysAgo"
..$ end.date : chr "yesterday"
..$ profileId : chr "ga:25439551"
..$ dimensions : chr "ga:date,ga:deviceCategory"
..$ metrics : chr "ga:users" "ga:sessions" "ga:pageviews"
..$ segment : chr "sessions::condition::ga:pagePath=@/f /relations /questions_reponses-best_of/;sessions::condition::ga:pagePath=@/f/manger-bouger/q"| __truncated__
..$ start.index: int 1
..$ max.results: int 10000
- attr(*, "sampled")= logi FALSE
I want to make a plot with ggplot2 but i cant access the data in $segment ? Is it possible to convert into dataframe ?
frame() function in R Programming Language is used to convert an object to data frame.
The tbl_df class is a subclass of data. frame , created in order to have different default behaviour. The colloquial term "tibble" refers to a data frame that has the tbl_df class. Tibble is the central data structure for the set of packages known as the tidyverse, including dplyr, ggplot2, tidyr, and readr.
Tibbles vs data frames There are two main differences in the usage of a data frame vs a tibble: printing, and subsetting. Tibbles have a refined print method that shows only the first 10 rows, and all the columns that fit on screen. This makes it much easier to work with large data.
tbl_df object is a data frame providing a nicer printing method, useful when working with large data sets. In this article, we'll present the tibble R package, developed by Hadley Wickham. The tibble R package provides easy to use functions for creating tibbles, which is a modern rethinking of data frames.
df = as.data.frame(gaDataExt)
Simple as that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With