[R] Extracting Variable Name to define breaks for histogram
ligges at statistik.tu-dortmund.de
Wed Feb 4 20:03:55 CET 2009
Christian Langkamp wrote:
> I am trying to define an automatic breaks function for a histogram.
> Inputs are a vector x and a number n. What I would like is to define the
> outcome as breaks_(Name of Vector) - but the paste("breaks_",x) obviously
> refers to the whole vector.
> breaks<- function(x, n)
> R<-range(x, na.rm=T)
> paste("breaks_",x)<-c(NA, seq(floor(R), ceiling(R),diff_x/n))
> rm(diff_x, R)
I do not think you want it that way. You want to return values, not to
assign it into the environment of a function that is shortly deleted anyway.
Anyway, for the assignment itself (that is also undesirable), see ?assign
More information about the R-help