Plot multiple functions in R -
I first asked this which was useful in plotting a function. I want to try twenty functions on the same axis and tell me how a function varies between two categories. I have done this successfully by using specified tasks personally, but I wanted to use a loop to do this.
I did try it:
## add ggplot2 library (Ggplot2) library (Latis) #Path = "D: / R_Analysis /" inFile = " sample.txt "Autpath =" D: / R_Analysis / "outFile =" processed_sample.txt "pdfOutPath =" D: / R_Analysis / "PdfOutFile =" processed_sample.pdf "# declared to chart the value y_label =" x-axis "x_label = "Y-axis" chart_title = "..." ##################################### ################################# Read In Data; Analysis and lieutenant; - read.table (paste (inPath, inFile, sep = ""), header = TRUE, sep = ",", na.strings = "NA", dec = ".", Strip.white = TRUE) # setup PDF PDF (pdfOutPath, pdfOutFile, sep = ""), height = 6, width = 9) #Plot object P & lt; - qplot (data = Detakfrem (x = x, y = y) X, y, xlab = x_label, ylab = y_label, code Enter here xlim = x_range, main = chart_title) # Empty function eq_dummy = function (x) {0} d = stat_function (fun = eq_dummy) ##################################### [i , 2] slope = analysis [i, 3] #defined curve eq & lt; - Pane (X) {slope * log (x) + intercept) # Plot object composite; - stat_function (fun = eq) Composite = Composite + d} print (P + Combosait) # Warning Close Alerts Show () # File dev.off ()
The syntax of chapter Any suggestions in the roumement, or programming structure will be appreciated. Thank you.
Good job file.path
OS free You can use it in your code:
inPath = file.path ("D:", "R_Analysis") inFile = "sample.txt" outPath = file.path ( "D:", "R_Analysis") outFile = "processed_sample.txt" pdfOutPath = file.path ("D:", "R_Analysis") pdfOutFile = "processed_sample.pdf"
and Then <(PdfOutPath, pdfOutFile))
Your path is "windows-dependent (reference to disk label), but if you use relative paths, then it is more useful Be.
and other signs - you possibly graphics device should open late, like
pdf (file.path (pdfOutPath, pdfOutFile), height = 6 , Width = 9) print (P + composite) dev.off ()
Then it is easy to find when you want to see the plot in the window and not in the file for the appropriate line.
Comments
Post a Comment