3

I need help about this function, i try it with plot (R) and googleVis, it works perfectly; now i want to use rChart but when i launch the functions it returned me a simple grid with no points on it.

VehiculeFunction <- function(data, gamme, absciss, ordinate){

  # Aim: Permet de visualiserles données sous la forme de nuages de points 
  #      croisant GMF*Coût,  Ratio K * Ratio Coût ou bien GMF*Ratio en 
  #      choisissant la gamme qu'on désire
  # Input: data.frame avec notamment GAMME, PROJET, PERIMETRE, NITG, GMF.24,
  #        Cout.24 et libele
  # Output: Graphique avec le croisement choisi ainsi que le libellé étiquetté
  #         sur le point qu'on voudra identifier

  if(absciss == "GMF.24"){
    my.data <- data[data$RANG_NITG_PROJET_K %in% c(1, 2, 3),]
  } else if(absciss == "Ratio.K") {
    my.data <- data[data$RANG_NITG_PROJET_C %in% c(1, 2, 3),]
  }
  my.data2 <- my.data[my.data$GAMME == gamme,]
  X <- my.data2[[absciss]] 
  Y <- my.data2[[ordinate]] 

  plot <- nPlot(Y ~ X, data = data, type = 'scatterChart')
  plot
}


VehiculeFunction(data.vehicule2, gamme = "M1", "GMF.24", "Cout.24")

data.vehicule2 is a dataframe. Thank you.

EDIT:

In the dataframe, i have 18 variables and 36 000. This code works perfectly, but my problem is the plot appearance.

library(rCharts)
VehiculeFunction <- function(data, gamme, absciss, ordinate){

  # Aim: Permet de visualiser les données sous la forme de nuages de points 
  #      croisant GMF*Coût,  Ratio K * Ratio Coût ou bien GMF*Ratio en 
  #      choisissant la gamme qu'on désire
  # Input: data.frame avec notamment GAMME, PROJET, PERIMETRE, NITG, GMF.24,
  #        Cout.24 et libele
  # Output: Graphique avec le croisement choisi ainsi que le libellé étiquetté
  #         sur le point qu'on voudra identifier

  if(absciss == "GMF.24"){
    my.data <- data[data$RANG_NITG_PROJET_K %in% c(1, 2, 3),]
  } else if(absciss == "Ratio.K") {
    my.data <- data[data$RANG_NITG_PROJET_C %in% c(1, 2, 3),]
  }
  my.data2 <- my.data[my.data$GAMME == gamme,]
  X <- my.data2[[absciss]] 
  Y <- my.data2[[ordinate]] 
  SIZEVAR <- my.data2$Ratio.K
  df <- data.frame(X,Y,SIZEVAR)

  plot <- nPlot(x = "X", y = "Y", size = "SIZEVAR", data = df, type = "scatterChart")
  plot 
}



VehiculeFunction(data.vehicule, gamme = "M1", "GMF.24", "Cout.24")

Could i add a size variable because on the plot nothing appears, how could i have my variable "GMF.24" and "Cout.24" on the axis ? and the last question, is it possible to add label when i place the mouse above a point ?

Thank you in advance.

  • 2
    I am sure many people are willing to help the Coût of your croisant, but without croisant data it is difficult. So please provide a part of the data frame that shows the problem. If you do not want to share your data, make fake data. – Dieter Menne Jun 11 '14 at 16:52
  • 2
    Try `plot <- nPlot(x = X, y = Y, data = data, type = 'scatterChart')` if X and Y are characters. If they are column vectors, then I don't understand why you are referring to `data = data`. – Ramnath Jun 11 '14 at 16:53
  • I just edited my post, @Ramnath in my example X reprensents GMF.24, Y represents Cout.24 and GAMME is M1. Thank you. – user3527451 Jun 12 '14 at 08:27

0 Answers0