-1

This is a sample of the sndata I have this code every time I try to run it, it gives me an incorrect number of dimensions.

tab<-table(sndata$Visitors)
tab 
y<- data.frame(tab)
y
x<-gvisMotionChart(sndata$Visitors, "Visitors", "Datehour")
plot (x)

A sample of the date is this:

Focus        Country     Region    City  PrevPage   Pagepath  Pagetitle  Datehour
Admissions    China     Beijing   Beijing  (entrance)  www.bra.ed Inters  20122110
Admissions    China     Beijing Beijing   lts.brandeis.edu  www.b. Undergraduate 

Cannot get past the fifth line

Richard Telford
  • 9,558
  • 6
  • 38
  • 51
  • 2
    Can you provide us with a sample of sndata or sndata$Visitors ? – G5W Feb 18 '17 at 23:45
  • 1
    What do the first 4 lines have to do with it? – Rich Scriven Feb 18 '17 at 23:47
  • Yes, sndata contains information about website entrance, page visits, datehour, and exits. It is a university website which is visited by people all over the world. And I have to analyze it by created charts, such as motion, network and etc. – Shahzoda Nasimi Feb 19 '17 at 00:11
  • Rich Scriven I have do create a motion chart, the first four lines are running successfully, but when it comes to the last line, it is error, because of incorrect dimensions, so maybe the way I'm writing the code is wrong. – Shahzoda Nasimi Feb 19 '17 at 00:12
  • I am unable to correctly post a sample of the data by just copy and paste. – Shahzoda Nasimi Feb 19 '17 at 00:27
  • @dww Uploaded a picture of sample data – Shahzoda Nasimi Feb 19 '17 at 00:32
  • Shouldn't that be: `ab<-table(sndata$Visitors, sndata$Datehour)`? – IRTFM Feb 19 '17 at 00:36
  • @42 it did not work this way as well. I feel like the problem is with the strings but I am not even sure what to replace it with. – Shahzoda Nasimi Feb 19 '17 at 00:42
  • 2
    *"unable to correctly post a sample"* ... `dput(head(sndata))`? If it's too wide, perhaps `dput(head(sndata[,1:10]))`? – r2evans Feb 19 '17 at 01:16
  • @r2evans I have posted it above in the question already. – Shahzoda Nasimi Feb 19 '17 at 01:31
  • 2
    No. You posted an image hoping that people volunteering their time to assist you are okay with transcribing data from an image. Though it is necessary some times, for most things related to `[r]` it is easy enough to post representative data as *text* that we can copy and paste into our console. The only legitimate times I can think of when posting the data directly in the question will not work are based on (a) non-atomic structures, therefore requiring code to construct it; or (b) too large, perhaps requiring an external link to *data* (not an image). (Your problem is neither.) – r2evans Feb 19 '17 at 01:52
  • @r2evans This is my first time doing programming and it is for my big data course. I had no idea you were going to work with it in your console, therefore I thought a picture would suffice. I will type it up right now, thanks for your advice & clarification. – Shahzoda Nasimi Feb 19 '17 at 02:14

1 Answers1

0

Check your syntax for gvisMotionChart()

gvisMotionChart(sndata, idvar="Visitors", timevar="Datehour")

Where,

  • sndata is a dataframe.

  • idvar is the column to be analysed.

  • timevar is the column with time dimension. It can be either numeric or date or character class.

Check ?gvisMotionChart for more details.

Karthik Arumugham
  • 1,300
  • 1
  • 11
  • 18
  • Thanks Karthik for your reply, I took your advice and put it in and it's giving me this message. Error in gvisCheckMotionChartData(data, my.options) : The data must have rows with unique combinations of idvar and timevar. Your data has 189157 rows, but idvar and timevar only define 1924 unique rows. – Shahzoda Nasimi Feb 19 '17 at 02:54
  • It is quite explicit in the error. You need to reduce the rows by transforming it to some metric like `mean`, `sum`, count `n()`, etc. In your case you can try functions from `dplyr` package. `library(dplyr)`, `sndata <- sndata %>% group_by(Visitors, Datehour) %>% summarise_all(mean)`. Then try passing it to gvisMotionChart. You can share some data with us using `dput(head(sndata))` to provide you the complete solution. – Karthik Arumugham Feb 19 '17 at 03:06
  • can you elaborate on how I can share data using dput. pretty new to all this. – Shahzoda Nasimi Feb 19 '17 at 03:30
  • @ShahzodaNasimi if `sndata` is the dataframe in your R environment, then just run `dput(head(sndata))` and copy paste the output in your question here. Check this post on [reproducible-example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Karthik Arumugham Feb 19 '17 at 03:40
  • 1 2 3 4 5 6 7 8 10 11 12 – Shahzoda Nasimi Feb 19 '17 at 03:52
  • 171113 2382 304 73 13 4 3 3 1 1 1 – Shahzoda Nasimi Feb 19 '17 at 03:53
  • The first numbers correspond with the second numbers respectively. creating a table. – Shahzoda Nasimi Feb 19 '17 at 03:53
  • @ShahzodaNasimi No. This is unacceptable. Read the instructions in the link I shared in my previous comment. – Karthik Arumugham Feb 19 '17 at 03:57
  • www.brandeis.edu/wsrc/arts/"), class = "factor"), Pageviews = c(1L, 1L, 1L, 1L, 1L, 1L), Newvisits = c(0L, 0L, 0L, 0L, 0L, 0L ), Entrances = c(0L, 0L, 0L, 0L, 0L, 0L), Avgtimeonpage = c(24, 0, 5, 6, 8, 12), Exits = c(0L, 1L, 0L, 0L, 0L, 0L)), row.names = c(NA, -6L), class = "data.frame", vars = list(Visitors, Datehour, Pagepath, Pageviews, Newvisits, Entrances, Avgtimeonpage, Exits), drop = TRUE, .Names = c("Visitors", "Datehour", "Pagepath", "Pageviews", "Newvisits", "Entrances", "Avgtimeonpage", "Exits"))) – Shahzoda Nasimi Feb 19 '17 at 04:05
  • This is whats coming up when I run dput(head(sndata)). The numbers I gave previosly were from dput(head(sndata$Visitors)). There is just so much. – Shahzoda Nasimi Feb 19 '17 at 04:07
  • @ShahzodaNasimi The output in your previous comment is the right format. But the beginning is truncated. – Karthik Arumugham Feb 19 '17 at 04:22
  • "www.brandeis.edu/audience/parents.html", "www.brandeis.edu/bgi/people/index.html", "www.brandeis.edu/cgi-bin/soupermail.pl", "www.brandeis.edu/communications/", "www.brandeis.edu/community-engaged/", "www.brandeis.edu/das/", "www.brandeis.edu/departments/afroamerstudies/", "www.brandeis.edu/departments/anthro/", "www.brandeis.edu/departments/anthro/faculty/index.html" - This is the beginning of the output R is producing. I don't know what to do with this motion chart anymore, it's giving me a hard time. Thanks for your help much. – Shahzoda Nasimi Feb 19 '17 at 04:37