r

Need a R package for piecewise linear regression ?

Does anybody aware of a package for "piecewise linear regression" ? ...

select only rows if its value in a particular column is less than its value in the other column

Hi folks, I am using R and need to select rows with aged (age of death) less than or equal to laclen (lactation length). I am trying to create a new data frame to only include rows/ids whereby the value of column'aged' is less than its corresponding 'laclength' value. df: id1 id2 laclen aged 9830 64526 26 6 7609 64...

StatET debugging tool

I think I'm just being dense, but I can't seem to figure out how to use the debugging tool while working in R in Eclipse (StatET plugin). Has anyone got any tips or tutorials on the subject? ...

tidy/efficient function writing in R

Excuse my ignorance, as I'm not a computer engineer but with roots in biology. I have become a great fan of pre-allocating objects (kudos to SO and R inferno by Patrick Burns) and would like to improve my coding habits. In lieu of this fact, I've been thinking about writing more efficient functions and have the following question. Is th...

Working with dictionaries/lists in R

Hi, everybody! I have trivial question: I couldn't find a dictionary data structure in R, so I used list instead (like "word"->number) So, right now I have problem how to get the list of keys. Anybody knows? ...

How to visualize a list of lists of lists of ... in R?

Hi there, I have a very deep list of lists in R. Now I want to print this list to the standard output to get a better overview of the elements. It should look like the way the StatET plugin for eclipse shows a list. Example list: l6 = list() l6[["h"]] = "one entry" l6[["g"]] = "nice" l5 = list() l5[["e"]] = l6 l4 = list() l4[["f"]] = ...

Essential skills of a Data Scientist

What are the relevant skills in the arsenal of a Data Scientist? With new technologies coming in every day, how does one pick and choose the essentials? A few ideas germane to this discussion: Knowing SQL and the use of a DB such as MySQL, PostgreSQL was great till the advent of NoSql and non-relational databases. MongoDB, CouchDB etc...

R Question. Numeric variable vs. Non-numeric and "names" function

> scores=cbind(UNCA.score, A.score, B.score, U.m.A, U.m.B) > names(scores)=c('UNCA.scores', 'A.scores', 'B.scores','UNCA.minus.A', 'UNCA.minus.B') > names(scores) [1] "UNCA.scores" "A.scores" "B.scores" "UNCA.minus.A" "UNCA.minus.B" > summary(UNCA.scores) X6.69230769230769 Min. : 4.154 1st Qu.: 7.333 Medi...

Creating a for loop in R

For this project you are required to use an R script to simulate the effectiveness of the t-test. A for loop will be used to carry out the following 2000 times: Would the loop look something like this i <- 1 for (i <= 2001) { x <-rf(5,df1=5,df2=10) b <- df2 p.value <-t.test(x,mu=(b/(b-2))$p.value i <- i+1 } ...

select rows with unidentical column values using R

Hi Guys, I need to create a new data frame that excludes dams that appear in "dam1" and "dam2" columns on the same fosdate (fostering date). I tried df <- df[df$dam1!=df$dam2,] but did not work. Dam1 and dam2 are factors which are the id's of mothers. my df: fosdate dam1 dam2 8/09/2009 2Z523 2Z523 30/10/2009 1W509 ...

What is the difference between Multiple R-squared and Adjusted R-squared in a single-variate least squares regression?

Could someone explain to the statistically naive what the difference between Multiple R-squared and Adjusted R-squared is? I am doing a single-variate regression analysis as follows: v.lm <- lm(epm ~ n_days, data=v) print(summary(v.lm)) Results: Call: lm(formula = epm ~ n_days, data = v) Residuals: Min 1Q Median 3Q...

Is there an R function to get the number of permutations of n objects take k P(n,k)?

..or do I have to give P.nk <- factorial(n) / factorial(n-k) or P.nk <- choose(n,k) * factorial(k) Thank you. ...

How to access elements in a complex list?

Hi, it's me and the lists again. I have a nice list, which looks like this: tmp = NULL t = NULL tmp$resultitem$count = "1057230" tmp$resultitem$status = "Ok" tmp$resultitem$menu = "PubMed" tmp$resultitem$dbname = "pubmed" t$resultitem$count = "305215" t$resultitem$status = "Ok" t$resultitem$menu = "PMC" t$resultitem$dbname = "pmc" tmp...

applying apply() to deeply embeded list elements only

I would like to apply my function to only elements that are deeper in the list structure. For example, I would like to apply a certain function to list elements of second order only. Is this feasible with apply()? > str(l) List of 3 $ :List of 2 ..$ : num 5 ..$ : num 10 $ :List of 2 ..$ : num 15 ..$ : num 20 $ :List of 2 ....

Is there an expand.grid like function in R, returning permutations ?

to become more specific, here is an example: > expand.grid(5, 5, c(1:4,6),c(1:4,6)) Var1 Var2 Var3 Var4 1 5 5 1 1 2 5 5 2 1 3 5 5 3 1 4 5 5 4 1 5 5 5 6 1 6 5 5 1 2 7 5 5 2 2 8 5 5 3 2 9 5 5 4 2 10 5 5 6 2 1...

how to send email with attachment from R in windows

I have a scheduled R script running from a windows machine. After it finishes, I wish this script to automatically send an email with some log file attached. Using shell() with some other scripts may be possbile, but I was wondering if there is a better solution within R. thanks. ...

How can I find out how many rows of a matrix satisfy a rather complicated criterion (in R)?

As an example, here is a way to get a matrix of all possible outcomes of rolling 4 (fair) dice. z <- as.matrix(expand.grid(c(1:6),c(1:6),c(1:6),c(1:6))) As you may already have understood, I'm trying to work out a question that was closed, though, in my opinion, it's a challenging one. I used counting techniques to solve it (I mean by...

Calling software modules (Java, Perl, etc.) from R

I've recently started using R for Natural Language Processing tasks and find that a lot of applications are available in Java and Perl (for my purposes). For example: A few perl modules are available to find distance measures between words by querying Wordnet. I am aware of the R Wordnet package, but it does not perform the tasks that t...

Generate lags R

Hi All, I hope this is basic; just need a nudge in the right direction. I have read in a database table from MS Access into a data frame using RODBC. Here is a basic structure of what I read in: PRODID PROD Year Week QTY SALES INVOICE Here is the structure: str(data) 'data.frame': 8270 obs. of 7 variables: $ PRODID : int 20001...

Asking ESS/R users for suggestions for elisp codes in .emacs file

I believe that not all R users know elisp. It would be nice if ESS users could share their code in their .emacs file here. Well commented code would be particularly useful. Hope this will promote the use of ESS by R users. ...