Re: [R] Correlation

2014-07-17 Thread PIKAL Petr
Hi I looked in the help page which states See Also cor.test for confidence intervals (and tests). cov.wt for weighted covariance computation. Then I looked to cov.wt help page and it seems that it does what you want cov.wt(data.frame(x,y), wt=c(.5,.25,.25), cor=T) $cov xy x 1.1 4.1

Re: [R] Help with Download of a comma separated file in zip format

2014-07-17 Thread Raghuraman Ramachandran
Hi Fabio Can you please reproduce your output? When I tried it curl are the following issues I get: download.file( http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip;, temp, method=curl) Error in download.file(

Re: [R] Correlating multiple effect sizes within a study to study-level predictors: metafor package

2014-07-17 Thread Michael Dewey
At 17:49 16/07/2014, Megan Bartlett wrote: Hi Michael, Thank you! Just to clarify, in my question, I was thinking that in this regression each study should be treated as one point, instead of each species, so that each effect size x value has a unique climate y value. Is that what the random=

Re: [R] Help with Download of a comma separated file in zip format

2014-07-17 Thread Raghuraman Ramachandran
Many thanks. I will try that. On Thu, Jul 17, 2014 at 1:29 PM, Fábio Magalhães fmagalh...@gmail.com wrote: Hi Balaji, Sorry, I forgot to tell that I'm running R on OSX. I don't know if there's an easier way, but since you are running on Windows you could try to install

[R] Mapping from one vector to another

2014-07-17 Thread Gang Chen
Suppose I have the following dataframe: L4 - LETTERS[1:4] fac - sample(L4, 10, replace = TRUE) (d - data.frame(x = 1, y = 1:10, fac = fac)) x y fac 1 1 1 B 2 1 2 B 3 1 3 D 4 1 4 A 5 1 5 C 6 1 6 D 7 1 7 C 8 1 8 B 9 1 9 B 10 1 10 B I'd like to add

Re: [R] Mapping from one vector to another

2014-07-17 Thread William Dunlap
One way is to use a vector with names to do the mapping: mapVector - c(A=8, B=11, C=3, D=2) mapVector[as.character(d$fac)] B B D A C D C B B B 11 11 2 8 3 2 3 11 11 11 # you may want to wrap this with unname() d$mappedFac - mapVector[as.character(d$fac)] d x y fac mappedFac

Re: [R] Mapping from one vector to another

2014-07-17 Thread Sarah Goslee
What about: d$var - c(8, 11, 3, 2)[d$fac] Side note: it's much appreciated that you included data and a clear problem statement. If you use set.seed(123) before your call to sample(), everyone who tries it will get the same fac that you do. Otherwise we all get something different. Or just

Re: [R] Mapping from one vector to another

2014-07-17 Thread PIKAL Petr
Hi depends if you want the new column as factor or numeric. d$fac2-d$fac I did not use var as it is R function. levels(d$fac2)-c(8,11,3,2) d$fac2 [1] 3 11 8 8 2 8 11 11 8 8 Levels: 8 11 3 2 You can change it to character or numeric if you wish. as.character(d$fac2) [1] 3 11 8 8 2

[R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Dario Strbenac
Hello, I have a block of code that has two head calls at the end, but only the second is shown on screen. If I manually execute the statement which is not showing, it works. I thought that if statements are not functions. It is behaving as one. if(1 2) + { + x-rnorm(100) + y - rpois(10,

[R] download.file: unsuppported url scheme

2014-07-17 Thread Joe W. Byers
I have found an interesting issue. I use R Studio for most of my development and automate many tasks to run over night. I have a https file scrape process that runs without issue from R Studio command line. When I try to run from the R console, I get an error from download.file stating

Re: [R] Help with Download of a comma separated file in zip format

2014-07-17 Thread Fábio Magalhães
Hi Balaji, Sorry, I forgot to tell that I'm running R on OSX. I don't know if there's an easier way, but since you are running on Windows you could try to install curl(http://curl.haxx.se/) binaries and try the curl method again. #! Fábio On Thu, Jul 17, 2014 at 5:26 AM, Raghuraman Ramachandran

[R] Definition of the shape paramter in PERT (mc2d)

2014-07-17 Thread Ingrid Charvet
Hello everyone, I am trying to define a PERT distribution by hand by transforming a classic beta distribution - as I would like to understand where the shape parameter (default value of 4) comes from in the mc2d package. The help page says The PERT distribution is a beta distribution extended

[R] Model for lm keeps producing an error

2014-07-17 Thread Jessica Timms
Hi, I still seem to be getting errors from trying to run my altered R script, any advice? Thanks Jess Model1A = function(meth_matrix,exposure, X1, X2, X3, batch) { + + mod = lm(methcol ~ exposure+X1+X2+X3+batch, data = meth_matrix) + + + res=coef(summary(mod))[2,] + + + } ##Run

Re: [R] Mapping from one vector to another

2014-07-17 Thread Gang Chen
Thanks a lot for the quick and elegant solutions, Sarah, Bill and Petr! I really appreciate it, including the suggestion of setting a random seed. Have a nice day! Gang On Thu, Jul 17, 2014 at 11:15 AM, Sarah Goslee sarah.gos...@gmail.com wrote: What about: d$var - c(8, 11, 3, 2)[d$fac]

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Sarah Goslee
Hi, You can get the behaviour you want using the print() command: if(1 2) { x-rnorm(100) y - rpois(10, 5) print(head(x)) print(head(y)) } Sarah On Thu, Jul 17, 2014 at 2:00 AM, Dario Strbenac dstr7...@uni.sydney.edu.au wrote: Hello, I have a block of code that has two head calls

[R] information

2014-07-17 Thread shashank guptanp
Hello, i am working on a metagenomics, and analyzing a genome of different sample using QIIME tools, will you tell me how can i use R Program for metagenome analysis. Regards.Shashank Gupta [[alternative HTML version deleted]] __

Re: [R] how to subset based on other row values and multiplicity

2014-07-17 Thread arun
Hi Bill, Modifying `f2` seems to solve the problem. f2 - function (data) {     library(dplyr)     data%%     group_by(id, value) %%     mutate(date=as.Date(date))%%     arrange(date) %%     filter(indx =any(c(abs(diff(date)),NA) 31) date==min(date)) %%     filter(row_number()==1) }  

Re: [R] Mapping from one vector to another

2014-07-17 Thread Jeff Newmiller
You ask about generic methods for introducing alternate values for factors, and some of the other responses address this quite efficiently. However, a factor has meaning only within one vector at a time, since another vector may have additional values or missing values relative to the first

Re: [R] information

2014-07-17 Thread Jeff Newmiller
You should read the Posting Guide for the r-help list, and the list control web page. One problem with your post is that the r-help-request address is not for asking questions. Another problem is that cross-posting to multiple lists would not have been polite anyway. Your question is really

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Rui Barradas
Hello, Also, unlike what the op says, if statements are functions, explaining the behavior he got. Hope this helps, Rui Barradas Em 17-07-2014 16:53, Sarah Goslee escreveu: Hi, You can get the behaviour you want using the print() command: if(1 2) { x-rnorm(100) y - rpois(10, 5)

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Jeff Newmiller
This question is related to FAQ 7.16, which you should look up. In general, whenever you just type a variable or function directly at the command line, R prints the result for you. Inside code blocks of any kind, it does not do that, so you need to use the print function yourself. On Thu, 17

Re: [R] Mapping from one vector to another

2014-07-17 Thread Gang Chen
Jeff, Even though the solutions from the previous responders are good enough for my current situation, the principle you just raised will be definitely beneficial to your future work. Thanks a lot for sharing the insights! Gang On Thu, Jul 17, 2014 at 12:06 PM, Jeff Newmiller

Re: [R] Reading SDMX Files in R

2014-07-17 Thread Emmanuel Blondel
Dear Lorenzo, I've just seen one post from you asking for hints to read SDMX data in R. I don't know if you still need to read SDMX datasets in R. In case, you can use the rsdmx package hosted here https://github.com/opensdmx/rsdmx With the OECD sample you mention, you can do as follows:

[R] Equivalent of chartr to numeric

2014-07-17 Thread ALBERTO VIEIRA FERREIRA MONTEIRO
Is there any equivalent to chartr for numeric values? Meaning, something like: numerictr(c(-1, 42, 666), 1:3, numeric.stuff) that replaces in numeric.stuff (a vector, matrix, etc) all instances of -1 for 1, 42 for 2 and 666 for 3? Alberto Monteiro

Re: [R] Correlating multiple effect sizes within a study to study-level predictors: metafor package

2014-07-17 Thread Megan Bartlett
Hi Michael, I think you're right, it would be a good idea for me to get a better grip on mixed effects modeling before I charge ahead with metafor. Thank you very much for all of your help with this! Much appreciated! Best, Megan On Thu, Jul 17, 2014 at 3:50 AM, Michael Dewey

Re: [R] Equivalent of chartr to numeric

2014-07-17 Thread ALBERTO VIEIRA FERREIRA MONTEIRO
Replying to self: Is there any equivalent to chartr for numeric values? Meaning, something like: numerictr(c(-1, 42, 666), 1:3, numeric.stuff) that replaces in numeric.stuff (a vector, matrix, etc) all instances of -1 for 1, 42 for 2 and 666 for 3? match does it. Sorry to ask. Alberto

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread David Winsemius
On Jul 17, 2014, at 9:27 AM, Rui Barradas wrote: Hello, Also, unlike what the op says, if statements are functions, explaining the behavior he got. I'm not sure that is correct. The help page says if() is a control-construct. I think the function is actually { {rnorm(10); rpois(10, 3)}

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Rolf Turner
On 18/07/14 11:32, David Winsemius wrote: On Jul 17, 2014, at 9:27 AM, Rui Barradas wrote: Hello, Also, unlike what the op says, if statements are functions, explaining the behavior he got. I'm not sure that is correct. The help page says if() is a control-construct. I think the function

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Bert Gunter
Rolf et.al I have not followed this thread closely and so have nothing to say about whose or what explanation is correct. However, the following statement is misleading, if not wrong: --- foo - function(){ x - 17 x y - 42 y } If you type foo() you get [1] 42 which is

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Dario Strbenac
The example in the question was not inside a user function. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal,

[R-es] Selección eficiente de individuos

2014-07-17 Thread Francisco Javier
Buenas tardes, Tengo un data frame denominado “trabajadores”, que cubre desde el 1 de enero de 1997 hasta el 30 junio de 1999, con 3 columnas: Identificador (ID), la fecha de entrada en la empresa (ENT) y la fecha de salida (SAL). Deseo localizar aquellos trabajadores que, durante dicho

Re: [R-es] Selección eficiente de individuos

2014-07-17 Thread Carlos J. Gil Bellosta
Simplificando (i.e., asumiendo que los días fin de año son los múltiplos de 10): # datos simulados dat - data.frame(id = letters[1:4], ini = c(1, 15, 15, 11), fin = c(11, 19, 25, 22)) fin.anno - 10 * 1:3 # resultado dat[mapply(function(x,y) ! any(fin.anno

Re: [R-es] [Grupo de Usuarios R Madrid]: Siguiente reunión el 1-julio... (Agenda disponible)...

2014-07-17 Thread Jose Luis Cañadas Reche
Me pilla un poco lejos de dónde trabajo. ;) Estaría interesado en que fuera en Córdoba o Granada. Sé que en Granada hay unos cuantos eRReros entre la uni y alguna que otra empresa, y en Málaga también hay unos cuantos.. Saludos El 17/07/14 23:03, Rubén Gómez Antolí escribió: Hola: El