Format value in legend in dygraph plot in R - r

I'm using the excellent dygraphs R package. One thing that I don't seem to find in the documentation is the possibility of passing a formatting function to dyLegend in the same way it's possible for dyAxis (e.g. valueAxisFormatter). The legend defaults to scientific notation for values in the millions, which most of my audience does not like.
Does anyone know of a way to pass a JS formatting function?
Thank you.

Related

How to Change X-Axis Label in ChromoMap?

I am new to R and I have been using chromoMap library in R to visualize annotation plots and visualizing the feature-associated data. It's a great library and produces great charts. However, I was not able to find any option for changing the x-axis label from length (bp) to anything else. Because of this, I am not able to use any of the produced charts. It sounds like a small issue, but it totally affects the usability of this great package. I followed this tutorial link and produced the below chart. In my chart and all the samples, the x-axis label is fixed and this is my problem and I am looking for a way to just change it.
library(chromoMap)
chr_file_1 = "chr_file_without_centromere.txt"
anno_file_1 = "annotation_pos.txt"
chromoMap(chr_file_1,anno_file_1)
I am wondering if anybody has the same experience ?? This package produces output as a htmlwidget object and therefore I could not change the x-axis lable. Is there any way to modify a htmlwidget object? or Any way to change this bp to something else??

Incorrect label representation with gvisTimeline in the R googleVis

I am using gvisTimeline for performing Gantt charts, and think that this library is brilliant.
But when the barlabel parameter in gvisTimeline function is set to dataframe column name, which contains Russian words, they comes into ��������, when plotting this timeline.
I've tried changing encoding to UTF-8, but as a result I receive the same question marks and also something like <ce><f2><e1><ee><f0> <ef><f0><ee><e1>.
So I guess the problem is with encoding, but I have no idea how to fix it.
The same names in plotly or ggplot2 diagrams are displayed correctly.
I really appreciate any help you can provide.

Mapping variable values to colors in gvisLineChart?

I'm looking for the equivalent of:
ggplot(df,aes(x=date,y=var1,**group=col1,colour=col1**))+geom_line()
in the googleVis package.
Anyone knows how to do this? I only found examples of differently colored lines if they are mapping different columns from the dataframe.
thanks!
#mtoto, I hope my answer here on ggplot2 equivalent of 'factorization or categorization' in googleVis in R can help. Have you taken a look?
Using roles you can specify specific styles for your data. It involves adding another column with the style detail. So if plotting varx, you need to add the column varx.style where you will set the colors.
I do not know ggplot well enough to know if this is the exact fit of what you want, but please take a look at my figures and links in that answer.

hide missing dates from x-axis ggplot2

I am trying to make a chart in ggplot2 (barplot). There are several days in between data points in my data set. I'd like to only graph the dates where variables are and omit the empty dates.
I have been searching for an hour trying to find an answer to this. I found some replies here indicating that the fix is this:
scale_x_date(format = '%d%b', major='days')
However, those arguments inside of scale_x_date don't seem to work anymore. Does anyone have a quick and easy solution?
I would be remiss if I didn't mention the ggplot2 docs which are a fantastic resource, packed full of well-documented examples. They are often the best place to start when you don't know how to do something with ggplot.
The "translation" for the code you quoted above in the current framework is:
scale_x_date(breaks='days', labels=date_format("%d%b"))
which will require the package scales. Unless you have fairly few dates, you probably also would want an adjustment like
theme(axis.text.x = element_text(angle=45))
If you only want to label the dates for which you have data, try
scale_x_date(breaks=df$date, labels = date_format("%m/%d"))
where df$date is the column of your dataframe containing the dates, and of course you can use your preferred date format string.

Plotting large numbers with R, but not all numbers are being shown

I am trying to render 739455 data point on a graph using R, but on the x-axis I can not view all those numbers, is there a way I can do that?
I am new to R.
Thank you
As others suggested, try hist, hexbin, plot(density(node)), as these are standard methods for dealing with more points than pixels. (I like to set hist with the parameter breaks = "FD" - it tends to have better breakpoints than the default setting.)
Where you may find some joy is in using the iplots package, an interactive plotting package. The corresponding commands include ihist, iplot, and more. As you have a Mac, the more recent Acinonyx package may be even more fun. You can zoom in and out quite easily. I recommend starting with the iplots package as it has more documentation and a nice site.
If you have a data frame with several variables, not just node, then being able to link the different plots such that brushing points in one plot highlights them in another will make the whole process more stimulating and efficient.
That's not to say that you should ignore hexbin and the other ideas - those are still very useful. Be sure to check out the options for hexbin, e.g. ?hexbin.

Resources