Re: [R] add an idx column to the matrix

2015-08-10 Thread PIKAL Petr
Hi here is another approach. > cbind(mydata, idx=(rowSums(mydata==2, na.rm=T)>0)*1) X125 X255 X558 X2366 X177 X255.1 idx aa010NA0 0 0 bb110NA0 1 0 cs212 10 0 1 de010NA0 0 0 gh20

Re: [R] replacing then summing by values from another dataframe

2015-08-10 Thread PIKAL Petr
Hi Not sure about elegancy/efficiency. library(reshape2) dat3 <- melt(dat2) dat3 mid variablevalue 1 m10 -19.5482 2 m20 -0.5120 3 m30 -0.4920 4 m11 0.0070 5 m21 3.2410 6 m31 -2.2560 7 m12 1.2230 8 m22 -4.490

Re: [R] inbuilt crossover function for backtesting

2015-08-10 Thread boredstoog via R-help
Josh, I have found other demos on demo().. any way thanks for the help and for supporting this project :) boredstog -- View this message in context: http://r.789695.n4.nabble.com/inbuilt-crossover-function-for-backtesting-tp4710918p4710962.html Sent from the R help mailing list archive at Nabb

Re: [R] inbuilt crossover function for backtesting

2015-08-10 Thread boredstoog via R-help
Hey thanks josh, I was looking for such a demo programme can you point to some more such demo programmes if available -- View this message in context: http://r.789695.n4.nabble.com/inbuilt-crossover-function-for-backtesting-tp4710918p4710961.html Sent from the R help mailing list archive at Na

[R] replacing then summing by values from another dataframe

2015-08-10 Thread Xianming Wei
[I might have sent the following request to a wrong email address - 'r-help-requ...@r-project.org'] Hi, I have two data frame dat1 and dat2. dat1 <- data.frame(pid = paste('C', 1:5, sep = ''), m1 = c(2, 2, 1, -1, 0),

[R] LMER - generate data and define model (2 fixed effects and 1 random effect or 1 fixed effect and 2 random effects)

2015-08-10 Thread Rosa Oliveira
### # Clear memory and set the working directory and the seed ### rm(list = ls()) setwd("/Dropbox/LMER/R ") set.seed(7010) ###

Re: [R] Unable to pass Object Arguments to UniRoot()

2015-08-10 Thread Bert Gunter
?? ?uniroot tells you exactly what uniroot() expects as arguments. Unless I misunderstand, your query seems totally unrelated to the way uniroot() works. Also, stop posting to Nabble and post to this (plain text) list. We have no idea of what the Nabble contexts are, and many of us won't even bot

Re: [R] Is there a R function for the nonparametric Walsh Test?

2015-08-10 Thread Rolf Turner
On 11/08/15 11:26, Dr. Thomas W. MacFarland wrote: Everyone: I am currently trying to reproduce the nonparametric Walsh Test, as presented in Siegel (1956, pp. 83-87), and unfortunately I cannot find a R function for this test. I would certainly appreciate any pointers for the Walsh Test using

[R] Is there a R function for the nonparametric Walsh Test?

2015-08-10 Thread Dr. Thomas W. MacFarland
Everyone: I am currently trying to reproduce the nonparametric Walsh Test, as presented in Siegel (1956, pp. 83-87), and unfortunately I cannot find a R function for this test. I would certainly appreciate any pointers for the Walsh Test using R, or perhaps a reasonable substitute if there is

Re: [R] add an idx column to the matrix

2015-08-10 Thread Thierry Onkelinx
Dear Lida, Here is a solution. Please don't post in HTML. And provide an easy to use example of the data. E.g. the output of dput(mydata) set.seed(1234) mydata <- matrix( sample( c(0, 1, 2, NA), size = 30, replace = TRUE, prob = c(2, 1, 1, 1) ), ncol = 6 ) idx <- apply(myda

Re: [R] add an idx column to the matrix

2015-08-10 Thread Sarah Goslee
Easy enough (note that your column names are problematic, though) > mydata <- structure(list(X125 = c(0L, 1L, 2L, 0L, 2L), X255 = c(1L, 1L, + 1L, 1L, 0L), X558 = c(0L, 0L, 2L, 0L, 0L), X2366 = c(NA, NA, + 1L, NA, 0L), X177 = c(0L, 0L, 0L, 0L, 0L), X255.1 = c(0L, 1L, + 0L, 0L, 0L)), .Names = c("X12

[R] add an idx column to the matrix

2015-08-10 Thread Lida Zeighami
Hi there, I have a matrix contain 0,1,2, NA elements. I want to add a column to this matrix with name of "idx" . then for each row, I should put 1 in this column (idx) if there is at least one 2 in that row otherwise I should put 0 in this column! for example mydata: 125 255 558 23

[R] How to 2d cross sections from a 3d finite element mesh

2015-08-10 Thread Waichler, Scott R
Hi, I have a 3D finite element mesh where each element (cell) is defined by 8 vertices. Each element is a regular polyhedron. The overall domain is a block in shape, but its horizontal principal axes are not coincident with x and y (i.e. the domain is rotated about the z-axis). I want to pl

Re: [R] accessing confidence interval values from the 'predict' function

2015-08-10 Thread Adams, Jean
Avril, The more direct way to access these columns from the matrix is: ci[, "lwr"] ci[, "upr"] Jean On Mon, Aug 10, 2015 at 3:20 AM, alc wrote: > > > Dear all, > > I'm wondering how can I access the confidence interval values ('upr' and > 'lwr' values) produced by the 'predict' function. For

Re: [R] inbuilt crossover function for backtesting

2015-08-10 Thread Joshua Ulrich
On Mon, Aug 10, 2015 at 11:02 AM, boredstoog via R-help wrote: > Thanks Joshua for the quick reply to the mail and once more sorry for > bothering with another doubt. So i have modified your code :) for > backtesting and this is the code > > * > library(quantmod) > library(tseries) > require(quant

Re: [R] inbuilt crossover function for backtesting

2015-08-10 Thread boredstoog via R-help
Thanks Joshua for the quick reply to the mail and once more sorry for bothering with another doubt. So i have modified your code :) for backtesting and this is the code * library(quantmod) library(tseries) require(quantstrat) library(PerformanceAnalytics) sym <- get(getSymbols('SPY'))["2013::"] sy

Re: [R] result NA , but expected True or False

2015-08-10 Thread William Dunlap
The || operator will always return a result of type 'logical' and length 1. You gave it two operands of length 0, so it returned the logical value NA, meaning it had no idea what the result should be. If you give it operands of length > 1, it will use the only the first elements of them. (S and S

Re: [R] Reading Json data

2015-08-10 Thread Mark Sharp
Mayukh, I apologize for taking so long to get back to your problem. I expect you may have found the solution. If so I would be interested. I have developed a hack to solve the problem, but I expect if someone knew how to handle JSON objects or even text parsing better they could develop a more

[R] Revolutions blog roundup: July 2015

2015-08-10 Thread David Smith
Since 2008, Revolution Analytics (and now Microsoft) staff and guests have written about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you mi

[R] Bootstrapped CIs of R-squared for ordinal regression

2015-08-10 Thread varin sacha
Dear R-Experts, I am trying to get the bootstrapped confidence intervals of R-squared (Nagelkerke) for an ordinal logistic regression. Something is going wrong at the end of my script. Many thanks for your help. Here is my reproducible example. install.packages("rms") library(rms) x=c(1,2,3,2

Re: [R] accessing confidence interval values from the 'predict' function

2015-08-10 Thread Michael Dewey
Dear Avril I think you will find that predict.lm returns a matrix not a data frame. I find str() useful when R does things I did not expect or quite understand. Michael On 10/08/2015 09:20, alc wrote: Dear all, I'm wondering how can I access the confidence interval values ('upr' and 'lwr'

Re: [R] Unable to pass Object Arguments to UniRoot()

2015-08-10 Thread Bazman76
Thanks Krishna! You are correct, but even when I manually add m<-17 just after x I still get the same error? Uniroot falls over when it tries to take in the argument MLEobj=fit, thus I think the error is occurring before LamOpt() gets called by uniroot(). Which is why the error you mentioned di

[R] Unable to pass Object Arguments to UniRoot()

2015-08-10 Thread Bazman76
Hi there, I'd like to be able to pass an entire object to uniroot() as one of the arguments. Unfortunately to recreate my precise error would be rather involved. So I present a simplified version below: To create a structured object let the output from the lm() function use this simple code:

[R] accessing confidence interval values from the 'predict' function

2015-08-10 Thread alc
Dear all, I'm wondering how can I access the confidence interval values ('upr' and 'lwr' values) produced by the 'predict' function. For example, I fitted a linear regression line using: fit <- lm(y ~ x) I then wanted to calculate a 95% confidence interval for the line, and did this using

Re: [R] Plotting wind direction as arrows with precipitation

2015-08-10 Thread Jeff Newmiller
I don't see any conversion of your time data from character to a time type, so it is probably converting to factor within the ggplot function. Something like Sys.setenv(TZ="Etc/GMT+5") # you need to study time types, including ?strptime Sandy$Deal1 <- as.POSIXct( Sandy$Deal1, format="%m/%d/%Y %H

[R] Setting R working directories on Windows - was RE: Why does R start in wrong working directory ...

2015-08-10 Thread S Ellison
> My preference is to start in different working directories depending on which > project I am working on. R_USER is not a project directory. One way to do that > is to double-click on an RData file located where you want to start. Saving an empty 'empty.RData' image in my project directories when

Re: [R] Why does R start in wrong working directory despite R_USER setting?

2015-08-10 Thread S Ellison
> >I would like the startup working directory to be that pointed to by > >R_USER. In Windows, right click on your R desktop shortcut (or create a new one pointing to Rgui.exe) and on the properties tab, change "Start in:" to %R_USER% R will then start 'in' the R_USER directory if R_USER exists (

[R] simultaneous equation model with endogenous interaction terms

2015-08-10 Thread Janka Vanschoenwinkel
Dear list members, I am building a model such as: Y1 = Y2*X1 + X2 Y2 = Y1*X1 + X2 X2 is the exogenous variable Z1 is the instrument of Y1 Z2 is the instrument of Y2 This is a simultaneous equation model. I know how to build a simultaneous equation model without interaction terms: library(syste

Re: [R] Data frame Q

2015-08-10 Thread PIKAL Petr
Hi Your question is without reproducible example and I find it a bit cryptic. You do not uncover what is i. If it is a number I wonder why your atempts fail. Find answer in line below. > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ragia > Ibrahim