I believe it's a problem in your variable name "hsa-miR-98". R wants to interpret that as "hsa" less "miR" less 98. Since you don't have a variable called "hsa", R (rightly) complains.
Call ls() and see what R thinks your variables are named -- that will hopefully make the problem evident. Hope this helps, Michael Weylandt PS -- in your plot() call, you don't need a "c" around xcoords. On Mon, Aug 15, 2011 at 7:55 AM, rmje <robinmje...@gmail.com> wrote: > *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: > > > 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@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.