Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Classes ‘tbl_df’, ‘tbl’ and 'data.frame into dataframe with R

Tags:

r

dplyr

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 ?

like image 795
r tremeaud Avatar asked Jun 02 '16 14:06

r tremeaud


People also ask

How do I convert data into a Dataframe in R?

frame() function in R Programming Language is used to convert an object to data frame.

What is TBL class in R?

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.

What is the difference between Tibble and Dataframe in R?

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.

What does Tbl_df do in R?

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.


1 Answers

df = as.data.frame(gaDataExt)

Simple as that.

like image 86
Rnoob Avatar answered Sep 30 '22 10:09

Rnoob