-1

I have a dataframe that I want to add a column to from another data frame. The following code "works":

GOT_TOTALS$PERCENTAGE <- totals
GOT_TOTALS

When I print GOT_TOTALS I get my dataframe with the new column "totals".

But I can't do anything with that new column. I can't plot it in a bar graph because it doesn't register the values.

And when I save the table back onto dashDB, it saves every percentage in EACH box. For example instead a new column like this:

  PERCENTAGE
1   14.10625
2   70.48295
3   18.27415
4   37.03030
5   89.40300
6   17.03065
7   34.74760
8   37.05015
9   53.86945

It shows all the percentages in EACH box like this:

c(14.10625, 70.48295, 18.27415, 37.0303, 89.403, 17.03065, 34.7476, 37.05015, 53.86945)
c(14.10625, 70.48295, 18.27415, 37.0303, 89.403, 17.03065, 34.7476, 37.05015, 53.86945)
c(14.10625, 70.48295, 18.27415, 37.0303, 89.403, 17.03065, 34.7476, 37.05015, 53.86945)
c(14.10625, 70.48295, 18.27415, 37.0303, 89.403, 17.03065, 34.7476, 37.05015, 53.86945)
c(14.10625, 70.48295, 18.27415, 37.0303, 89.403, 17.03065, 34.7476, 37.05015, 53.86945)
c(14.10625, 70.48295, 18.27415, 37.0303, 89.403, 17.03065, 34.7476, 37.05015, 53.86945)

etc.

Any ideas?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Saraida
  • 39
  • 7
  • You need to provide more to go on. Before trying to join the columns, type `dput(GOT_TOTALS)` and `dput (totals)` and paste the output into your question – dww Jun 29 '16 at 14:57
  • You answered my question. Unknowingly. It turns out that every row i had saved was saved either as a double or integer but that I was adding my list directly as a list. Even though I saved the list into dashDB as a table, it was still oddly saved as a list. So i just used TOTALDATA <- sapply(TOTALDATA, as.double) to my list and THEN added it to my dataframe and it worked. – Saraida Jun 29 '16 at 15:12
  • thanks for answering – Saraida Jun 29 '16 at 15:12

1 Answers1

0

I saved the new column being added as a double. THEN added it to the dataframe. TOTALDATA <- sapply(TOTALDATA, as.double)
GOT_TOTALS$PERCENTAGE <- TOTALDATA

eli-k
  • 10,898
  • 11
  • 40
  • 44
Saraida
  • 39
  • 7