r - Transfer of columns from one data frame to another under conditional statement -


I have this code, which was written mostly by a member here which exports to all the graphs from my data set The condition is that the trendline coefficient is positive (increasing trend)

  lungs & lt; - read.csv ("LAC.csv") enclosed (lung) # data age & lt; - Lung $ Age Mirna & lt; - data.frame (lung) stuff & lt; - data.frame (matrix (ncol = 500, nrow = 40)) pdf ("test.pdf") #pdf to match all articles for all exports (colnames (mirna) [-1], function (call) {Plot form for #function; - Formula (paste (chest, "age", Sep = "~") is fit & lt; - LM (form, mirna) stuff_want <- stuff if (cof (fit ) [2]> Plotting with {# content plot (form, df, xlab = "age", main = "mirana expression with increasing age")) abline (fit, col = 4)}}) Dev.o Ff ()   

This gives me a PDF file that I need to know later that the dataset is required for miRNA and to manually use columns to isolate columns Was hoping. However, I have seriously underestimated the number of mirrors that meet the condition and now face a new puzzle how to export the data from a column and to increase the trendline in a different data frame, which I Later on Further analysis in the form of a CCV file.

Please keep in mind that my knowledge about R is very limited, although I have been spending days in Rahelk and books. My idea was to create a separate data frame (luggage_want) in which the columns that satisfy the situation (Coeff (LM)> gt; 0) will be transferred. My initial thought was to use the function () function and if the condition was written attachment (after baggage_imant, mirna, = length), after write.csv () Festival The production of this is just NA loaded. The CCV file is

Anyone is able to explain why this is not working?

All the best, Paulus

So here's a way (@Estustody's Comment ), Using the data I created

  # some data x < - Copyable examples for seq (1,10, len = 100) set.seed (1) # DF & LT; - Data. Frame (X, Y1 = 1 + 2 * x + rnorm (100), y2 = 3-4 * x + rnorm (100), y3 = 2 + 0.001 * x + rnorm (100)) # You Let's start ... Results & lt; - sapply (colnames (df) [- 1], function (call) {form  gt; TRUE else FALSE}) column & lt; - Name (result) [result] column # [1] "y1" "y3" / code>  

This creates a designated vector, result , in which your responses to the elements The variable has the same name, and value = TRUE if that variable is positive slope, wrong otherwise

  cols & lt; - Name (result) [result]   

A vector of variable names with slopes and gt; 0. Finally, to extract the actual data, you will use it:

  stuff_want & lt; - Content [, Coles]    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -