Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:17:05+00:00 2026-06-06T21:17:05+00:00

I am trying to create a googleVis MotionChart with the Google Visualization API, using

  • 0

I am trying to create a googleVis MotionChart with the Google Visualization API, using the R package.

My problem is that I would like to publish the MotionChart on the internet and for this I want to be able to control the default variables for the different axis/dimensions.

A lot of information can be set using:

gvisMotionChart(M, options=list(state='xxx')

Where 'xxx' is the state which can be copied from the Advanced tab in a MotionChart, however the default time series are not included in the state.

My question is, how can I choose the default variables for the different axis/dimensions of the googleVis MotionChart?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:17:06+00:00Added an answer on June 6, 2026 at 9:17 pm

    Below is a little interface function to gvisMotionChart that allows to specify default values for xvar,yvar, colorvar and sizevar in addition to idvar and timevar. It accomplishes this by simply changing the column order of the provided data.frame. The function also transforms booleans into numbers (otherwise gvisMotionChart throws an error). Since I the motion chart also quite convenient for analyzing cross sectional data, it allows to set timevar=NULL.

        # Convenience interface to gvisMotionChart that allows to set default columns
        myMotionChart = function(df,idvar=colnames(df)[1],timevar=colnames(df)[2],xvar=colnames(df)[3],yvar=colnames(df)[4], colorvar=colnames(df)[5], sizevar = colnames(df)[6],...) {
            library(googleVis)
    
            # Generate a constant variable as column for time if not provided
            # Unfortunately the motion plot still shows 1900...
            if (is.null(timevar)) {
                .TIME.VAR = rep(0,NROW(df))
                df = cbind(df,.TIME.VAR)
                timevar=".TIME.VAR"
            }
    
            # Transform booleans into 0 and 1 since otherwise an error will be thrown
            for (i in  1:NCOL(df)) {
                if (is.logical(df [,i])[1])
                    df[,i] = df[,i]*1
            }
    
            # Rearrange columns in order to have the desired default values for
            # xvar, yvar, colorvar and sizevar
            firstcols = c(idvar,timevar,xvar,yvar,colorvar,sizevar)
            colorder = c(firstcols, setdiff(colnames(df),firstcols))
            df = df[,colorder]
    
            gvisMotionChart(df,idvar=idvar,timevar=timevar,...)
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a button using HTML/jQuery that is positioned on the
I am trying to create a Google Drive app that can run in the
I'm trying to create a Google Map that will display multiple geodesic lines originating
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
I'm trying to create a userscript that automatically adds a QR code image of
I've been trying to create my own firefox toolbar with commands that will open
I am trying create a small web application that allows a user to login
I'm trying to create a GreaseMonkey script that automatically extends the list of alerts
I'm trying to create a page that, when refreshed, will randomly load a url

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.