[R] choose(n, k) as n approaches k

2020-01-14 Thread Wright, Erik Scott
This struck me as incorrect: > choose(3.99, 4) [1] 0.979 > choose(3.999, 4) [1] 0 > choose(4, 4) [1] 1 > choose(4.001, 4) [1] 4 > choose(4.01, 4) [1] 1.02 Should base::choose(n, k) check whether n is within machine precision of k and return 1

[R] as(, "numeric") vs as.numeric()

2016-02-01 Thread Erik Wright
"Methods are pre-defined for coercing any object to one of the basic datatypes. For example, as(x, "numeric") uses the existing as.numeric function." Thanks, Erik __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https:

Re: [R] as(, "numeric") vs as.numeric()

2016-02-01 Thread Erik Wright
umeric function." But clearly the result is different in each case. If the help for as() is correct, then as(1:10, "numeric") should also return doubles, and the second argument is not ignored. Erik > On Feb 1, 2016, at 8:16 AM, Franklin Bretschneider <brets...@xs4all.nl> w

[R] Trading Strategy and Bootstrap

2015-12-10 Thread Schiele, Erik
sma50.new)) chart.CumReturns(returns.new,s$sma50.new,geometric=F) Erik Schiele Vice President Money Markets Trading, Originations and Sales 101 Barclay St, NY NY 10007 3rd Floor BNY Mellon Capital Markets, LLC Main Desk 212-815-8222 This is for informational purposes only; from sources the Firm b

Re: [R] R Freezes (Mac) using file.choose()

2015-04-23 Thread Erik Duhaime
Hi, Did you ever get an answer about this? It has been so so frustrating for me... Thanks! On Sunday, March 22, 2015 at 11:29:28 PM UTC-4, Vindoggy ! wrote: I'm using a mac with OSX Yosemite (10.10.2), running the latest version of R (3.1.3). But I've been having this same issue since

[R] Calculate the median age interval

2015-01-12 Thread Erik B Svensson
-34,35-44,45-54,55-64,65-74,75-84,84-) y1994 - c(0,5,7,9,25,44,23,32,40,36,8) y1995 - c(2,4,1,7,20,39,32,18,21,23,5) y1996 - c(1,3,1,4,22,37,41,24,24,26,8) I look forward to your response Best regards, Erik Svensson [[alternative HTML version deleted

[R] Building R on RHEL 5

2012-01-20 Thread Erik Wright
this time around? Thanks in advance, Erik make output: ... gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 -I../../src/extra/pcre -I../../src/extra  -I../../src/extra/xz/api -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c vfonts.c -o vfonts.o

Re: [R] Keep ALL duplicate records

2011-10-03 Thread Erik Svensson
It worked, thank you Jim Erik -- View this message in context: http://r.789695.n4.nabble.com/Keep-ALL-duplicate-records-tp3865136p3867709.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https

Re: [R] Find all duplicate records

2011-10-03 Thread Erik Svensson
It works, thanks a lot Gabor Erik -- View this message in context: http://r.789695.n4.nabble.com/Find-all-duplicate-records-tp3865139p3867724.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https

[R] Find all duplicate records

2011-10-02 Thread Erik Svensson
FALSE i.e. not all user A records are found With unique(df$ID) [1] userA userB userC Levels: userA userB userC i.e. one of each ID is found --] Erik Svensson -- View this message in context: http://r.789695.n4.nabble.com/Find-all-duplicate-records-tp3865139p3865139.html Sent from the R help

[R] Non-negative least squares for sparse matrix

2011-07-14 Thread Erik Wright
, and matrix b is a dense 750,000 by 1 matrix. Does an R function exist for solving the non-negative least squares problem with a sparse matrix? Thanks!, Erik sessionInfo() R version 2.13.0 (2011-04-13) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/C/C

[R] RgoogleMaps Axes

2011-06-07 Thread Erik Gregory
no answer other than that I ought to contact the package maintainer.  Since it would be nice to have a publicly displayed solution, I opted to post here first before doing so.  Does anyone have any insight to share? Thank you very much for your time, -Erik Gregory CSU Sacramento, Mathematics

[R] draw text outside plot boundaries

2011-06-06 Thread Erik Aronesty
a bit. - erik __ 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, self-contained, reproducible code.

Re: [R] SAPPLY function XXXX

2011-05-04 Thread Erik Iverson
))) NB: none of this is tested! --Erik Ultimately, I would like for this to be 1 conponent in a larger function that will produce PROC CONTENTS style output. Something like... data1.contents-data.frame(Variable=names(data1), Class=sapply(data1,class), n.valid=sapply(data1,sum(!is.na)), n.miss

Re: [R] SAPPLY function XXXX

2011-05-04 Thread Erik Iverson
.contents Also meant to mention to see ?describe in the Hmisc package: E.g., describe(c(NA, 1:10)) There is also a useful method for data.frame objects. --Erik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] Where is the tcltk package?

2011-04-07 Thread Erik Iverson
Rolf, What does capabilities(tcltk) return? On 04/07/2011 07:15 PM, Rolf Turner wrote: Perhaps I'm being even thicker than usual, but I can't find the tcltk package on CRAN. There is a tcltk2 package, which says that it is a collection of supplements to tcltk, but I cannot see a just-plain

Re: [R] Where is the tcltk package?

2011-04-07 Thread Erik Iverson
On 04/07/2011 07:32 PM, Rolf Turner wrote: On 08/04/11 12:22, Erik Iverson wrote: Rolf, What does capabilities(tcltk) return? FALSE I believe R needs to be compiled with tcltk support for the package to work. Do you compile your own version or use a package manager (e.g., on Ubuntu

Re: [R] Where is the tcltk package?

2011-04-07 Thread Erik Iverson
On 04/07/2011 07:55 PM, Rolf Turner wrote: On 08/04/11 12:40, Erik Iverson wrote: On 04/07/2011 07:32 PM, Rolf Turner wrote: On 08/04/11 12:22, Erik Iverson wrote: Rolf, What does capabilities(tcltk) return? FALSE I believe R needs to be compiled with tcltk support for the package

Re: [R] Precision of summary() when summarizing variables in a data frame

2011-04-05 Thread Erik Iverson
jim holtman wrote: They are probably the same. It isjust that summary is printing out 4 significant digits. Try: options(digits = 20) FYI, the default summary method also has its own digits argument. On Tue, Apr 5, 2011 at 12:38 PM, Daniel Malter dan...@umd.edu wrote: Hi, I

Re: [R] Compare three or more values?

2011-03-23 Thread Erik Iverson
Holly, try length(unique(x)) == 1 where x is your vector of interest. But think about how you want NA values to be treated, and also think about R FAQ 7.31 if dealing with floating point numbers. --Erik Beale, Holly (NIH/NHGRI) [F] wrote: Is there a less cryptic way to compare three

Re: [R] linear model - lm (Adjusted R-squared)?

2011-03-04 Thread Erik Iverson
See: http://en.wikipedia.org/wiki/Coefficient_of_determination#Adjusted_R2 and the implementation in summary.lm : ans$adj.r.squared - 1 - (1 - ans$r.squared) * ((n - df.int)/rdf) Brian Smith wrote: Hi, Sorry for the naive question, but what exactly does the 'Adjusted

Re: [R] Plot with same font like in LaTeX

2011-03-02 Thread Erik Iverson
Jonas, Try looking at the tikzDevice package, and/or the pgfSweave package. --Erik Jonas Stein wrote: Hi, i want to make my plots look uniform in LaTeX documents. - usage of the same font on axes and in legend like LaTeX uses (for example Computer Modern) - put real LaTeX formulas

Re: [R] converting the string columns in a data.frame to factors?

2011-02-28 Thread Erik Iverson
John, as.data.frame is a generic function that will call different methods depending on what class of object you pass to it. The different methods may have different arguments that they expect or honor. The stringsAsFactors parameter is only used in certain methods of as.data.frame. When you

Re: [R] The L Word

2011-02-23 Thread Erik Iverson
Gene, it's described in ?NumericConstants HTH, Erik Gene Leynes wrote: I've been wondering what L means in the R computing context, and was wondering if someone could point me to a reference where I could read about it, or tell me what it's called so that I can search for it myself. (L

Re: [R] nrow()

2011-02-22 Thread Erik Iverson
Sandra, Please provide a small, reproducible example of this issue. You probably want to use ?is.nan and not the inequality operator. Similar example, contrast: x - NA is.na(x) x == NA Sandra Stankowski wrote: Hey there, I tried to count the number of rows, where my data isn't NaN in a

Re: [R] nrow()

2011-02-22 Thread Erik Iverson
., tapply(o$m, o$n, mean, na.rm = TRUE) None of this is tested... hope this explains, what I need to know. Thanks, S. Am 22.02.2011 16:50, schrieb Erik Iverson: Sandra, Please provide a small, reproducible example of this issue. You probably want to use ?is.nan and not the inequality

Re: [R] identify an element in a column

2011-02-22 Thread Erik Iverson
Is this what you mean? z[which(z[,x] == 5) - 1, y] ?which is probably what you're looking for... Hongwei Dong wrote: Hi, R users, I'm wondering if I can identify an element in a column by an element in another column. For example: x-1:10 y-11:20 z-cbind(x,y) z x y [1,] 1 11 [2,] 2

Re: [R] Populate a list / recursively set list values to NA

2011-02-17 Thread Erik Iverson
Gene, ?rapply is a recursive version of ?lapply, and should work. rapply(masterlist, function(x) x*NA, how = replace) --Erik Gene Leynes wrote: Hello all, Maybe I'm being thick, but I was trying to figure out a simple way to create a list with the same dimension of another list

Re: [R] Sweave doesn't hand on width of special characters of Computer Modern fonts to LaTeX

2011-02-15 Thread Erik Iverson
LaTeX document. --Erik Julia Jacobson wrote: Hello R users, Using R, Sweave and the cmsyase.afm font it is possible to write LaTeX documents including R figures with text in the Computer Modern Fonts: \documentclass{article} \usepackage{Sweave} \begin{document} echo = false, results = hide

Re: [R] Expected behavior of as.character ??

2011-02-09 Thread Erik Iverson
koooee wrote: is this the expected behavior of as.character ? resultset is a data.frame from a sqlQuery() using RODBC a = as.character(as.vector(resultset[1])) a [1] c(-1, 1, 2, 3, 4, 5, 6, 7, 8, 9) I would expect the statement above to return similar to the result below, am I missing

Re: [R] How to properly use a generated test string as a name?

2011-02-09 Thread Erik Iverson
Mark Knecht wrote: Title asks it all. Thanks in advance, Mark a = 1:5 b1 = 2:6 Z = data.frame(a,b1) Z Z$b1 count = 1 MyName = paste(b,count,sep=) MyName Z$MyName Z[[MyName]] __ R-help@r-project.org mailing list

Re: [R] merge multiple .csv files

2011-02-09 Thread Erik Iverson
the common names in the two data.frames. You might try the by argument in merge... Best. --Erik __ 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

Re: [R] Merging by factor variables

2011-02-02 Thread Erik Iverson
frame methods. You can also study the code of base.rbind.data.frame to see what it's actually doing. --Erik __ 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

Re: [R] Efficient way to determine if a data frame has missing observations

2011-02-02 Thread Erik Iverson
H Roark wrote: I have a data set covering a large number of cities with values for characteristics such as land area, population, and employment. The problem I have is that some cities lack observations for some of the characteristics and I'd like a quick way to determine which cities have

Re: [R] (no subject)

2011-02-01 Thread Erik Iverson
?tapply would be one way to get the max for all conditions at once. Your example is not reproducible, so I cannot give you a reproducible answer, but adapt the following: tapply(df$responce, df$condition, max) A. Ramzan wrote: Hello I am trying to find a way to find the max value, for only

Re: [R] sum the values in a vector as a complete number

2011-01-31 Thread Erik Iverson
I am trying to create a function that is able to calculate this sum: a-c(2,3,5) b-(8,7) with a meaning 235 and b 87. So the result of this sum would be 235 + 87 = 322. a - c(2,3,5) b - c(8,7) vectorToScalar - function(x) { as.numeric(paste(x, collapse = )) } vectorToScalar(a) +

Re: [R] function application

2011-01-25 Thread Erik Iverson
as the arguments, then ?do.call is what you need. a - list(example, of, do.call) #compare the two following expressions paste(a) do.call(paste, a) --Erik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] crazy loop error.

2011-01-24 Thread Erik Iverson
Roy, I have no idea what you're actually trying to do here, but it looks like there would be a more natural R'ish way if you're concerned about grouping consecutive elements of 'a'. At any rate, within your while loop, you're incrementing n by 1, and eventually n will be 10, which will be

Re: [R] crazy loop error.

2011-01-24 Thread Erik Iverson
Roy Mathew wrote: Thanks for the reply Erik, As you mentioned, grouping consecutive elements of 'a' was my idea. I am unaware of any R'ish way to do it. It would be nice if someone in the community knows this. Is this the idea you're trying to execute? It uses ?rle and ?mapply. a - c

Re: [R] R package rating site?

2011-01-24 Thread Erik Iverson
http://crantastic.org/ On 01/24/2011 09:08 PM, zubin wrote: We should really have an R package rating site, comments, reviews or such, like folks do for apps or movie reviews. Does anyone know of a site trying to do this. If i remember correctly a few R user conferences ago this was talked

Re: [R] splitting a square symmetric matrix

2011-01-20 Thread Erik Iverson
Joe P King wrote: So many matrices are square symmetrical (i.e. variance-covariance matrices), is there any way to get R to split the matrix on its diagonal and just return one diagonal? mat-matrix(c(1,4,3,4,1,2,3,2,1), nrow = 3, ncol=3, byrow=TRUE) is there anyway to get the lower

Re: [R] subset factor?

2011-01-14 Thread Erik Iverson
Silvano wrote: Hi, I used subset command, like this: grupoP = subset(dados, grupos=='P', select=c(mortos, vivos, doses, percevejos, p)) and the variables in select option are numeric. They may *look* numeric, but are they really? You don't give us enough information to determine that.

[R] Weighted least squares regression for an exponential decay function

2011-01-14 Thread Erik Thulin
Hello, I have a data set of data which is best fit by an exponential decay function. I would like to use a nonlinear weighted least squares regression. What function should I be using? Thank you! [[alternative HTML version deleted]] __

Re: [R] navigating in lists

2011-01-12 Thread Erik Gregory
pick(test, 3) a b c NA NA 7 pick(test, 4) a b c NA NA NA -Erik Gregory Student Assistant, California EPA CSU Sacramento, Mathematics - Original Message From: Greg Snow greg.s...@imail.org To: Jannis bt_jan...@yahoo.de; r-help@r-project.org r-help@r-project.org Sent: Wed, January

Re: [R] Hmisc, summary.formula and catTest

2011-01-06 Thread Erik Iverson
The closest I get is u-function(a,b){ j-fisher.test(a) p-list(P=j$p.value,stat=1,df=1,testname=j$method,statname=) return(p) } However then I manually have to edit the output. Is there a smart way of doing this? You're not explaining what

Re: [R] Hmisc, summary.formula and catTest

2011-01-06 Thread Erik Iverson
Does the prtest argument help when you actually use the 'print' function around your summary.formula object? I think that's how I solve it. I.e., sf1 - summary(trt~sex+ascites,data=ex,test=T,method=reverse,catTest=u) print(sf1, prtest = P) Descriptive Statistics by trt

Re: [R] R not recognized in command line

2011-01-06 Thread Erik Gregory
that python can open and open that with python script! I did all this without any experience with python (I'm alright with R), so you may even find some shortcuts. Good Luck, Erik Gregory, Student Assistant, California EPA CSU Sacramento, Mathematics - Original Message From: Aaditya

[R] Navigating web pages using R

2011-01-04 Thread Erik Gregory
programming, so if this question belongs in a forum on that I apologize. I'm trying to centralize all of my code for my analysis in R! Thank you, -Erik Gregory Student Assistant, California EPA CSU Sacramento, Mathematics __ R-help@r-project.org mailing

[R] Optimal method to scan cells and set flag

2010-12-16 Thread Jon Erik Ween
Jon Erik Ween, MD, MS Scientist, Kunin-Lunenfeld Applied Research Unit Director, Stroke Clinic, Brain Health Clinic, Baycrest Centre Assistant Professor, Dept. of Medicine, Div. of Neurology University of Toronto Faculty of Medicine Kimel Family Building, 6th Floor, Room 644 Baycrest

[R] Installing R-packages in Windows

2010-12-14 Thread Erik Lukac
Hi there, I have the following problem and I hope somebody might help me. First of all: I am using WinXP SP3 (english and/or german) with R in Version 2.10.0. Now I am trying to install some packages but unfortunately I am getting a weird error. No matter which package I am trying to install

Re: [R] Installing R-packages in Windows

2010-12-14 Thread Erik Lukac
that - even if I can use a local repo. Any ideas? Thanks in advance Erik On 12/14/2010 06:17 PM, Mike Marchywka wrote: ( hotmail just randomly decides not to prefix original text, my comments below) Date: Tue, 14 Dec 2010 17:36:11 +0100 From: er

Re: [R] help on SAS Macro in R

2010-12-13 Thread Erik Iverson
On 12/13/2010 07:14 AM, Özgür Asar wrote: Dear Researchers, I am looking for to read a SAS macro in R. Although I searched it on web, I couldn’t find anything. Are you hoping just to read it in, or to actually have it execute the macro as SAS would? What gives you the idea the latter is

[R] Does a formula object have a left hand side

2010-12-13 Thread Erik Iverson
Hello, Does anyone know of a function that will determine whether or not a formula object has a left hand side? I.e., can differentiate between y ~ x + z and ~ x + z Perhaps I'm overlooking the obvious... Thanks! __ R-help@r-project.org mailing

Re: [R] Does a formula object have a left hand side

2010-12-13 Thread Erik Iverson
that the parser would not make). Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erik Iverson Sent: Monday, December 13, 2010 12:17 PM To: R-help Subject: [R] Does a formula

Re: [R] inconsistency with cor() - x must be numeric

2010-12-13 Thread Erik Iverson
Please provide a reproducible example! E.g., use ?dput to dump a minimal data.frame that exhibits this issue on the newest version of R. Justin Fincher wrote: Howdy, I have written a small function to generate a simple plot and my colleague is having an error when attempting to run it.

Re: [R] Why do we have to turn factors into characters for various functions?

2010-12-12 Thread Erik Iverson
On 12/11/2010 04:48 PM, Tal Galili wrote: Hello dear R-help mailing list, My question is *not* about how factors are implemented in R (which is, if I understand correctly, that factors keeps numbers and assign levels to them). My question *is* about why so many functions that work on factors

Re: [R] Reorder factor and address embedded escapes

2010-12-10 Thread Erik Iverson
Does the following help? A = c(A\\nB, C\\nD) test -data.frame(A) #access levels directly to change names levels(test$A) - sub(n, \n, levels(test$A)) #re-order levels of the factor test$A - relevel(test$A, C\nD) Rob James wrote: I am trying to reorder a factor variable that has embedded

[R] set dataframe field value from lookup table

2010-12-09 Thread Jon Erik Ween
Hi This is (hopefully) a bit more cogent phrasing of a previous post. I'm trying to compute a z-score to rows in a large dataframe based on values in another dataframe. Here's the script (that does not work). 2 questons, 1) Anyone know of a more elegant way to calculate the rounded age value

Re: [R] set dataframe field value from lookup table

2010-12-09 Thread Jon Erik Ween
0.5 1.0 1.8 2.6 2.6 26 -.5 0.0 0.0 1.0 1.8 2.6 . . . . So, if a subject (row) has age==29 and a standard score of 28, the value should be 1.8, etc. Thanks Jon Soli Deo Gloria Jon Erik Ween, MD, MS Scientist, Kunin-Lunenfeld Applied Research Unit Director, Stroke Clinic, Brain

Re: [R] set dataframe field value from lookup table

2010-12-09 Thread Jon Erik Ween
referencing of the lookup in the main table that causes me trouble. Jon Soli Deo Gloria Jon Erik Ween, MD, MS Scientist, Kunin-Lunenfeld Applied Research Unit Director, Stroke Clinic, Brain Health Clinic, Baycrest Centre Assistant Professor, Dept. of Medicine, Div. of Neurology University of Toronto

Re: [R] set dataframe field value from lookup table

2010-12-09 Thread Jon Erik Ween
is not a multiple of shorter object length So, regardless of how you calculate [r,c], the step df$DSTz-DSTzlook[r,c] doesn't work. I've tried various permutations with apply, but that didn't work either. Any suggestions? Jon Soli Deo Gloria Jon Erik Ween, MD, MS Scientist, Kunin-Lunenfeld Applied

Re: [R] set dataframe field value from lookup table

2010-12-09 Thread Jon Erik Ween
] On Behalf Of Jon Erik Ween Sent: Thursday, December 09, 2010 8:27 AM To: David Winsemius Cc: r-help@r-project.org Subject: Re: [R] set dataframe field value from lookup table Sorry, I should have included the error I get when using the initial vesion of step 2): Error in `$-.data.frame

Re: [R] Reshape Columns

2010-12-09 Thread Erik Iverson
One way: as.vector(t(cbind(ColA, ColB))) Ross, Stephanie wrote: Hello, I have a general formatting question. I have two columns of data: ColA - c(m, m, m, m) ColB- c(d,d,d,d) And I would like to reorder them into a new column that looks like this: ColC- c(m,d,m,d,m,d,m,d) Thank you!

Re: [R] set dataframe field value from lookup table

2010-12-09 Thread Jon Erik Ween
is then translated into a z-score in a second table. My DSTz table combines these two steps, going from the raw score to the tabulated age-adjusted z-score that was calculated based on a normative sample by the WMS-R folks. Jon Soli Deo Gloria Jon Erik Ween, MD, MS Scientist, Kunin-Lunenfeld

[R] change matrix based on look-up value from table

2010-12-08 Thread Jon Erik Ween
Hi! I have a large dataset where I need to recompute a value in each row based on z-sores from another look-up table. The look-up table is arranged by raw score in the first column and age in the first row, eg: 20 30 40 1 .3 .5 .7 2 .2 .3 .4 3 .1 .4 .7 the main matrix will have

Re: [R] Changing names of a string variable

2010-12-07 Thread Erik Iverson
, which can be queried with the ?levels function. 'Behind the scenes', R is storing this variable as numeric codes, not the character string associated with each numeric code. This contrasts with character vectors. --Erik Jahan wrote: Hello, Here is the data set I am working with: dat=read.csv

Re: [R] Changing names of a string variable

2010-12-07 Thread Erik Iverson
Phil Spector wrote: Jahan - Try dat$target = toupper(dat$target) Note that in this case, the above *will* coerce dat$target to a character vector, which may or may not be what is intended. __ R-help@r-project.org mailing list

Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed

2010-12-07 Thread Erik Iverson
, that can be exported to PDF, HTML, DocBook, and others all simultaneously. It is thus an alternative to Sweave, although conceptually similar. Org-mode can also be used as a note-taking tool, project planner, calendar, ... It is by for the most important tool I've discovered since R. --Erik

Re: [R] using ``-'' in function argument

2010-12-02 Thread Erik Iverson
variable ncol a value of 4. Try typing ncol before and after your example. The second argument to the matrix function is now the value 4, and R uses positional matching to give that argument (nrow) a value of 4. Thus, the result. Moral of the story: don't do that. :) --Erik Best regards

Re: [R] how to update my own function

2010-11-23 Thread Erik Iverson
, 8)) See ?lapply and ?mapply, and the MoreArgs and SIMPLIFY arguments to mapply. --Erik Edwin Sun wrote: Hello all, I wrote a function with many arguments. Then I need to call it many times with changes on some arguments only. Is there any way to write a function or have a method to update

[R] Who uses R with multicore, SNOW or CUDA package for resource intense computing?

2010-11-16 Thread erik
Hi, who of you in this forum uses R (http://www.r-project.org/) with the multicore, SNOW or CUDA packages, so for advanced calculations that need more power than a workstation CPU? On which hardware do you compute these scripts? At home/ at work or do you have data center access somewhere? The

Re: [R] indexing lists

2010-11-15 Thread Erik Iverson
Chris, Well, the 'answer' could be: which(sapply(a, function(x) all(x == c(1,2 But I wonder how these elements of 'a' in your actual application are coming to be? If you're constructing them, you can give the elements of the list names, and then it doesn't matter what numerical index they

Re: [R] Consistency of Logistic Regression

2010-11-11 Thread Erik Iverson
Is the algorithm converging? Is there separation (i.e., perfect predictor) in the model? Are you getting a warning about fitted probabilities of 0 or 1?, etc. We would need much more information (preferably a reproducible example) before we can help. Benjamin Godlove wrote: Dear R developers,

Re: [R] randomForest can not handle categorical predictors with more than 32 categories

2010-11-10 Thread Erik Iverson
Well, the error message seems relatively straightforward. When you run str(x) (you did not provide the data) you should see 1 or more components are factors that have more than 32 levels. Apparently you can't include those predictors in a call to randomForest. You might find the following

Re: [R] arrays of arrays

2010-11-09 Thread Erik Iverson
This type of object has the matrix class in R. So just use ?matrix to create it. matrix(1:25, ncol = 5) for example. On 11/09/2010 08:55 PM, sachinthaka.abeyward...@allianz.com.au wrote: Hi All, I want to have an array/ matrix that looks this x- 0 0 1 1 1

Re: [R] Performing a geometric seqeunce using iterators?

2010-11-09 Thread Erik Iverson
On 11/09/2010 09:16 PM, vicho wrote: I want to make a function for geometric seqeunce since testing=function(x){i=1;ans=1;while(true){ans=ans+(1/x)^i ; i=i+1} ;return(ans)} doesn't work... the program is freeze... What exactly are you trying to do? Where does true get set? Did you mean

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
What class of object / structure do you exactly want in the end? A matrix, a data.frame, a vector? johannes rara wrote: Hi, How to rbind these vectors from a list?: l - list(a = c(1, 2), b = c(1, 2, 3)) l $a [1] 1 2 $b [1] 1 2 3 do.call(rbind, l) [,1] [,2] [,3] a121 b

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
So what do you want the matrix to look like, since the number of columns will be different between the two rows? johannes rara wrote: Thanks, data.frame or matrix. -J 2010/11/8 Erik Iverson er...@ccbr.umn.edu: What class of object / structure do you exactly want in the end? A matrix

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
Then one solution is to use rbind.fill from the plyr package. johannes rara wrote: This is the ideal result (data.frame): result names X1 X2 X3 1 a 1 2 NA 2 b 1 2 3 2010/11/8 Erik Iverson er...@ccbr.umn.edu: So what do you want the matrix to look like, since the number

Re: [R] Random Sample

2010-11-08 Thread Erik Iverson
?set.seed is what you're looking for Xiaoxi Gao wrote: Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the same random numbers? For example, 10 random numbers is generated from N(0,1), then runif(10) is used.What if I want to get the

Re: [R] compare and replace

2010-11-06 Thread Erik Iverson
On 11/06/2010 11:36 AM, Robert Ruser wrote: Hello R Users, I'm wondering if there exists any elegant and simple way to do the following: I have a data.frame X fills in numbers. I have a vector y with numbers as well. Every value in X that is equal to any values in y should be replaced by e.g. 1.

Re: [R] subsets, %in%

2010-11-05 Thread Erik Iverson
argument. -Erik mp.sylves...@gmail.com wrote: Hi, I have a question about %in% and subsettin data frames. Say I need to keep ID 1,2,4,5, 10 from the data frame dat. I can do: dat - data.frame(ID = 1:10, var = 1:10) someID - c(1,2,4,5,10) subset(dat, dat$ID %in% someID) Is there a quick way to do

Re: [R] assignment operator saving factor level as number

2010-11-05 Thread Erik Iverson
Could you give a small reproducible example please? It is not clear to me what your looping structure is doing, or what your goal here is. There may be a much simpler method than introducing subscripts. --Erik Wade Wall wrote: Hi all, I have a dataframe (df1) that I am trying to select

Re: [R] Problems with points in plots when importing from pdf to an SVG editor

2010-11-04 Thread Erik Iverson
/accept /alias I've found that in my case, this happens when viewing a PDF with that plotting character under old versions of Evince, but not newer. --Erik Rafael Björk wrote: Dear R-users When trying to import graphics from an pdf-file to a Vector graphics editor (I use Inkscape, but i've

Re: [R] Loop

2010-11-04 Thread Erik Iverson
can find more details about this in the posting guide, linked to at the bottom of every email. Best, --Erik Matevž Pavlič wrote: Hi all, I understand that you most of you this is a peice of cake but i am a complete newbie in thisso any example would be greatly aprpeciated and also any hint

Re: [R] Converting Strings to Variable names

2010-11-04 Thread Erik Iverson
(rbind, sampleList) otherwise perhaps using ?Reduce and ?merge. If you can provide a more complete example to the list, please do. You need not resort to a for loop/get hack for this. Best, --Erik Thanks, Anand [[alternative HTML version deleted

Re: [R] creating vectors with three variables out of three datasets

2010-11-04 Thread Erik Iverson
DomDom wrote: Hi there, i´ve got a problem with how to create a vector with three variables out of three seperate ascii files. These three ascii files contain pixel information of the same image but different bands and i need a matrix of vectors, with each vector containing the

Re: [R] setting attributes (SOLVED)

2010-11-04 Thread Erik Iverson
useful for this.) --Erik __ 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, self-contained, reproducible code.

Re: [R] How to unquote string in R

2010-11-03 Thread Erik Iverson
lord12 wrote: s= Hey a = Hello table = rbind(s,a) write.table(table,paste(blah,.PROPERTIES,sep = ),row.names = FALSE,col.names = FALSE) In my table, how do I output only the words and not the words with the quotations? You read the help page for the function you're using :). From

Re: [R] programming questions

2010-11-03 Thread Erik Iverson
ivo welch wrote: quick programming questions. I want to turn on more errors. there are two traps I occasionally fall into. * I wonder why R thinks that a variable is always defined in a data frame. is.defined(d) [1] FALSE d= data.frame( x=1:5, y=1:5 ) is.defined(d$z)

Re: [R] programming questions

2010-11-03 Thread Erik Iverson
have set. 2) does not pass in the object, in which case you can test for that with ?missing. Is writing your own functions for others to use what you're doing? --Erik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] deleteing all but some observations in data.frame

2010-11-03 Thread Erik Iverson
It depends on which 20 you want. If you have a data.frame called 'test.df', you can do: #first 20 test.df[20, ] -or- head(test.df, 20) #random 20 test.df[sample(nrow(test.df), 20), ] None of this was tested, but it should be a start. --Erik Matevž Pavlič wrote: Hi, I am sure

Re: [R] deleteing all but some observations in data.frame

2010-11-03 Thread Erik Iverson
Note that these methods don't 'delete' observations. They all create brand new objects that are subsets of the test.df object. You can effectively 'delete' the observations by replacing the original data.frame with the returned object... so test.df - head(test.df, 20) Erik Iverson wrote

Re: [R] avoiding too many loops - reshaping data

2010-11-03 Thread Erik Iverson
of the reshape2 package, but have no idea if that's replaced the reshape package yet. --Erik Dimitri Liakhovitski wrote: Hello! I have a data frame like this one: mydf-data.frame(city=c(a,a,a,a,a,a,a,a,b,b,b,b,b,b,b,b), brand=c(x,x,y,y,z,z,z,z,x,x,x,y,y,y,z,z), value=c

Re: [R] biding rows while merging at the same time

2010-11-03 Thread Erik Iverson
Just merge(df1, df2, all = TRUE) does it, yes? Dimitri Liakhovitski wrote: Hello! I have 2 data frames like this (well, actually, I have 200 of them): df1-data.frame(location=c(loc 1,loc 2,loc 3),date=c(1/1/2010,1/1/2010,1/1/2010), a=1:3,b=11:13,c=111:113) df2-data.frame(location=c(loc

Re: [R] Error message when creating a dataframe

2010-11-01 Thread Erik Iverson
I suggest using the most recent version of R (2.12.0 I believe) and providing a reproducible example, showing us exactly how you are creating this data.frame (assuming it still exhibits the behavior). --Erik ANJAN PURKAYASTHA wrote: Hi, I'm creating a data frame of 24 columns and 45101 rows

Re: [R] How to stop showing messages while loading package?

2010-11-01 Thread Erik Iverson
Simply read the ?library help page, where you'll find under Details: To suppress messages during the loading of packages use ‘suppressPackageStartupMessages’: this will suppress all messages from R itself but not necessarily all those from package authors. Christofer Bogaso

Re: [R] how to view the top 20 lines in a long dataset

2010-11-01 Thread Erik Iverson
?head or just df[1:20, ] Louis Plough wrote: Hi, I am simply looking for the function that will allow you to look at the top 20 lines of a long dataset? LP On Mon, Nov 1, 2010 at 10:46 AM, Louis Plough lplo...@usc.edu wrote: Hi, I am trying to generate all possible permutations (choose 2)

Re: [R] SARIMA simulation using time series history

2010-10-29 Thread Knut Erik Vedahl
), period=NA)), n=N, innov=YourSerie) I'm not sure, but maybe this help you. Salute. Juan. On 2010-10-28, at 8:08 PM, Knut Erik Vedahl wrote: Hi, I'm currently working with a SARIMA model from which I want to make simulations. As I understand, neither sarima.Sim nor the functions

Re: [R] help with help()

2010-10-28 Thread Erik Iverson
claudia tebaldi wrote: Hi all Just this morning I upgraded to R 2.12.0 (for Mac OS X 10.6.4). All went well until I needed to run a help() or help.search() in my session, which I'm running within Emacs (ESS 5.3.7). That's very old version of ESS, I have no problems with 2.12.0 with ESS

  1   2   3   4   5   6   7   8   9   >