[R] Plot from function
Duncan Murdoch
murdoch.duncan at gmail.com
Mon Aug 15 15:24:18 CEST 2011
On 11-08-15 7:55 AM, rmje wrote:
> *I have the following function:*
>
> /plot_mi_time = function(mdata, miname) {
> mdata2 = mdata[row.names(hakat) == miname, ]
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
> 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:
>
>> plot_mi_time(hakat, hsa-miR-98)
> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list