Re: [R] strangely long floating point with write.table()

2014-03-16 Thread Mike Miller
On Sat, 15 Mar 2014, peter dalgaard wrote: On 15 Mar 2014, at 20:54 , Mike Miller mbmille...@gmail.com wrote: $ cat data1.txt 0.005 0.00489 I don't know why it shows 17 digits and doesn't round to 15, but it is showing that the numbers are different, for some reason. Aiding

Re: [R] Access column after hp filter

2014-03-16 Thread Pascal Oettli
Dear Sabina, If you carefully read the help page (always a good idea), examples show you that it is object$cycle, not object$Cycle. Also, you can use names, i.e. names(e.hp$). HTH, Pascal On Sun, Mar 16, 2014 at 12:56 AM, Liana-Sabina Luncasu lianasabinalunc...@gmail.com wrote: Dear all, I

Re: [R] Access column after hp filter

2014-03-16 Thread Pascal Oettli
Sorry, typo. It should be names(e.hp) Pascal On Sun, Mar 16, 2014 at 3:42 PM, Pascal Oettli kri...@ymail.com wrote: Dear Sabina, If you carefully read the help page (always a good idea), examples show you that it is object$cycle, not object$Cycle. Also, you can use names, i.e. names(e.hp$).

Re: [R] Help using order with data.frame

2014-03-16 Thread arun
Try:  t[order(t$z),] #or t[with(t,order(z)),] A.K. On Sunday, March 16, 2014 12:27 AM, Jason Rupert jasonkrup...@yahoo.com wrote: Evidently, I'm overlooking something simple.  I'm trying to used order with data.frame.   For example: t = data.frame(x = c(11,12,14), y = c(19,20,21), z =

Re: [R] ts instead of xts object

2014-03-16 Thread Bill
Hello Pascal, Yes that is what I was worried about. The date-stamps are there and I would like to use that information but I think using as.ts will not do this. Does anyone know how this is done? Thank you. On Wed, Mar 12, 2014 at 1:02 AM, Pascal Oettli kri...@ymail.com wrote: Hello, On Tue,

Re: [R] strangely long floating point with write.table()

2014-03-16 Thread Duncan Murdoch
On 14-03-16 2:13 AM, Mike Miller wrote: On Sat, 15 Mar 2014, peter dalgaard wrote: On 15 Mar 2014, at 20:54 , Mike Miller mbmille...@gmail.com wrote: $ cat data1.txt 0.005 0.00489 I don't know why it shows 17 digits and doesn't round to 15, but it is showing that the numbers

Re: [R] plotting residuals/error message

2014-03-16 Thread John Fox
Dear Jason, Your suspicion is correct: the cases with NAs in either ft_dpc_r or pid_x are absent from the residuals but not from pid_x. There are several ways to deal with this problem, but one straightforward way is to use na.exclude in place of the default na.omit in the call to lm, as in

Re: [R] plotting residuals/error message

2014-03-16 Thread Gainous,Jason
Thanks John. That worked. It was an easy solution. I'm in the process of switching from Stata and some of these small things are still hanging me up. Jason -Original Message- From: John Fox [mailto:j...@mcmaster.ca] Sent: Sunday, March 16, 2014 9:51 AM To: Gainous,Jason Cc:

[R] permutational ANOVA with random factors

2014-03-16 Thread Menzel, Dr. Florian
Hi everyone, I want to analyse a multivariate dataset with a permutational ANOVA. I usually use adonis in the vegan package. Is there a way to incorporate random factors in such analyses as well? thanks all the best! Florian Dr. Florian Menzel Department of Evolutionary Biology, Institute of

[R] plot average from aggregated data

2014-03-16 Thread Luigi Marongiu
Dear all, I was trying to plot the average of different variables at the same time; I used the aggregate function and I obtained correctly the averages I wanted. However when I have tried to plot the data the outlook of the data is a bar rather than by a symbol; even using the pch or the col

[R] data frame vs. matrix

2014-03-16 Thread Göran Broström
I have always known that matrices are faster than data frames, for instance this function: dumkoll - function(n = 1000, df = TRUE){ dfr - data.frame(x = rnorm(n), y = rnorm(n)) if (df){ for (i in 2:NROW(dfr)){ if (!(i %% 100)) cat(i = , i, \n) dfr$x[i] -

[R] Problems with clmm2 (ordinal data fit)

2014-03-16 Thread Caroline Lustenberger
Dear all I have ordinal data (from a questionnaire with 4 levels) for 2 groups (30 subjects each) and 2 timepoints. So I used a cumulative link mixed model to fit the data (nr = subject number).

[R] R help

2014-03-16 Thread Gautham .Madhusoodhanan
Hi guys, I ran the below R code: department - c(rep(B, 2), rep(C, 2), rep(D, 2), rep(E, 2), rep(F, 2)) gender - rep(c(Male, Female), 5) admitted - c(353, 17, 120, 202, 138, 131, 53, 94, 22, 24) not.admitted - c(207, 8, 205, 391, 279, 244, 138, 299, 351, 317) cbind(department, gender,

Re: [R] Negative binomial models and censored observations

2014-03-16 Thread Ben Bolker
Achim Zeileis Achim.Zeileis at uibk.ac.at writes: On Thu, 13 Mar 2014, Tim Marcella wrote: Hi, I am working with hurdle models in the pscl package to model zero inflated overdispersed count data and want to incorporate censored observations into the equation. 33% of the observed

[R] Overriding predict based on newdata...

2014-03-16 Thread Jonathan Greenberg
R-helpers: I'm having some trouble with this one -- I figure because I'm a bit of a noob with S3 classes... Here's my challenge: I want to write a custom predict statement that is triggered based on the presence and class of a *newdata* parameter (not the object parameter). The reason is I am

Re: [R] plot average from aggregated data

2014-03-16 Thread arun
Hi, Try: plot(copy~as.numeric(stimulation),data=AVG,xaxt=n,xlab=stimulation) axis(1,seq(length(AVG$stimulation)),label=AVG$stimulation) #or library(ggplot2) qplot(stimulation,copy,data=AVG) A.K. On Sunday, March 16, 2014 2:28 PM, Luigi Marongiu marongiu.lu...@gmail.com wrote: Dear all, I

Re: [R] Problems with clmm2 (ordinal data fit)

2014-03-16 Thread Rune Haubo
Dear Caroline, Yes, it seems you have complete separation for the 'Timepoint' variable. This means that the likelihood is unbounded for that parameter and the optimizer just terminates when it gets far enough out on an asymptote and improvements are below a threshold. This is also the reason the

Re: [R] Help using order with data.frame

2014-03-16 Thread Jason Rupert
Thank you very much for your posts.  I updated the example, which was taken from the following: http://cran.r-project.org/doc/contrib/Torfs+Brauer-Short-R-Intro.pdf Hopefully the below is a bit more representative question, but unfortunately, it looks like I'm not inputting the dates

Re: [R] plot average from aggregated data

2014-03-16 Thread Duncan Mackay
Hi Luigi It always helps to know what your data is str(AVG) 'data.frame': 8 obs. of 2 variables: $ stimulation: Factor w/ 8 levels Unstimulated,..: 1 2 3 4 5 6 7 8 $ copy : num 1006 1750 7439 1058 2952 ... AVG stimulation copy 1 Unstimulated 1005.80527 2ESAT6

Re: [R] Help using order with data.frame

2014-03-16 Thread arun
Hi, Try:  data_test-data.frame(id, dates, info, sqfootage, lotsize,stringsAsFactors=FALSE)  data_test[order(with(data_test,as.Date(dates,%m/%d/%Y))),]    id dates   info sqfootage lotsize 3 ID3 2/03/2013 siding  3000    0.75 2 ID2 1/16/2014   wood  2000    0.50 1 ID1 2/16/2014 

Re: [R] ts instead of xts object

2014-03-16 Thread Joshua Ulrich
On Sun, Mar 16, 2014 at 6:27 AM, Bill william...@gmail.com wrote: Hello Pascal, Yes that is what I was worried about. The date-stamps are there and I would like to use that information but I think using as.ts will not do this. Does anyone know how this is done? It cannot be done. The ts class

Re: [R] ts instead of xts object

2014-03-16 Thread Bill
Joshua, Thanks. I am going to check. On Mon, Mar 17, 2014 at 11:10 AM, Joshua Ulrich josh.m.ulr...@gmail.comwrote: On Sun, Mar 16, 2014 at 6:27 AM, Bill william...@gmail.com wrote: Hello Pascal, Yes that is what I was worried about. The date-stamps are there and I would like to use that

Re: [R] data frame vs. matrix

2014-03-16 Thread Rui Barradas
Hello, This is to be expected. Matrices can hold only one type of data so the problem is solved once and for all, data frames can have many types of data so the code to handle them must determine which type to handle on every access. Hope this helps, Rui Barradas Em 16-03-2014 18:57,

Re: [R] data frame vs. matrix

2014-03-16 Thread Duncan Murdoch
On 14-03-16 2:57 PM, Göran Broström wrote: I have always known that matrices are faster than data frames, for instance this function: dumkoll - function(n = 1000, df = TRUE){ dfr - data.frame(x = rnorm(n), y = rnorm(n)) if (df){ for (i in 2:NROW(dfr)){ if

Re: [R] data frame vs. matrix

2014-03-16 Thread William Dunlap
Duncan's analysis suggests another way to do this: extract the 'x' vector, operate on that vector in a loop, then insert the result into the data.frame. I added a df=quicker option to your df argument and made the test dataset deterministic so we could verify that the algorithms do the same

Re: [R] data frame vs. matrix

2014-03-16 Thread Jeff Newmiller
Did you really intend to make all of the x values the same? If so, try one line instead of the for loop: dfr$x[ 2:n ] - dfr$x[ 1 ] If that was merely an error in your example, then you could use a different one-liner: dfr$x[ 2:n ] - dfr$x[ seq.int( n-1 ) ] In either case, the speedup is

Re: [R] R Running slow on Ubuntu

2014-03-16 Thread Russell Bainer
Thanks guys. I'll look into this and tell you if I come up with anything. -R On Saturday, March 15, 2014, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Comparing with an unspecified benchmark makes answering this too hard. Following instructions in the Posting Guide will lead to more

Re: [R] R Running slow on Ubuntu

2014-03-16 Thread Mitchell Maltenfort
http://www.cybaea.net/Blogs/Faster-R-through-better-BLAS.html any help? On Mar 16, 2014 9:38 PM, Russell Bainer russ.bai...@gmail.com wrote: Thanks guys. I'll look into this and tell you if I come up with anything. -R On Saturday, March 15, 2014, Jeff Newmiller jdnew...@dcn.davis.ca.us

[R] Issue with special assignment operator

2014-03-16 Thread AROONALOK PYNE
Hi Please explain why the function 'foo()' is not printing x as 8 in the following code : foo - function(){ + x - 10 + if(x){ + x - 8 + } + print(x) + } foo() [1] 10 x [1] 8 -- *AROONALOK PYNE* BE Graduate Department Of Computer Science And Engineering Jadavpur University, Kolkata-32

[R] assigning dataframes in an ifelse statement

2014-03-16 Thread BEUTEL Terry S
Hi everyone. I have three dataframes (A, B and C). B and C are subsets of the rows of A, for example... A-as.data.frame(cbind(1:5,21:25)) A V1 V2 1 1 21 2 2 22 3 3 23 4 4 24 5 5 25 B-A[1:4,] B V1 V2 1 1 21 2 2 22 3 3 23 4 4 24 C-A[3:5,] C V1 V2 3 3 23 4 4 24 5 5 25

Re: [R] assigning dataframes in an ifelse statement

2014-03-16 Thread Jeff Newmiller
Solution is to not use ifelse. Use if...else... --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go...

Re: [R] Issue with special assignment operator

2014-03-16 Thread Jeff Newmiller
Because x refers to the local version, not the global one. In case you have not read this before, using - is a really really bad idea. Your code will become confusing and likely be wrong if you ignore this warning. Return a value from the function and save it in the calling environment when