Re: [R] Editing code in a function? related to allowing zero weights in lmer()

2013-08-02 Thread Mike Rennie
, R.methodsS3 before you can use it. On Fri, Aug 2, 2013 at 12:03 AM, Mike Rennie mikerenni...@gmail.com wrote: Indeed- thanks for the tips to get me going. This just kicks things up a notch for me, having happily used packages without wanting to tinker with them till now. Cheers. On Thu, Aug 1, 2013

[R] Editing code in a function?

2013-08-01 Thread Mike Rennie
Hi folks, I've not before had to edit code right in a function, but I think I need to. I am using lmer() and want to use a model that uses zero weights. I found this thread from 2009: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2009q1/001995.html but I'm unsure of how I would actually go

Re: [R] install-packages

2013-08-01 Thread Mike Rennie
Try typing this into google search bar: [R] install packages The majority of the results on the first page will help you out. On Thu, Aug 1, 2013 at 8:43 PM, Said Filahi sa.fil...@gmail.com wrote: hello, i am new and I want to know how to install a packare on R thank you said filahi

[R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
Hi there, Does anyone know how I solve for x from a given y in a polynomial function? Here's some example code: ##example file a-1:10 b-c(1,2,2.5,3,3.5,4,6,7,7.5,8) po.lm-lm(a~b+I(b^2)+I(b^3)+I(b^4)); summary(po.lm) (please ignore that the model is severely overfit- that's not the point).

Re: [R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
- From: Rui Barradas ruipbarra...@sapo.pt To: Mike Rennie mikerenni...@gmail.com Cc: r-help Mailing List r-help@r-project.org Sent: Friday, March 1, 2013 3:18 PM Subject: Re: [R] solving x in a polynomial function Hello, Try the following. a - 1:10 b - c(1, 2, 2.5, 3, 3.5, 4, 6, 7, 7.5, 8

Re: [R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
, coef(model))) + Re(r[is.zero(Im(r))]) + } r - realroots(po.lm, 5) predict(po.lm, newdata = data.frame(b = r)) 1 2 5 5 This function just returns what I feed it as written. Mike On 3/1/13, Peter Ehlers ehl...@ucalgary.ca wrote: On 2013-03-01 13:06, Mike Rennie wrote: Hi guys

Re: [R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
Doh- I'm a moron. I get it now. The last line is the confirmation that function realroots is working. Sorry- late in the day on a friday. Thanks everyone for your help with this- Uber-useful, and much appreciated. Mike On 3/1/13, Mike Rennie mikerenni...@gmail.com wrote: Hi Peter

Re: [R] how to make partial mean() of a matrix only when second value matching some logic

2010-12-08 Thread Mike Rennie
try tapply() if you want the values for all levels of x, or calculate your mean after a subset() Check the documentation on both of these. Mike On Wed, Dec 8, 2010 at 9:54 AM, madr madra...@interia.pl wrote: for example I have matrix with two columns x,y 1,0.56 2,9.55 2,7.56 5,2.55

Re: [R] Checking for orthogonal contrasts

2010-12-03 Thread Mike Rennie
There's a pretty good section in the R book by Crawley on contrast statements in R, including some discussion of the contrasts being orthogonal. I would say you should just make your own table and sort it out there- if you have equal sample sizes, then the contrast coefficients along the row

Re: [R] Help summarizing R data frame

2010-12-02 Thread Mike Rennie
see also tapply() e.g. a-c(1,1,1,2,2,2,3,3,3) b-c(10,10,10,15,15,15,20,20,20) c.dat-data.frame(a,b) tapply(c.dat[,2],c.dat[,1],sum) Mike On Thu, Dec 2, 2010 at 10:33 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: see ?aggregate, and ?summaryBy (in package doBy) I think ddply (in

Re: [R] Filter data

2010-12-02 Thread Mike Rennie
Try looking at subset()... I typically use this when I'm trying to isolate specific cases from a data frame. Also, Dalgaard's introductory R book has some great examples for parsing data in the manner you're attempting you might want to look at that. Mike On Thu, Dec 2, 2010 at 2:08 PM,

Re: [R] New Sampling question

2010-11-18 Thread Mike Rennie
Hi Wallace, Have you tried playing with sample()? Note that you can apply this function both to whole dataframes, as well as specific items within a vector. If you play with applying the function to different ways of indexing your sample data, you will likely arrive at your solution. for

Re: [R] New Sampling question

2010-11-18 Thread Mike Rennie
You could try writing a loop a-data.frame(c(1:10),c(21:30)) M-10 #number of iterations- scale up to 1000 once you get your sampling function working res-NULL #place to store your results for i in (1:M) { ares-sample(a[,2],1) res-c(res, ares) } res It's up to you how to

Re: [R] How to extract particular rows and column from a table

2010-11-05 Thread Mike Rennie
Hi Mauluda, Next time, please read the posting guide- helping you is made alot easier if you provide the code that didn't work. It sounds like you might want something like this? #make a data frame, with some column names assigned... aa-data.frame(c(rep(a,5), rep(c,3)),c(rep(7,5), rep(2,3))) aa

Re: [R] Converting Strings to Variable names

2010-11-04 Thread Mike Rennie
Hi Anand, Try creating a variable where you can store your data, and append it in your loop. See added lines of code to include below... On Thu, Nov 4, 2010 at 9:43 AM, Anand Bambhania amb1netwo...@gmail.comwrote: Hi all, I am processing 24 samples data and combine them in single table

Re: [R] Sorting data from one column with strings

2010-11-04 Thread Mike Rennie
(apologies for any double hits; forgot to reply all...) Or, you could just go back to basics, and write yourself a general loop that goes through whatever levels of a variable and gives you back whatever statistics you want... below is an example where you estimate means for each level, but you

Re: [R] Plotting densities

2010-09-23 Thread Mike Rennie
In your call to polygon(), include lty=dashed or dotted or whatever you want your line type to look like. take a good look at all the options in ?par For everything you can customize in plots. Alternatively, Paul Murrel's R Graphics book is the best reference I know for this sort of stuff.

Re: [R] merging multiple data frames

2010-09-23 Thread Mike Rennie
First, you might want to start by generating a new column to identify your 'pdf and bdf or whatever once it's merged. For the merging, see ?merge But as someone's already pointed out, it's not clear what you are trying to merge by. Also, as your example calculations show, you don't need to

Re: [R] plotting multiple animal tracks against Date/Time

2010-09-23 Thread Mike Rennie
By range on the y-axis, do you mean distance? It would have to be if time is on your x? Or am I misreading this? You could just plot() with the data for your first individual, and then add additional individuals after that using lines(), specifying a different colour and/or line type for each

Re: [R] Extracting bins and frequencies from frequency table

2010-09-22 Thread Mike Rennie
Hi Ralf try hist() obl-hist(x1, plot=FALSE) it returns midpoints and their respective frequencies. You can specify the breakpoints as well. ?hist for details. Mike On Wed, Sep 22, 2010 at 1:44 PM, Ralf B ralf.bie...@gmail.com wrote: Dear R users, I would like to great a frequency table