Skip to content

Plot from function

6 messages · R. Michael Weylandt, Duncan Murdoch, rmje

#
*I have the following function:*

/plot_mi_time = function(mdata, miname) {
   mdata2 = mdata[row.names(hakat) == miname, ]
   print(mdata2)
   xcoords <- c(1,1,2,2,3,3,4,4,5,5,6,6)
   plot(c(xcoords), mdata2, xaxt="n", ylab="Expression", xlab="Time(h)", ,
main=miname)
	   axis(1, at=xcoords,
labels=c("a","a","b","b","c","c","d","d","e","e","f","f"))
}/


*The function is supposed plot a row from the following input-table:*


/                     X1h    X4h    X9h   X15h   X18h   X21h
hsa-miR-99b*         173     64     66     56     65     65
hsa-miR-99b          549    697   1070   1051   1777   2201
hsa-miR-99a*           3      1      3      0      3      2
hsa-miR-99a            5      4     14     16     33     37
hsa-miR-98          3475   4177   4075   4513   4631   5940
hsa-miR-96            21     99    101    135     87    103
hsa-miR-95             3      7      6      4      3      5
hsa-miR-944          275    209    253    311    313    320/


*When running the function I get the following errro messag*e:
Error in `[.data.frame`(mdata, row.names(hakat) == miname, ) : 
  object 'hsa' not found


*Anyone know how to use the function correct?*


--
View this message in context: http://r.789695.n4.nabble.com/Plot-from-function-tp3744428p3744428.html
Sent from the R help mailing list archive at Nabble.com.
#
On 11-08-15 7:55 AM, rmje wrote:
You passed the expression hsa-miR-98 as miname.  The simplest fix is to pass

"hsa-miR-98"

instead.  A more complicated alternative is to use 
deparse(substitute(miname)) in place of miname in the function:  that 
converts the expression to a string.

Duncan Murdoch
#
It workes using ""

But what is this:
X1h  X4h  X9h X15h X18h X21h
hsa-miR-100 384 1038 1503 1511 2603 2899
*Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ*

--
View this message in context: http://r.789695.n4.nabble.com/Plot-from-function-tp3744428p3744673.html
Sent from the R help mailing list archive at Nabble.com.