Re: [R] Merging dataframes

2018-05-01 Thread Sarmah, Chintanu
Thanks, Peter, Eivind and Lui Sorry, I could not explain it properly in the first go. Trying to simplify it here with an example - Say I have two dataframes as below that are not equally-sized data frames: Table_A: Email Name Phone

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Jeff Newmiller
Here is a stab in the dark. I agree with Jim that the description of the problem is hard to follow. The original posting being in HTML format did not help. # library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Jim Lemon
Hi Marna, This is a condition that the function cannot handle. It would be possible to reformat the result based on the time intervals, but the stretch_df function doesn't try to interpret the values, just stretches them out to a wide format. Jim On Wed, May 2, 2018 at 9:16 AM, Marna Wagley

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Marna Wagley
Hi Jim, The data set is correct. I took two readings from the "SITE A" within a short time interval, therefore I want to take the first value if there are repeated within a same group of "timeGroup". Therefore I wanted following FinalData1 B1B2 id_X "A" "B" id_Y "A" "B"

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Jim Lemon
Hi Marna, I think this is due to having three rows for id_X and only two for id_Y. The function creates a data frame with enough columns to hold the greatest number of values for each ID variable. Notice that the SITE_n columns contain three values for id_X (A, A, B) and two for id_Y (A, B, NA) as

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Marna Wagley
Hi Jim, Thank you very much for your suggestions. I used it but it gave me three sites. But actually I do have only two sites "Id_X" and "Id_y" . In fact "A" is repeated two times for "Id_X". If it is repeated, I would like to take the first one among many repeated values. dat<-structure(list(ID

Re: [R] how can I convert a long to wide matrix?

2018-05-01 Thread Jim Lemon
Hi Marna, Try this: library(prettyR) stretch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE")) Jim On Wed, May 2, 2018 at 8:24 AM, Marna Wagley wrote: > Hi R user, > I was trying to convert a long matrix to wide? I have an example and would > like to get a table

[R] how can I convert a long to wide matrix?

2018-05-01 Thread Marna Wagley
Hi R user, I was trying to convert a long matrix to wide? I have an example and would like to get a table (FinalData1): FinalData1 B1B2 id_X "A" "B" id_Y "A" "B" but I got the following table using the following code. FinalData1 B1 B2 id_X "A" "A" id_Y "A" "B"

Re: [R] [FORGED] Re: Specifying priors in a multi-response MCMCglmm

2018-05-01 Thread Michelle Kline
Okay, you've all successfully convinced me to leave this list. Bye! On Tue, May 1, 2018 at 3:13 PM, Rolf Turner wrote: > > On 02/05/18 09:53, Michelle Kline wrote: > > Hi Bert, >> >> That was distinctly unhelpful >> > > Not if you actually follow Bert's advice. > > and

Re: [R] [FORGED] Re: Specifying priors in a multi-response MCMCglmm

2018-05-01 Thread Rolf Turner
On 02/05/18 09:53, Michelle Kline wrote: Hi Bert, That was distinctly unhelpful Not if you actually follow Bert's advice. and your outward hostility to a field you obviously don't understand reveals a regrettable level of ignorance. I didn't see any hostility to any field. Bert, like

Re: [R] Specifying priors in a multi-response MCMCglmm

2018-05-01 Thread Michelle Kline
Hi Bert, That was distinctly unhelpful, and your outward hostility to a field you obviously don't understand reveals a regrettable level of ignorance. By the way, my research is Anthropology despite my job title. Michelle On Tue, May 1, 2018 at 2:48 PM, Bert Gunter

Re: [R] Specifying priors in a multi-response MCMCglmm

2018-05-01 Thread Bert Gunter
1. (Mainly) Statistical issues are generally off topic on this list. You might want to try the r-sig-mixed-models list instead. 2. However, I think a better answer is to seek local statistical expertise in order to have an extended discussion about your research intent in order to avoid producing

Re: [R] How would I color points conditional on their value in a plot of a time series

2018-05-01 Thread Eivind K. Dovik
You may also want to check this out: plot(ttt, type = "p") points(ttt, col = ifelse(ttt < 8, "black", "red")) Eivind K. Dovik Bergen, NO On Tue, 1 May 2018, Christopher W Ryan wrote: Excellent! Worked like a charm. Thanks. --Chris Ryan On Tue, May 1, 2018 at 4:33 PM, William Dunlap

[R] Specifying priors in a multi-response MCMCglmm

2018-05-01 Thread Michelle Kline
Hi all, I previously emailed about a multinomial model, and after seeking some additional help, realized that since my response/outcome variables are not mutually exclusive, I need to use a multi-response model that is *not* multinomial. I'm now trying to figure out how to specify the priors on

Re: [R] How would I color points conditional on their value in a plot of a time series

2018-05-01 Thread Christopher W Ryan
Excellent! Worked like a charm. Thanks. --Chris Ryan On Tue, May 1, 2018 at 4:33 PM, William Dunlap wrote: > The ts method for plot() is quirky. You can use the default method: > > plot(as.vector(time(ttt)), as.vector(ttt), type = "p", col=ifelse(ttt<8, > "black", "red"))

Re: [R] How would I color points conditional on their value in a plot of a time series

2018-05-01 Thread William Dunlap via R-help
The ts method for plot() is quirky. You can use the default method: plot(as.vector(time(ttt)), as.vector(ttt), type = "p", col=ifelse(ttt<8, "black", "red")) Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, May 1, 2018 at 1:17 PM, Christopher W Ryan wrote: > How

[R] How would I color points conditional on their value in a plot of a time series

2018-05-01 Thread Christopher W Ryan
How would I color points conditional on their value in a plot of a time series. Something like this: ## demonstration data ttt <- ts(rpois(12, lambda = 8), start = c(2000, 1), freq = 4) ttt plot(ttt, type = "p") ## doesn't work--all points the same color plot(ttt, type = "p", col = ifelse(ttt <

Re: [R] Merging dataframes

2018-05-01 Thread Eivind K. Dovik
On Tue, 1 May 2018, Chintanu wrote: Hi, May I please ask how I do the following in R. Sorry - this may be trivial, but I am struggling here for this. For two dataframes (A and B), I wish to identify (based on a primary key-column present in both A & B) - 1. Which records (rows) of A did

Re: [R] Merging dataframes

2018-05-01 Thread peter dalgaard
I'd expect more like setdiff(A$key, B$key) and vice versa. Or, if you want the actual rows A[!(A$key %in% B$key),] or for the row numbers which(!(A$key %in% B$key)) -pd > On 1 May 2018, at 12:48 , Rui Barradas wrote: > > Hello, > > Is it something like this

Re: [R] Merging dataframes

2018-05-01 Thread Rui Barradas
Hello, Is it something like this that you want? x <- data.frame(a = c(1:3, 5, 5:10), b = c(1:7, 7, 9:10)) y <- data.frame(a = 1:10, b = 1:10) which(x != y, arr.ind = TRUE) Hope this helps, Rui Barradas On 5/1/2018 11:35 AM, Chintanu wrote: Hi, May I please ask how I do the following in

[R] Merging dataframes

2018-05-01 Thread Chintanu
Hi, May I please ask how I do the following in R. Sorry - this may be trivial, but I am struggling here for this. For two dataframes (A and B), I wish to identify (based on a primary key-column present in both A & B) - 1. Which records (rows) of A did not match with B, and 2. Which