[R] Knitr R - how to draw plot exactly at place of plot function call in output document?

2016-06-06 Thread Michu Kom
My R script run with Knitr generates a statistic summary of electrode pairs accompanied with plots. The problem is that knitr does not render plots in correct sections. In section for pair A knitr do not wait for plot and start to evaluate code for output summary for pair B. So in section B knitr p

Re: [R] detecting if a variable has changed

2016-06-06 Thread peter dalgaard
> On 06 Jun 2016, at 05:20 , Duncan Murdoch wrote: > > On 05/06/2016 2:13 PM, Bert Gunter wrote: >> Nope, Ted. I asked for a O(log(n)) solution, not an O(n) one. > > I don't think that's possible with a numeric vector. Inserting an entry at a > random location is an O(n) operation, since you

Re: [R] Knitr R - how to draw plot exactly at place of plot function call in output document?

2016-06-06 Thread Ulrik Stervbo
Hi Michu, What document type do you generate? I usually make just html and have no problems. If you create a pdf, please remember this is done through LaTeX and your problem could arise from the floats of LaTeX. For other output I have no idea. Hope this helps Ulrik Michu Kom schrieb am Mo., 6

Re: [R] Reading and converting time data via read.table

2016-06-06 Thread PIKAL Petr
Hi > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ek Esawi > Sent: Sunday, June 5, 2016 2:54 PM > To: r-help@r-project.org > Subject: [R] Reading and converting time data via read.table > > Hi All-- > > > > I am relatively new to R. I am reading a cs

Re: [R] How to specify a data frame column using command line arg?

2016-06-06 Thread Ista Zahn
Hi Doug, ggplot lets you map variables to aesthetics in a few different ways, including passing to variable names as strings to aes_string. See ?aes_string for details. Best, Ista On Jun 6, 2016 1:03 AM, "Jim Lemon" wrote: > Yes, I see what you want. I can't run this myself as my work computer

[R] Merging variables

2016-06-06 Thread G . Maubach
Hi All, I merged two datasets: ds_merge1 <- merge(x = ds_bw_customer_4_match, y = ds_zww_customer_4_match, by.x = "customer", by.y = "customer", all.x = TRUE, all.y = FALSE) R created a new dataset with the variables customer.x and customer.y. I would like to merge these two variable back

[R] BootChainLadder problem

2016-06-06 Thread Elisa Di Cristina
I am using ChainLadder package for statistical analysis of a run-off triangle with I=17 and J=14. When I use BootChainLadder() it appears on R console "Number of origin periods has to be equal or greater then the number of development periods". But I have origin periods greater then developmen

Re: [R] How to specify a data frame column using command line arg?

2016-06-06 Thread Changrong Ge
> > Hi, > I have recently made similar scatter plot. > Suppose you have a data frame "data.csv" and the first column is not > what you want to plot but rather something informative such as ID, Class, > Group, etc which might not be your case (but would be very nice if you want > to color yo

Re: [R] Merging variables

2016-06-06 Thread David Winsemius
You loop through each Sent from my iPhone > On Jun 6, 2016, at 8:29 AM, g.maub...@weinwolf.de wrote: > > Hi All, > > I merged two datasets: > > ds_merge1 <- merge(x = ds_bw_customer_4_match, y = > ds_zww_customer_4_match, > by.x = "customer", by.y = "customer", > all.x = TRUE, all.y = FALSE

Re: [R] Merging variables

2016-06-06 Thread David Winsemius
You loop through each row but during each iteration you assign a value to the entire "mismatch" column. The last value assigned was 1. Sent from my iPhone > On Jun 6, 2016, at 8:29 AM, g.maub...@weinwolf.de wrote: > > Hi All, > > I merged two datasets: > > ds_merge1 <- merge(x = ds_bw_custome

Re: [R] Merging variables

2016-06-06 Thread PIKAL Petr
Hi Not sure if this is the most effective or general solution but Here you get 2 if the value is same in both columns, 1 if it is only in one column and the other is NA and 0 if there is mismatch of values. temp <- (ds_test[,2] %in% ds_test[,1])+(ds_test[,1] %in% ds_test[,2]) here you get 0 if

Re: [R] dissolve tiny polygons to others with unionSpatialPolygons{maptools}

2016-06-06 Thread Roger Bivand
On Mon, 6 Jun 2016, Kumar Mainali wrote: I am trying to use unionSpatialPolygons() of maptools to eliminate sliver in species range. I want to dissolve tiny sliver polygons in a shapefile to bigger polygons as "Eliminate (Data Management)" of ArcMap does. Whereas I can dissolve polygons that hav

Re: [R] Merging variables

2016-06-06 Thread Michael Dewey
X-Originating-<%= hostname %>-IP: [217.155.205.190] Dear Georg I find it a bit surprising that you end up with customer.x and customer.y. Can you share with us a toy example of two data.frames which exhibit this behaviour? On 06/06/2016 13:29, g.maub...@weinwolf.de wrote: Hi All, I merged

Re: [R] detecting if a variable has changed

2016-06-06 Thread Bert Gunter
Oh, good point! I was thinking only of the comparisons to identify the insertion location. --Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sun, Jun 5, 20

[R] multcomp package

2016-06-06 Thread li li
Hi all, After fitting a random slope and random intercept model using lme function, I want to test whether each of the fixed slopes is equal to zero (The output of model is below). Can this be done (testing each individual slope) using multcomp package? Thanks much for the help. Hanna > sum

Re: [R] Merging variables

2016-06-06 Thread PIKAL Petr
Hi Michael it is simple set.seed(111) let=sample(letters[1:10],6, replace=T) dat1<-data.frame(let=let, customer=sample(1:10,6, replace=T)) let=sample(letters[1:10],6, replace=T) dat2<-data.frame(let=let, customer=sample(1:10,6, replace=T)) merge(dat1, dat2, by.x="let", by.y="let", all=T) Of cour

[R] Trouble with (Very) Simple Clustering

2016-06-06 Thread Lorenzo Isella
Dear All, I am doing something extremly basic (and I do not claim at all there is no other way to achieve the same): I have a list of numbers and I would like to split them up into clusters. This is what I do: I see each number as a 1D vector and I calculate the euclidean distance between them. I

Re: [R] find longest consecutive streak in double

2016-06-06 Thread Bert Gunter
Yes, see ?rle, as Jim indicated. Just wanted to add that there is an rpy2 package that enables you to use R within python, which may mean that you do not need to translate your python code. Or at least not all of it. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people k

[R] Antwort: RE: Merging variables

2016-06-06 Thread G . Maubach
Hi David, Hi Petr, many thanks for your help. With your hints I got the idea how I could do it and I came up with this solution: -- cut -- #--- # Module: t_merge_variables.R # Author: Georg Maubach # Dat

Re: [R] How to specify a data frame column using command line arg?

2016-06-06 Thread David L Carlson
Looking at your overall goal to plot multiple columns, you can use a simple loop with expand.grid(): > set.seed(42) > adl1 <- matrix(sample.int(9), 3, 3) > colnames(adl1) <- letters[1:3] > lbls <- colnames(adl1) > > ncols <- ncol(adl1) > colnos <- as.matrix(expand.grid(1:ncols, 1:ncols)) > coln

Re: [R] merging dataframes in a list

2016-06-06 Thread MacQueen, Don
I would probably do it this way, tmp <- list(data.frame(name="sample1", red=20), data.frame(name="sample1", green=15), data.frame(name="sample2", red=10), data.frame(name="sample2", green=30)) fun1 <- function(df) data.frame(name=df$name, color=names(df)[2], va

Re: [R] Trouble with (Very) Simple Clustering

2016-06-06 Thread David L Carlson
I think your problem is that pvclust looks for clusters between variables and you have only one variable. When you transpose data_mat, you have a single row and dist cannot calculate a distance matrix on a single row: > dist(t(data_mat)) dist(0) I was going to suggest package NbClust since ther

Re: [R] dissolve tiny polygons to others with unionSpatialPolygons{maptools}

2016-06-06 Thread Kumar Mainali
Thank you, Roger. I cannot fix the upstream processes to eliminate generation of these problems. So, I need to deal with the data I got. I tried various online resources including https://gist.github.com/mstrimas/1b4a4b93a9d4a158bce4 and tried: setScales() set_RGEOS_dropSlivers(TRUE) set_RGEOS_poly

Re: [R] [R-sig-ME] multcomp package

2016-06-06 Thread Evan Palmer-Young
Hanna, If you are interested in whether effect of time varies across individuals, why don't you fit a model with the predictors (time*individual) as fixed effects rather than random? On Mon, Jun 6, 2016 at 10:57 AM, li li wrote: > Hi all, > After fitting a random slope and random intercept mod

[R] replace NAs in each column of a matrix with 0 or 1 or 2 with specific proportion

2016-06-06 Thread Lida Zeighami
Hello specialist, I have a matrix in which there are NA,0,1 and 2 in each columns. I wanna replace NAs with special proportion of 0,1 or 2 ! for example in df<- matric(df, nrow=50, ncol=100) If in one column the number of NAs = 10 , # of 0=50 , #of 1=25 and # of 2=15 I want to replace 5 of 10 N

Re: [R] replace NAs in each column of a matrix with 0 or 1 or 2 with specific proportion

2016-06-06 Thread Henrique Dallazuanna
Maybe you can use something like this In this way, almost your proportion of 0, 1 and 2 will be maintained m <- matrix(sample(c(NA, 0:2), size = 50*100, replace = TRUE), nrow = 50, ncol = 100) trunc(prop.table(apply(m, 2, table), 2) * colSums(is.na(m)), 0) m[is.na(m)] <- unlist(apply(trunc(prop.t

[R] R programmer/developer part time job

2016-06-06 Thread nidal . alhuniti
AstraZeneca, a leading pharmaceutical company, has an exciting opportunity for an R-developer within its Quantitative Clinical Pharmacology (QCP) group. The position is a 6-12 month contract position which will integrate R programming knowledge, capabilities and prowess towards pharmacometric analy

Re: [R] replace NAs in each column of a matrix with 0 or 1 or 2 with specific proportion

2016-06-06 Thread Bert Gunter
Sidenote: When you do imputation in this way all your inference (error estimates, goodness of fit, confidence intervals, etc.) will be wrong and misleading, as you are creating "information" from nothing. If this comment is irrelevant, please ignore. Cheers, Bert Bert Gunter "The trouble with h

Re: [R] R programmer/developer part time job

2016-06-06 Thread Bert Gunter
This should be posted on the r-sig-jobs email list. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jun 6, 2016 at 3:25 PM, wrote: > AstraZe

Re: [R] [R-sig-ME] multcomp package

2016-06-06 Thread li li
Thanks Evan and Gabriel for the reply. I think it might help me make the question clearer if I show the data and the model here (I actually asked questions related to this data before but I still need some help). The data looks like the following: response individual time method 1102.9

Re: [R] Knitr R - how to draw plot exactly at place of plot function call in output document?

2016-06-06 Thread Ulrik Stervbo
Hi Michu, it is not I problem I am familiar with, sorry. Maybe someone else on this list or at the knirt google group can help you further. Best, Ulrik On Mon, 6 Jun 2016 at 10:36 Michu Kom wrote: > Hello, > > HTML looks much nicer :) ... but still problem is not solved :/ still > having mixed

[R] Antwort: Re: Merging variables

2016-06-06 Thread G . Maubach
Hi Michael, yes, I was astonished about this behaviour either. I have worked with SPSS a lot - and that works different. I would like to share some of my data. Can you tell me how I can dump a dataset in a way that I can post it here as text? Kind regards Georg Von:Michael Dewey An:

[R] Antwort: RE: Merging variables

2016-06-06 Thread G . Maubach
Hi Petr, I would like to describe the data situation in brief: I have an business warehouse dataset (referred to as BW data) containing sales and an ERP customer master data dataset with additional information (referred to as ERP data). Though customer IDs and customer names are identical due

[R] evaluate the daily mean with date in "POSIXct" "POSIXt" class

2016-06-06 Thread Stefano Sofia
Dear R-list users, I have the following data frame, called MteBove: posix_datesnowtemp ... 2010-01-20 23:30:00 45 NA 2010-01-02 00:30:00 10-2.7 2010-01-20 03:00:00 45 NA 2010-01-20 03:30:00 44 NA 2010-01-20 04:00:00 44 NA 2010-01-20 04:30:00 44 NA 2010-01-20 05:00:00 44 NA 2010-01-20 05:30