Re: [R] Simple parallel for loop

2012-05-14 Thread R. Michael Weylandt
Perhaps mcmapply from the parallel package? It's a parallel mapply to complement mclapply. Michael On Tue, May 15, 2012 at 2:28 AM, Alaios wrote: > Thanks Michael, > last comment that I am trying to figure out, is that my called function has > two inputs arguments, while foreach looks to be work

Re: [R] Simple parallel for loop

2012-05-14 Thread Alaios
Thanks Michael, last comment that I am trying to figure out, is that my called function has two inputs arguments, while foreach looks to be working with only on one, being also able to execute one command while I need two. ReadDataSet (based on iteration number). Call PlotFunction(based on two i

Re: [R] Simple parallel for loop

2012-05-14 Thread R. Michael Weylandt
I haven't actually used foreach very much myself, but I would imagine that you could just take advantage of the fact that most plot functions return their arguments silently and then just throw the results away (i.e., don't assign them) Switching %do% to %dopar% automatically activates paralleliza

Re: [R] Simple parallel for loop

2012-05-14 Thread Alaios
Hello Michael, thanks for the answer, it looks like that the foreach package might do what I want. Few comments though The foreach loop asks for a way to combine results, which I do not want to have any. AFter I load a dataset the subsequent function does plotting and save the files as pdfs, no

Re: [R] How to Un-group a grouped data set?

2012-05-14 Thread R. Michael Weylandt
It is a nifty and surprisingly useful construct whenever you need to construct a function call programmatically or apply it to a list. R-News 2/2 has some useful tips on this and related functions in the Programmer's Note section if you're interested. Best, Michael On Tue, May 15, 2012 at 2:05 A

Re: [R] How to Un-group a grouped data set?

2012-05-14 Thread Cheenghee AM Koh
Thank you so much! I can't believe I spent the whole night by not knowing this one command "do.call" This is so handy! Best, Koh On Tue, May 15, 2012 at 12:52 AM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > Sorry -- I missed the bit about the AE in your original post. Perhaps > y

Re: [R] Simple parallel for loop

2012-05-14 Thread R. Michael Weylandt
Take a look at foreach() and %dopar$ from the CRAN package foreach. Michael On Tue, May 15, 2012 at 1:57 AM, Alaios wrote: > Dear all, > I am having a for loop that iterates a given number of measurements that I > would like to split over 16 available cores. The code is in the following > form

[R] Simple parallel for loop

2012-05-14 Thread Alaios
Dear all, I am having a for loop that iterates a given number of measurements that I would like to split over 16 available cores. The code is in the following format inputForFunction<-expand.grid(caseList,filterList) for (i in c(1:length(inputForFunction$Var1))){#       FileList<-GetFileList

Re: [R] How to Un-group a grouped data set?

2012-05-14 Thread R. Michael Weylandt
Sorry -- I missed the bit about the AE in your original post. Perhaps you can work with my bit for the repeats, but it looks like if you want to use your function, it should suffice to do something like do.call("rbind", lapply(NewFuncName, 1:6)) Best, Michael On Tue, May 15, 2012 at 1:50 AM, R.

Re: [R] How to Un-group a grouped data set?

2012-05-14 Thread R. Michael Weylandt
Don't use subset for a function name -- it's already the name of a rather important function as is data (but at least that one's not a function in your use so it's not quite so bad). Finally, use dput() when sending data so we get a plaintext reproducible version. I'd try something like this: dat

[R] How to Un-group a grouped data set?

2012-05-14 Thread Cheenghee AM Koh
Hello, R-fellows, I have a question that I really don't know how to solve. I have spent hours on line surfing for possible solutions but in veil. Please if anyone could help me handle this issue, you would be so appreciated! I have a "grouped" dataset like this: > data Study TX AEs N 1 1

Re: [R] how to create a new data given a vector of variable names

2012-05-14 Thread christy
oh, thank you very much! From: Michael Weylandt [via R] To: christy Sent: Tuesday, May 15, 2012 12:28 AM Subject: Re: how to create a new data given a vector of variable names I think you're making this too hard: x[, vars] should do it. For a smaller

Re: [R] how to create a new data given a vector of variable names

2012-05-14 Thread R. Michael Weylandt
I think you're making this too hard: x[, vars] should do it. For a smaller example, consider x <- data.frame(a = 1:5, b = rnorm(5), c = letters[1:5]) x[, c("b","a")] Best, Michael On Tue, May 15, 2012 at 1:12 AM, christy wrote: > hi, please help me on this. I'm very new to R.  I've been fig

Re: [R] Inf and lazy evaluation

2012-05-14 Thread R. Michael Weylandt
The only place I know lazy evaluation really is visible and widely used is in the passing of function arguments. It's what allows magic like zz <- 1:5 plot(zz) to know your variable was called "zz." It can also show up in some places through the promise mechanism, but you have to do a little bit

Re: [R] how to create a new data given a vector of variable names

2012-05-14 Thread Jorge I Velez
Hi Christy, Try either of the following subset(x, select = vars) x[, vars] HTH, Jorge.- On Tue, May 15, 2012 at 1:12 AM, christy < >wrote: > hi, please help me on this. I'm very new to R. I've been figuring out how > to > do this the whole day, and I could not get the correct R code. > > Sup

[R] how to create a new data given a vector of variable names

2012-05-14 Thread christy
hi, please help me on this. I'm very new to R. I've been figuring out how to do this the whole day, and I could not get the correct R code. Suppose I have a dataframe called x and it consists of 10variables. >x h 1h 2h 3 h 4h 5h 6 h 7

[R] OpenStreetMap Library

2012-05-14 Thread Pierre-Olivier Chasset
Hello, I am trying to use the OpenStreetMap library on Mac OS X Lion with Java 6 & 7. Loading the library is not a problem: > library("OpenStreetMap") Le chargement a nécessité le package : rJava Le chargement a nécessité le package : sp Le chargement a nécessité le package : maptools Le chargeme

Re: [R] package rgl not installing on Mac OS X

2012-05-14 Thread Duncan Murdoch
On 14/05/2012 6:12 PM, Brenda McCowan wrote: This is what I am getting: install.packages("rgl") Installing package(s) into Œ/Users/brenda/Library/R/2.15/library¹ (as Œlib¹ is unspecified) trying URL 'http://cran.cnr.Berkeley.edu/bin/macosx/leopard/contrib/2.15/rgl_0.92.880.t gz' Content type '

Re: [R] Scraping a web page.

2012-05-14 Thread J Toll
On Mon, May 14, 2012 at 4:17 PM, Keith Weintraub wrote: > Folks, >  I want to scrape a series of web-page sources for strings like the following: > > "/en/Ships/A-8605507.html" > "/en/Ships/Aalborg-8122830.html" > > which appear in an href inside an tag inside a tag inside a table. > > In fact a

Re: [R] Interpreting Q-Q Plots

2012-05-14 Thread S Ellison
>And since I don't have the experience, the only way to gain it is by > learning from those with practice reading chicken entrails. This can be hard on the chicken population. Try comparing QQ plots for simulated random data from different distributions with something more immediately interp

Re: [R] package ‘adehabitat’ is not available (for R version 2.15.0) on Mac OS X

2012-05-14 Thread David Winsemius
On May 14, 2012, at 5:44 PM, Kristi Glover wrote: Hi R- User,I tried to load package adehabitat for R version 2.15.0. But, I got error. even I download and save in local drive and tried to install from the local file. but still i got the following errors install.packages("adehabitat", re

Re: [R] Interpreting Q-Q Plots

2012-05-14 Thread Rich Shepard
On Tue, 15 May 2012, Peter Alspach wrote: Probably highly skewed to the right, with discrete values (perhaps due to the limitations in the accuracy of the assessment equipment). Peter, Most of these data are near zero or the lower detection limit. A few values are very much higher. I didn't

Re: [R] Error in names(x) <- value: 'names' attribute must be the same length as the vector

2012-05-14 Thread David Winsemius
On May 14, 2012, at 2:35 PM, Priya Bhatt wrote: Dear R-helpers, I am stuck on an error in R: When I run my code (below), I get this error back: Error in names(x) <- value : 'names' attribute must be the same length as the vector Then when I use traceback(), R gives me back this in retu

[R] package rgl not installing on Mac OS X

2012-05-14 Thread Brenda McCowan
This is what I am getting: > install.packages("rgl") Installing package(s) into Œ/Users/brenda/Library/R/2.15/library¹ (as Œlib¹ is unspecified) trying URL 'http://cran.cnr.Berkeley.edu/bin/macosx/leopard/contrib/2.15/rgl_0.92.880.t gz' Content type 'application/x-gzip' length 10757858 bytes (10.

Re: [R] Interpreting Q-Q Plots

2012-05-14 Thread Peter Alspach
Tena koe Rich Probably highly skewed to the right, with discrete values (perhaps due to the limitations in the accuracy of the assessment equipment). But note: library(fortunes) fortune('chicken') HTH . Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r

Re: [R] package ‘adehabitat’ is not available (for R version 2.15.0) on Mac OS X

2012-05-14 Thread Steve Lianoglou
Hi, Did you simply try: install.packages("adehabitat") or, if that doesn't work, maybe: install.packages("adehabitat", type="source") Or change your cran mirror? -steve On Mon, May 14, 2012 at 5:44 PM, Kristi Glover wrote: > > Hi R- User,I tried to load package adehabitat for R version 2.15

[R] Interpreting Q-Q Plots

2012-05-14 Thread Rich Shepard
My understanding of Q-Q plots is that if the tails of the plotted points fall above or below the x=y line the distribution of observed/measured values is under or over dispersed. But, how do I interpret measured values that are in horizontal lines? The attached plot illustrates this situation.

[R] package ‘adehabitat’ is not available (for R version 2.15.0) on Mac OS X

2012-05-14 Thread Kristi Glover
Hi R- User,I tried to load package adehabitat for R version 2.15.0. But, I got error. even I download and save in local drive and tried to install from the local file. but still i got the following errors install.packages("adehabitat", repos='C:/adehabitat_1.8.10.tgz') package ‘adehabitat’ i

Re: [R] select data

2012-05-14 Thread S Ellison
> From: David L Carlson [dcarl...@tamu.edu] >This overwrites the data so you might want to create a copy first. > > example <- data.frame(V1=c(3, -1), V2=c(-2, 4), V3=c(4, 1)) > tf <- ifelse(example<0, TRUE, FALSE) > example[tf] <- NA > apply(example, 1,

Re: [R] write data using xlsReadWrite

2012-05-14 Thread Ethan Brown
You're trying to write an object that you've never created. If you want to write `varHL2y`, which it appears you do, you would replace that for `mydata` in your command. Best, Ethan On Sun, May 13, 2012 at 1:33 AM, diyanah wrote: > Hai, I'm trying to write these var output data from these codes

Re: [R] determine size (width and height) of a graphics file via R - how?

2012-05-14 Thread Ethan Brown
Hi Mark, You can do this easily with the "identify" command in ImageMagick . Install it, and then from within an R session: system2("identify", "yourimagename.jpg") ...and it should give you something like this: yourimagename.jpg JPEG 800x533 800x533+0+0 8-bit Direct

[R] Scraping a web page.

2012-05-14 Thread Keith Weintraub
Folks, I want to scrape a series of web-page sources for strings like the following: "/en/Ships/A-8605507.html" "/en/Ships/Aalborg-8122830.html" which appear in an href inside an tag inside a tag inside a table. In fact all I want is the (exactly) 7-digit number before ".html". The good new

Re: [R] Plot

2012-05-14 Thread Tyler Rinker
I noticed I was remiss in addressing your origin question: Use the xlim and ylim, setting the lower limit to 0.  Here's an example of this with the CO2 dataset: plot(uptake~Plant, data=CO2) plot(uptake~as.numeric(Plant), data=CO2) plot(uptake~as.numeric(Plant), data=CO2, ylim=c(0, 50), xlim

Re: [R] Error in names(x) <- value: 'names' attribute must be the same length as the vector

2012-05-14 Thread Tyler Rinker
I'd throw a browser() in at that point and see what colnames(newdf.int) gives you.  If you have less columns than names this is likely the reason for the error. You can get the same error with: colnames(mtcars) <- LETTERS Cheers,Tyler > Date: Mon, 14 M

Re: [R] Aligning time series

2012-05-14 Thread Matthew Johnson
Very useful, however as i will be aligning large datasets, is it possible to query a variable for the lead / lag for each series? So i can more 'automatically' align? ideally the lag is stored in d$align or something Best mj Sent from my iPad On 14/05/2012, at 9:36 PM, Gabor Grothendieck wrot

Re: [R] Plot

2012-05-14 Thread Tyler Rinker
That is likely because ferm is a factor.  A scatterplot is two numeric variables.  To make it a scatterplot wrap ferm with as.numeric.  Cheers, Tyler Date: Mon, 14 May 2012 12:21:12 -0700 From: kellycoo...@yahoo.com To: r-help@r-project.org Subject: [R] P

Re: [R] Inf and lazy evaluation

2012-05-14 Thread J Toll
Thank you all for the replies. On Mon, May 14, 2012 at 2:45 PM, R. Michael Weylandt wrote: > R is lazy, but not quite that lazy ;-) Oh, what is this world coming to when you can't count on laziness to be lazy. ;) I should probably stop reading about Haskell and their lazy way of doing things.

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread William Dunlap
Yes, package:intervals uses the same idiom as my code. Mine allows Date and POSIXct objects as interval endpoints (which is why it represents the objects as data.frames instead of matrices). package:intervals has more than basic set opertions on the collections of intervals. Bill Dunlap Spotfire,

Re: [R] Help with V function in igraph

2012-05-14 Thread bmccowan
Thank for your response. It is oddly working now. Thanks again, Brenda On 5/14/12 10:36 AM, "Gábor Csárdi-2 [via R]" wrote: > Something weird must be going on in your s641_social object. Can you just > simply check that the vertex names look OK with 'V(s641_social)$name'? If they > look go

[R] Error in names(x) <- value: 'names' attribute must be the same length as the vector

2012-05-14 Thread Priya Bhatt
Dear R-helpers, I am stuck on an error in R: When I run my code (below), I get this error back: Error in names(x) <- value : 'names' attribute must be the same length as the vector Then when I use traceback(), R gives me back this in return: `colnames<-`(`*tmp*`, value = c(""Item", "Color"

[R] Plot

2012-05-14 Thread Kelly Cool
Hello, I am trying to make a plot of the rates of an enzyme against three different protein concentrations (there are 45 rates in total and split up into 3 groups of 15, each receiving one of the 3 protein concentrations). When I enter the following code I instead get 3 separate boxplots for ea

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread Ben quant
Thank you Steve! This does everything I need (at this point): (this excludes ranges y2 from range y1) library('intervals') y1 = Intervals(c(-100,100)) y2 = Intervals(rbind( c(-100.5,30), c(0.77,10), c(25,35), c(70,80.3), c(90,95) )) interval_difference(y1,y2) Object of class Interval

Re: [R] Inf and lazy evaluation

2012-05-14 Thread R. Michael Weylandt
R is lazy, but not quite that lazy ;-) It's likely much easier to do this with regexps something like list.files()[grepl(paste0(filename, "-"[0123456789]+""), list.files())] Michael On Mon, May 14, 2012 at 3:34 PM, J Toll wrote: > Hi, > > I have a question involving Inf, lazy evaluation, and

Re: [R] Inf and lazy evaluation

2012-05-14 Thread Bert Gunter
?list.files -- Bert On Mon, May 14, 2012 at 12:34 PM, J Toll wrote: > Hi, > > I have a question involving Inf, lazy evaluation, and maybe argument > recycling.  I have a directory where I am trying to check for the > existence of files of a certain pattern, basically something like > "filename-

[R] Inf and lazy evaluation

2012-05-14 Thread J Toll
Hi, I have a question involving Inf, lazy evaluation, and maybe argument recycling. I have a directory where I am trying to check for the existence of files of a certain pattern, basically something like "filename-#", where # is an integer. I can do something like this, which works. file.exists

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread Steve Lianoglou
Hi all, Nice code samples presented all around. Just wanted to point out that I think the stuff found in the `intervals` package might also be helpful: http://cran.at.r-project.org/web/packages/intervals/index.html HTH, -steve On Mon, May 14, 2012 at 2:54 PM, Ben quant wrote: > Yes, it is. I'

Re: [R] Random forests prediction

2012-05-14 Thread Liaw, Andy
That's not how RF works at all. The setting of mtry is irrelevant to this. Andy -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of matt Sent: Monday, May 14, 2012 10:22 AM To: r-help@r-project.org Subject: Re: [R] Random forests pre

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread Ben quant
Yes, it is. I'm looking into understanding this now... thanks! Ben On Mon, May 14, 2012 at 12:38 PM, William Dunlap wrote: > To the list of function I sent, add another that converts a list of > intervals > into a Ranges object: > as.Ranges.list <- function (x, ...) { > stopifnot(nargs()

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread William Dunlap
To the list of function I sent, add another that converts a list of intervals into a Ranges object: as.Ranges.list <- function (x, ...) { stopifnot(nargs() == 1, all(vapply(x, length, 0) == 2)) # use c() instead of unlist() because c() doesn't mangle POSIXct and Date objects x

Re: [R] as.function parameters

2012-05-14 Thread David Winsemius
On May 14, 2012, at 1:56 PM, jackl wrote: Hi, ~ well that seems to be a better solution. Question is how much an enviroment for each node costs in terms of save space.. Seems unlike that it would expand you space very much. Every function you create will have an environment. The exampl

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread Ben quant
Turns out this solution doesn't work if the s range is outside the range of the x range. I didn't include that in my examples, but it is something I have to deal with quite often. For example s1_rng below causes an issue: x_rng = c(-100,100) s1_rng = c(-250.5,30) s2_rng = c(0.77,10) s3_rng = c(25

Re: [R] as.function parameters

2012-05-14 Thread jackl
Hi, ~ well that seems to be a better solution. Question is how much an enviroment for each node costs in terms of save space.. The example code is hard to present, because it is really based on that problem. The frame of the problem is, that I have to write a program that gives each node in a b

Re: [R] rgl: cylinder3d() with elliptical cross-section

2012-05-14 Thread Duncan Murdoch
On 10/03/2012 9:44 AM, Duncan Murdoch wrote: My first reply to this went privately, by accident. I've done a little editing to it, but mainly this is for the archives. On 12-03-09 2:36 PM, Michael Friendly wrote: > For a paper dealing with generalized ellipsoids, I want to illustrate in > 3D

Re: [R] New to R

2012-05-14 Thread Sarah Goslee
Hi, On Mon, May 14, 2012 at 12:44 PM, Bert Gunter wrote: > I usually try google searches first. While not always successful, I am > frequently surprised by how well it does. rseek.org is simply a custom Google search for R-related things. It does an even better job pulling out only R-related mat

Re: [R] Discrete choice model maximum likelihood estimation

2012-05-14 Thread Berend Hasselman
See below. On 14-05-2012, at 13:21, infinitehorizon wrote: > Hello again, > > I changed the name to tt. > and for a and tt actually I was getting them from data, I didn't put them > here in the question. Now I restructured my code and below I copy the full > code, I tried many things but still

Re: [R] How to apply a function to a multidimensional array based on its indices

2012-05-14 Thread David Winsemius
On May 14, 2012, at 10:09 AM, math_daddy wrote: Hello. I have a 4 dimensional array and I want to fill in the slots with values which are a function of the inputs. Through searching the forums here I found that the function "outer" is helpful for 2x2 matrices but cannot be applied to gener

Re: [R] select data

2012-05-14 Thread David L Carlson
This overwrites the data so you might want to create a copy first. example <- data.frame(V1=c(3, -1), V2=c(-2, 4), V3=c(4, 1)) tf <- ifelse(example<0, TRUE, FALSE) example[tf] <- NA apply(example, 1, mean, na.rm=TRUE) -- David L Carlson Associate Profes

Re: [R] Help with V function in igraph

2012-05-14 Thread Gábor Csárdi
Something weird must be going on in your s641_social object. Can you just simply check that the vertex names look OK with 'V(s641_social)$name'? If they look good, then can you send me the s641_social object in private? (Or part of it, assuming a part is enough to reproduce the problem.) Best, Ga

Re: [R] New to R

2012-05-14 Thread Bert Gunter
I usually try google searches first. While not always successful, I am frequently surprised by how well it does. I strongly second the use of CRAN task views. IMHO, some fine folks have volunteered their time and efforts to produce this very well written series of guides to what's in R. It and the

[R] using rcom to control Power Point - problem to set a property

2012-05-14 Thread Mark Heckmann
Hi all, I try to convert the VBA code below to run it from R using rcom and Power Point. The VBA code creates a shape and will move the handle of the the shape to another position. This fails using rcom and I do not understand what I am doing wrong... ### VBA ### ActiveWindow.Selection.SlideRan

Re: [R] Discrete choice model maximum likelihood estimation

2012-05-14 Thread infinitehorizon
Of course, that was the trick! It works now. Thank you very much Rui, I am very grateful. I hope this thread will help others as well. Best, Rui Barradas wrote > > Once again, sorry. > I had a different llfn in my R session and it messed with yours. > > llfn <- function(param, a, tt) { > >

Re: [R] Data read as labels

2012-05-14 Thread David Winsemius
On May 14, 2012, at 11:23 AM, barb wrote: Hey David, thanks for your fast reply, i really appreciate that you answer so many posts. Unfortunately it´s not that easy. Try to operate with the output: e.g file<-read.csv2(tmp,sep=";",skip="5") a<-(relevant<-file[,2][1]) a*5 # or as.numeric(re

Re: [R] How to apply a function to a multidimensional array based on its indices

2012-05-14 Thread Rui Barradas
Hello, Try K <- array(0,dim=c(2,2,2,2)) #dimensions will be much larger for(x1 in 1:2){ for(y1 in 1:2) { for(x2 in 1:2){ for(y2 in 1:2) { K[x1,y1,x2,y2] <- x1*y2 - sin(x2*y1) #this is just a dummy function. } } } } fun <- function(x){ x1 <- x

Re: [R] select data

2012-05-14 Thread Andrea Sica
Thank you all. Really! I have used the following function: apply(dfrm, 1, function(x) mean(x[x>=0]) ) Someone of you even gave me a few interesting explanations about why to use it. Still thank you all. Andrea On Mon, May 14, 2012 at 6:52 PM, David Winsemius wrote: > > On May 14, 2012, at 12:

Re: [R] Discrete choice model maximum likelihood estimation

2012-05-14 Thread Rui Barradas
Once again, sorry. I had a different llfn in my R session and it messed with yours. llfn <- function(param, a, tt) { llfn <- sum((a==1)*lL1+(a==2)*lL2+(a==3)*lL3) # sum of logs, it's a log-likelihood. return(-llfn) } Rui Barradas infinitehorizon wrote > > Hello again, > > You are absolutely

Re: [R] select data

2012-05-14 Thread David Winsemius
On May 14, 2012, at 12:32 PM, Andrea Sica wrote: Dear all, I am sure it won't be difficult for you!! I need to calculate the average among variables for the single units of my dataset. But, while doing it, I need to do not consider some values. To better explain, think like there are two un

Re: [R] Data read as labels

2012-05-14 Thread Krzysztof Mitko
On Mon, May 14, 2012, at 02:33, barb wrote: > Hey guys, > > i have a strange problem reading a .csv file. > Seems not to be covered by the usual read.csv techniques. > > The relevant data i want to use, seems to be saved as the label of the > data > point. > Therefore i can not really use it

[R] How to apply a function to a multidimensional array based on its indices

2012-05-14 Thread math_daddy
Hello. I have a 4 dimensional array and I want to fill in the slots with values which are a function of the inputs. Through searching the forums here I found that the function "outer" is helpful for 2x2 matrices but cannot be applied to general multidimensional arrays. Is there anything which can a

Re: [R] select data

2012-05-14 Thread R. Michael Weylandt
This was actually discussed about a week and a half ago with many good solutions offered, but I think the most idiomatic would be something like this: apply(dataset, 1, function(x) mean(x[x>0])) The reasons I like it: i) It uses the apply function to do the same operation row-wise (that's what t

Re: [R] Discrete choice model maximum likelihood estimation

2012-05-14 Thread Rui Barradas
Hello, again. Bug report: 1. Your densities can return negative values, 1 - exp(...) < 0. Shouldn't those be 1 PLUS exp()? P3 <- function(bx,b3,b,tt) { P <- exp(bx*x+b3+b*(tt == 1))/(1+exp(bx*x+b3+b*(tt == 1))) return(P) } And the same for P2 and P1? 2. Include 'a' and 'tt'

Re: [R] Discrete choice model maximum likelihood estimation

2012-05-14 Thread infinitehorizon
Hello again, You are absolutely right about probabilities.. Thanks for reminding me about that. I did exactly how you said but in the end I receive the error : "objective function in optim evaluates to length 12 not 1". I checked how llfn give a vector instead of scalar, but couldn't figure it o

Re: [R] Extract Variance Components

2012-05-14 Thread robgriffin247
Well, I'm going to reply to my own thread with a solution here, turns out one attempt we made last week nearly had it, slight adjustment made it work. For anyone that is interested / in the future wants to achieve the same thing > *varcomp <- matrix(nrow=0, ncol=3) for (i in 1:nlevels(na

Re: [R] Data read as labels

2012-05-14 Thread barb
Hey David, thanks for your fast reply, i really appreciate that you answer so many posts. Unfortunately it´s not that easy. Try to operate with the output: e.g file<-read.csv2(tmp,sep=";",skip="5") a<-(relevant<-file[,2][1]) a*5 # or as.numeric(relevant<-file[,2][1]) a is saved in the worksp

Re: [R] Random forests prediction

2012-05-14 Thread matt
But shouldn't it be resolved when I set mtry to the maximum number of variables? Then the model explores all the variables for the next step, so it will still be able to find the better ones? And then in the later steps it could use the (less important) variables. Matthijs -- View this message i

Re: [R] Discrete choice model maximum likelihood estimation

2012-05-14 Thread infinitehorizon
By the way, in my last post I forgot to return negative of llfn, hence the llfn will be as follows: llfn <- function(param) { bx <- param[1] b1 <- param[2] b2 <- param[3] b3 <- param[4] b <- param[5] lL1 <- log(L1(bx,b1,b2,b,tt)) lL2 <- log(L2(bx,b1,b2,b3,b,tt)) lL3 <- log(L3(bx,b1,b2,b3

Re: [R] Post stratification weights in survey package in R

2012-05-14 Thread Thomas Lumley
On Sun, May 13, 2012 at 7:10 PM, Ruijie wrote: > Hi all, > > I have data collected from a survey administered on a subset of the > population. I also have the population proportions of variables such as > gender, race and housing type. I would like to combine the weights from > each separate cross

Re: [R] New to R

2012-05-14 Thread David L Carlson
You will find functions such as these in the thousands of packages that are available once you have installed R. You can use rseek.org to search for specific topics. Good overviews are found in the CRAN Task Views (from the main R webpage, click on CRAN, select a mirror host, and then select Task V

[R] select data

2012-05-14 Thread Andrea Sica
Dear all, I am sure it won't be difficult for you!! I need to calculate the average among variables for the single units of my dataset. But, while doing it, I need to do not consider some values. To better explain, think like there are two units and three variables: V1V2 V3 [1] 3

Re: [R] How do I do group wise clustering in R?

2012-05-14 Thread David L Carlson
Look at the aggregate function to create a new data.frame in which you have M rows that have the means of the K variables for each group. Then use cluster analysis to cluster the M groups. -- David L Carlson Associate Professor of Anthropology Texas A&M

Re: [R] how to write data using xlsReadWrite

2012-05-14 Thread David L Carlson
You didn't tell us what your problem is, but it probably relates to the fact that mydata is never defined. -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-

Re: [R] Help with writing data to csv

2012-05-14 Thread David L Carlson
If you have a data.frame and you want a table in Microsoft Word, the quickest path (without additional packages and assuming you are using Windows) is write.table(DataFrameName, file="clipboard", sep="\t", row.names=FALSE) # If the file is large, you may need "clipboard-128" instead of "clipboard.

[R] New version of cloudRmpi

2012-05-14 Thread Barnet Wagman
cloudRmpi v 1.2 is now available on CRAN. cloudRmpi is a means for doing parallel processing in R, using MPI on a cloud-based network. It currently supports the use of Amazon's EC2 cloud computer service. Changes in v 1.2: Support for RStudio. RStudio Server is available on new AMIs. cloud

[R] glmnet speed

2012-05-14 Thread yan
I'm using glmnet for logistic regression, I got a fairly sparse dataset, 20,000 samples(very imbalanced too, 5% from one group), 1500 variables,. the code have beed running for 2 hours, still waiting for result, I am doing lasso here(alpha=1), my computer is core 2 due CPU @3Ghz, 4GB ram, why it's

Re: [R] No Data in randomForest predict

2012-05-14 Thread Liaw, Andy
It doesn't: You just get an error if there are NAs in the data; e.g., R> rf1 = randomForest(iris[1:4], iris[[5]]) R> predict(rf1, newdata=data.frame(Sepal.Length=1, Sepal.Width=2, Petal.Length=3, Petal.Width=NA)) Error in predict.randomForest(rf1, newdata = data.frame(Sepal.Length = 1, : mis

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread Ben quant
Great solution! Thanks! Ben On Sat, May 12, 2012 at 12:50 PM, jim holtman wrote: > Here is an example of how you might do it. It uses a technique of > counting how many items are in a queue based on their arrival times; > it can be used to also find areas of overlap. > > Note that it would be

Re: [R] Data read as labels

2012-05-14 Thread David Winsemius
On May 14, 2012, at 5:33 AM, barb wrote: Hey guys, i have a strange problem reading a .csv file. Seems not to be covered by the usual read.csv techniques. The relevant data i want to use, seems to be saved as the label of the data point. Therefore i can not really use it spec<-"EU2001" p

Re: [R] range segment exclusion using range endpoints

2012-05-14 Thread Ben quant
Wow, I'll have to study this one for a bit. Thanks! Ben On Sat, May 12, 2012 at 3:09 PM, William Dunlap wrote: > Here is some code that I've been fiddling with for years > (since I wanted to provide evidence that our main office > needed more modems and wanted to show how often > both of them w

[R] phyloclim could not be installed in linux - problems on tkrplot dependence

2012-05-14 Thread Mao Jianfeng
Dear R-helpers, Christoph (author of phyloclim) and Luke (author of tkrplot), I would like to get your helps on installing of phyloclim in Ubuntu linux. It seems a package named 'tkrplot' could not be installed at firstly, then packages depends on it could not be installed latter. As I have teste

Re: [R] file path

2012-05-14 Thread David Winsemius
On May 14, 2012, at 6:35 AM, Berend Hasselman wrote: On 14-05-2012, at 12:07, Wincent wrote: Emm, my bad. I meant str <- "abc\d". Any ideas? gsub("", "", str) #1: One cannot execute: str <- "abc\d" , at least on my machine, since that throws an error because "\d" is an "unrecogn

[R] ggplot2: Dendrogram text position

2012-05-14 Thread Brian Smith
Hi, I was trying to create a dendrogram using ggplot2. Everything seems to be looking ok except that the text labels are too close to the dendrogram (in the example below, 'a','b', ..). Is there a way that I can put a little gap between where the dendrogram ends and the label begins? thanks!! ==

Re: [R] To summary data

2012-05-14 Thread John Kane
One way is to use the reshape2 package === library(reshape2) dcast(xx, A ~ . , sum) John Kane Kingston ON Canada > -Original Message- > From: mrzun...@gmail.com > Sent: Sun, 13 May 2012 22:14:02 -0700 (PDT) > To: r-help@r-proj

Re: [R] Add column from other columns data.

2012-05-14 Thread Yellow
That worked. Thanks. :) -- View this message in context: http://r.789695.n4.nabble.com/Add-column-from-other-columns-data-tp4629921p4629937.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://sta

Re: [R] Random forests prediction

2012-05-14 Thread Liaw, Andy
I don't think this is so hard to explain. If you evaluate AUC using either OOB prediction or on a test set (or something like CV or bootstrap), that would be what I expect for most data. When you add more variables (that are, say, less informative) to a model, the model has to look harder to f

Re: [R] Add column from other columns data.

2012-05-14 Thread John Kane
Something along the lines of dat2 <- ifelse( dat1==1 , "yes", "no") should do it. John Kane Kingston ON Canada > -Original Message- > From: s1010...@student.hsleiden.nl > Sent: Mon, 14 May 2012 05:45:38 -0700 (PDT) > To: r-help@r-project.org > Subject: [R] Add column from other colu

[R] How do I do group wise clustering in R?

2012-05-14 Thread Luna
How do I do group wise clustering in R? Hi all, I have N x K data matrix, where N is the number of observations, K is the number of variables. The N observations fall into M categories or groups. Now I want to cluster the groups, instead of the observations, how do I do that? i.e. the clusteri

Re: [R] Why can we combine design matrix and data-frame in R?

2012-05-14 Thread Michael
Oh, so we can always combine model matrices and formulas in regression in R? Thanks! On Mon, May 14, 2012 at 2:41 AM, peter dalgaard wrote: > > On May 14, 2012, at 02:24 , Luna wrote: > > > Thanks! > > > > Do you think if the correctness of the such results could be generalized > to > > other f

[R] Rjava on Ubuntu quantal

2012-05-14 Thread Hasan Diwan
I just upgraded to Ubuntu Quantal from Precise and RJava stopped working, log follows: 0}% /usr/bin/find $HOME/workspace/FinanceOCR/visualizations/ -name '*R' -print | /usr/bin/xargs -n 1 -i% /usr/bin/Rscript % $1 [~] Loading required package: RJDBC Loading required package: methods Loading require

Re: [R] Add column from other columns data.

2012-05-14 Thread Sarah Goslee
Assuming you actually have a data frame or matrix, and not a csv file, ifelse() is the general solution to your problem. Sarah On May 14, 2012, at 8:45 AM, Yellow wrote: > Hi everyone, > > I am having some problems with making a new colomn wit data in it. > I have this one column named: Ful

Re: [R] rollmax.zoo : column names NULL

2012-05-14 Thread Achim Zeileis
Giles, thanks for the bug report: I am comparing the output of rollmax in two versions of R. In the current version, the column names are 'lost' ie NULL in the output; in the earlier version they were retained. Yes, this was an error. I just fixed it in the devel version on R-Forge. Thanks,

Re: [R] Calculating all possible ratios

2012-05-14 Thread genome1976
Hi Rui, Thanks once again for all the help. I need to ask for one more help from you. I have two matrices, with probesets as rows and samples as columns. The samples in the two matrices are matched (from the same animal but two different tissues). I want to create a correlation matrix of sample

  1   2   >