R programming

Hi,

I have the following program in R: It plots a graph. I want to include a functionality such that whenever I hover over the points on my graph I am able to view the information associated with each of the points.

Thanks
Data = read.csv(file = "data.csv", 
                header = TRUE, sep = ",")
OAS = matrix(Data[1])
OASD = matrix(Data[2])
#reg1 <- lm(as.matrix(OAS)~as.matrix(OASD))
reg1 <- lm(as.matrix(Data[1])~as.matrix(Data[2]))
par(cex=.8)
plot(t(Data[2]), t(Data[1]),main="OAS vs OASD",xlab="OASD", ylab="OAS")
abline(reg1)
text(Data$class3, Data$class4, Data$Maturity.Date)
anova(reg1)

Open in new window

camper12Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Matthew RichardsonProduct CoordinatorCommented:
I've never seen it done where you can hover over a point and get an immediate popup with the result unless you use a in-depth graphics package that included interactive plotting, because it sounds like you don't want all the values showing.

Have you tried using the built in "identify" function included in R's graphics package? I put together what I think would work for your dataset:
identify(t(Data[2], t(Data[1], labels=row.names(Data))
coords <- locator(type="l") 
coords

Open in new window

This will make a list with the coordinates that you could make into a data frame if that is what you wanted. Not sure what your intended purpose is with the information but you could label the graph with something different, I just chose the row names of your data set.

Alternatively, you could use this function:
identifyPch <- function(x, y = NULL, n = length(x), pch = 19, ...)
{
  xy <- xy.coords(x, y); x <- xy$x; y <- xy$y
  sel <- rep(FALSE, length(x)); res <- integer(0)
  while(sum(sel) < n) {
    ans <- identify(x[!sel], y[!sel], n = 1, plot = FALSE, ...)
    if(!length(ans)) break
    ans <- which(!sel)[ans]
    points(x[ans], y[ans], pch = pch)
    sel[ans] <- TRUE
    res <- c(res, ans)
  }
  res;
}

identifyPch(t(Data[2], t(Data[1])

Open in new window

Which would automatically return the list of points you selected while also seeing which one's were selected if you don't want anything appearing on the graph itself.

Let me know if that is something like what you are looking for.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
camper12Author Commented:
Hi Matthew,

I am trying to incorporate a tooltip: something like given in
http://ramnathv.github.io/rCharts/

However, when I do the following

library(devtools)
install_github('rCharts', 'ramnathv')

I get an error

Downloading github repo ramnathv/rCharts@master
Error in curl::curl_fetch_memory(url, handle = handle) :
  Timeout was reached

Any idea how I can resolve this?

Thanks
0
Matthew RichardsonProduct CoordinatorCommented:
I just tried downloading it myself the way their website says and it worked for me.  It sounds like an issue with one of the dependency packages from "devtools" is incomplete.  

Try reinstalling the "devtools" package and all its dependencies:
require(devtools)
install_github('rCharts', 'ramnathv')
library(rCharts)

Open in new window


And see if that helps.  I was able to use their first and second examples just fine doing that.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

camper12Author Commented:
Installed devtools again including dependencies. I still get the same error.
0
Matthew RichardsonProduct CoordinatorCommented:
Try putting this line of code before the install code:

options(download.file.method = "wininet")
1
camper12Author Commented:
Tried this. Still does not work.
0
Matthew RichardsonProduct CoordinatorCommented:
You might be behind firewall and need to use proxy settings from 'httr' package?

Fingers crossed...

library(RCurl)
library(httr)
set_config( config( ssl_verifypeer = 0L ) )
0
camper12Author Commented:
Tried it. Still get the same error. The proxy maybe the cause. I am looking into it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.