Re: [R] help with data layout

2008-07-17 Thread Erik Iverson
Iain Gallagher wrote: Hello list I have been given some Excel sheets with data laid like this: Col1Col2 A 3 2 3 B 4 5 4 C 1 4 3 I was hoping to import this into R as a csv and then get the mean and SD for each letter in column 1. Could someone give me some guidance

Re: [R] Display variables when running a script

2008-07-17 Thread Erik Iverson
Depending on your motivation here, you may want to search for 'debugging in R' or something to that effect to look at the various options available. I like the debug package available on CRAN. Also see ?browser and ?trace if you want to debug a function. [EMAIL PROTECTED] wrote: Hi, I kn

Re: [R] Problem with TLC/TK on Ubuntu

2008-07-17 Thread Erik Iverson
Davide Massidda wrote: Dear all, I have installed R on Linux/Ubuntu 8.04. But you don't say how. Are you compiling R yourself or installing the Ubuntu package from CRAN? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/

Re: [R] Function Error

2008-07-22 Thread Erik Iverson
Please give commented, minimal, self-contained, reproducible code. In this case, not only the function definition, but a simple example showing *how* it does not work, and what you were expecting it to do! Angelo Scozzarella wrote: Hi, Why this function doesn't work? function (x) { if (

Re: [R] Warning message in if else statement

2008-07-23 Thread Erik Iverson
Monica - Monica Pisica wrote: Hi, I am using an if else statement inside a function …. If I use that function I have no problems …. If I use the function with the if else statement inside a second function I get the following waring: Warning message: In if (pval == 0) p_value <- "< 2.2e-16" el

Re: [R] Can R fill in missing values?

2008-07-23 Thread Erik Iverson
, fromLast = TRUE) # end R code This will of course work on the 'France' column. Use of lapply in conjuction with this idea will lead to solving this problem for N columns in a couple lines of R. Not messy at all! Best Regards, Erik Iverson _

Re: [R] How to delete duplicate cases?

2008-07-24 Thread Erik Iverson
Daniel - First, use order() to arrange the data.frame into an appropriate format. Then, use duplicated() with the negation operator to get rid of the duplicated values. Daniel Wagner wrote: Dear R users, Â I have a dataframe with lot of duplicate cases and I want to delete duplicate ones

Re: [R] Help with which()

2008-07-24 Thread Erik Iverson
See http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f [EMAIL PROTECTED] wrote: Hi, I'm using which to find the position of a value in my data table, and it is returning the correct position and the position of another number that differs by an ex

Re: [R] Help with which()

2008-07-24 Thread Erik Iverson
Ben Bolker wrote: Erik Iverson biostat.wisc.edu> writes: See http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f naw3 duke.edu wrote: I'm using which to find the position of a value in my data table [snip] For example, w

Re: [R] Question: how to build a subset to do separate calculations

2008-07-24 Thread Erik Iverson
Spencer - Spencer wrote: Dear R Experts, I am trying to create several subsets that I want to use as separate datasets. After separate subsets are created for each country, I want to do some calculations for each. I did the following: data <- data.frame(na.omit(read.spss("trial.sav"))) at

Re: [R] Question: how to build a subset to do separate calculations

2008-07-24 Thread Erik Iverson
Erik Iverson wrote: Spencer - Spencer wrote: Dear R Experts, I am trying to create several subsets that I want to use as separate datasets. After separate subsets are created for each country, I want to do some calculations for each. I did the following: data <- data.frame(na.o

Re: [R] accessing list elements

2008-07-29 Thread Erik Iverson
Hello - Paul Adams wrote: Hello everyone, I have a list which I am trying to calculate a max value.I have the list as w<-c(v[[1]][1],...v[[100]][1]). The problem I am getting is that the function max is saying the list is an "invalid type (list) of argument".When I show the element v[[1]][1] it

Re: [R] Variable name in a String

2008-07-30 Thread Erik Iverson
?assign, ?get R_Learner wrote: Hi all, I have this string "year" and integer 2008 (both are inputs from the user), and I would like to make a variable called "year2008" that will store a vector of numbers. Does anyone know how to do this? Also, if the user later input "year" and "2008",

Re: [R] colnames from read.table

2008-07-30 Thread Erik Iverson
Chua Siang Li wrote: Hi. May I know why the colnames is NULL when reading only 1 column from a csv file? You are not "reading only 1 column from a csv file", you are subsetting one column of a data.frame. See ?Extract and the "drop" argument specifically. How do I get the colnam

Re: [R] How to output R image to a file?

2008-07-31 Thread Erik Iverson
?Devices for a start. Aiste Aistike wrote: Hello, I would like to ask if anyone could help me. I want to save images I create (e.g. histograms, boxplots, plots, etc.) to a file or files. Does anyone know how to do this? Thank you. Aiste [[alternative HTML version deleted]] _

Re: [R] Storing Matrices into Hash

2008-07-31 Thread Erik Iverson
I think a named list is probably the easiest way to start off, something like: all_mat <- list(mat1 = mat1, mat2 = mat2) all_mat$mat2 Gundala Viswanath wrote: Hi, Suppose I have these two matrices (could be more). What I need to do is to store these matrices into a hash. So that I can cal

Re: [R] Storing Matrices into Hash

2008-07-31 Thread Erik Iverson
Gundala Viswanath wrote: Thanks so much Erik, But how do you include that in a loop. I tried this, doesn't seem to work. Please advice: __BEGIN__ all_mat <- NULL for (matno in 1:10) { mat <- process_to_create_matrix(da[matno]) all_mat <- list(all_post, matno = mat) } I'm not exac

Re: [R] viewing data in something similar to 'R Data Editor'

2008-08-01 Thread Erik Iverson
See ?View but I don't think it 'auto updates' per your last sentence. Maybe there's a better option? Rachel Schwartz wrote: Hi, I would like to view matrices I am working with in a clean, easy to read, separate window. A friend showed me how to do something like I want with edit(). I can vie

Re: [R] viewing data in something similar to 'R Data Editor'

2008-08-01 Thread Erik Iverson
specific list, R-SIG-Mac, google for it. On Fri, Aug 1, 2008 at 10:52 AM, Erik Iverson <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: See ?View but I don't think it 'auto updates' per your last sentence. Maybe there's a better option?

Re: [R] Basic factor question.

2008-08-02 Thread Erik Iverson
0]) levels(x) x vs. y <- factor(letters[1:20], levels = letters) levels(y) y vs. z <- factor(letters[1:20], levels = letters[1:19]) levels(z) z That might help show you what's going on? Best, Erik Iverson [EMAIL PROTECTED] wrote: Doing ?factor I get: x a vector of data, usually taking

Re: [R] T Test

2008-08-11 Thread Erik Iverson
Just plug your values into the t-test formula, you don't need R for this, you can use a calculator. If you want a p-value then use the pt() function in R after getting the t statistic. Angelo Scozzarella wrote: Hi, I want to calculate the T-Test from means and sd. How can I do it? Thanks

Re: [R] produce variable on the fly

2008-08-12 Thread Erik Iverson
?assign , or consider a named vector/list. jimineep wrote: Hi guys, I want to create variable on the fly: for example for (i in 1:10) { cat(paste("VAR",i,sep="")) } Will print VAR1, VAR2 etc up to VAR10. However I want to make these into variables, and then give them a value, for example:

Re: [R] merging data sets to match data to date

2008-08-13 Thread Erik Iverson
rcoder wrote: Hi everyone, I want to extract data from a data set according to dates specified in a vector. I have created a blank matrix with row names (dates) that I want to extract from the full data set. I have then performed a merge to try to o/p rows corresponding to common dates to a resu

Re: [R] which(df$name=="A") takes ~1 second! (df is very large), but can it be speeded up?

2008-08-13 Thread Erik Iverson
I still don't understand what you are doing. Can you make a small example that shows what you have and what you want? Is ?split what you are after? Emmanuel Levy wrote: Dear Peter and Henrik, Thanks for your replies - this helps speed up a bit, but I thought there would be something much fas

Re: [R] conditional IF with AND

2008-08-13 Thread Erik Iverson
if(cond1 && cond2) { ... } rcoder wrote: Hi everyone, I'm trying to create an "if" conditional statement with two conditions, whereby the statement is true when condition 1 AND condition 2 are met: code structure: if ?AND? (a[x,y] , a[x,y] ) I've trawled through the help files, but I canno

Re: [R] Conditional statement used in sapply()

2008-08-13 Thread Erik Iverson
Hello - Altaweel, Mark R. wrote: Hi, I have data stored in a list that I would like to aggregate and perform some basic stats. However, I would like to apply conditional statements so that not all the data are used. Basically, I want to get a specific variable, do some basic functions (such as

Re: [R] Simple (?) subset problem

2008-08-14 Thread Erik Iverson
I can't tell exactly what's wrong, just check out the ?str and ?levels functions for some guidance. Farley, Robert wrote: I can't figure out the syntax I need to get subset to work. I'm trying to split my dataframe into two parts. I'm sure this is a simple issue, but I'm stumped. I either ge

Re: [R] Opening a web browser from R?

2008-08-15 Thread Erik Iverson
Hello - [EMAIL PROTECTED] wrote: Hi, I was wondering if there's a way in R to open a web browser (such as Internet Explorer, or Firefox or whatever). I'm doing some analyses that have associated urls, and it would be nice to have the ability to directly open the relevant page from within R.

Re: [R] Saving environment object

2008-08-15 Thread Erik Iverson
Benjamin Otto wrote: Hi, When I create an environment object with new.env() and populate it with values then how can I save it into an .RData file properly, so it can be loaded later on in a new session? Saving an environment object with save() or save.image() results in an error message when l

Re: [R] Saving environment object

2008-08-15 Thread Erik Iverson
Of course you said when you load it again. I just now loaded it, without error. FYI, my sessionInfo(), which I realize is not the latest version. sessionInfo() R version 2.7.0 (2008-04-22) i686-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;L

Re: [R] Produce single line graph title composed of text and computed values.

2009-08-10 Thread Erik Iverson
See the ?paste function, instead of the ?c function. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Sorkin Sent: Monday, August 10, 2009 10:36 AM To: r-help@r-project.org Subject: [R] Produce single line graph title composed

Re: [R] summary(table)

2009-08-10 Thread Erik Iverson
We cannot reproduce your example since we don't have access to probF. It seems probF is not an object of class "table", but perhaps of class "data.frame". Also, summary is not "cutting off the other variables", it is pooling levels of a factor into the "Other" category. All the levels belong

Re: [R] Bug in "seq" (or a "feature") ?

2009-08-10 Thread Erik Iverson
General floating point arithmetic issue here: See FAQ 7.31 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili Sent: Monday

Re: [R] pretty display or print for data frames ?

2009-08-12 Thread Erik Iverson
I sometimes use the View() (note the capital V) function to view long/wide data.frames. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Leon Yee Sent: Wednesday, August 12, 2009 2:12 AM To: Patrick Connolly Cc: r-help@r-project.or

Re: [R] Symbolic references - passing variable names into functions

2009-08-12 Thread Erik Iverson
I think ONE answer to what you actually want to do might be f <- function(dataf, col1 = "column1", col2 = "column2") { dataf[[col1]] <- dataf[[col2]] # just as an example dataf } -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.o

Re: [R] Nominal variables in SVM?

2009-08-12 Thread Erik Iverson
Noah, depending on what function you use, it might do this automatically for you if you give the function a formula containing a factor. Otherwise, see ?model.matrix. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Noah Silverm

Re: [R] Nominal variables in SVM?

2009-08-12 Thread Erik Iverson
This is where a small, reproducible example will definitely help us discover your problem. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Noah Silverman Sent: Wednesday, August 12, 2009 4:29 PM To: Achim Zeileis Cc: r help Subjec

Re: [R] Browser and Debug?

2009-08-13 Thread Erik Iverson
This article might help: http://www.biostat.jhsph.edu/~rpeng/docs/R-debug-tools.pdf -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Inchallah Yarab Sent: Thursday, August 13, 2009 9:40 AM To: r-help@r-project.org Subject: [R] Brows

Re: [R] How to get the n (number of observations) per conditional group

2009-08-13 Thread Erik Iverson
We will only be able to help if you provide a reproducible example! I'm sure this is a simple one-liner, but it's hard to tell from your example what it should be. The functions table, length, tapply, and/or nrow may play a part though. -Original Message- From: r-help-boun...@r-proje

Re: [R] Coding problem: How can I extract substring of function call within the function

2009-08-13 Thread Erik Iverson
Are you sure you just don't want to tell them about the :: operator? It sounds easier than what you're proposing. E.g., base::mean(c(1:10, NA)) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Pitt, Joel Sent: Thursday, August 1

Re: [R] help with median for each row

2009-08-21 Thread Erik Iverson
Edward, In general, if you have an nxn matrix, you can use the "apply" function to apply a function to each row of the matrix, and return the result. So, as a start, you could do, apply(your.mat, 1, median) or apply(your.mat, 1, median, na.rm = TRUE) if you want to pass further arguments

Re: [R] table function

2009-08-24 Thread Erik Iverson
You need to create a factor that indicates which group the values in 'z' belong to. The easiest way to do that based on your situation is to use the 'cut' function to construct the factor, and then call 'table' using the result created by 'cut'. See ?cut and ?factor -Original Message

Re: [R] Unique command not deleting all duplicate rows

2009-08-24 Thread Erik Iverson
I really don't think this is the issue. I think the issue is that some columns of the data.frame, specifically V1, V2, and V4 should be checked versus R FAQ 7.31. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Don McKenzie Sen

Re: [R] table, xyplot, names, & loops

2009-08-25 Thread Erik Iverson
city), mean)) ## use dotplot with the matrix object dotplot(h.tab, type = "o", auto.key = list(lines = TRUE, space = "right"), xlab = "height") ## END SAMPLE R CODE Best, Erik Iverson

Re: [R] table, xyplot, names, & loops

2009-08-25 Thread Erik Iverson
And of course I did not test this :). Within the data.frame argument list, please change the <- operators to = signs. Then it should work. Erik -Original Message- From: Erik Iverson Sent: Tuesday, August 25, 2009 1:17 PM To: 'w_poet'; r-help@r-project.org Subject:

Re: [R] Managing output

2009-08-26 Thread Erik Iverson
How about ?append, but R is vectorized, so why not just result_list <- 2*item^2 , or for more complicated tasks, the apply/sapply/lapply/mapply family of functions? In general, the "for" loop construct can be avoided so you don't have to think about messy indexing. What exactly are you trying

Re: [R] Simple column selection question- which and character lists

2009-08-31 Thread Erik Iverson
1) Don't call your data.frame "data". I will call my "example" one "df". 2) If you want the columns NOT in names.species.bio.18, which is what you said, then the answer is: df[!names(df) %in% names.species.bio.18] Best, Erik -Original Message- From: r-help-boun...@r-project.org [mai

[R] Offtopic, HT vs. HH in coin flips

2009-08-31 Thread Erik Iverson
FYI, this is not homework, I have not been in school in years. I saw a similar problem posed in a blog post on the Revolutions R blog, and although I believe the answer, I'm having a hard time figuring out why this should be? Thanks, Erik Iverson __

Re: [R] Offtopic, HT vs. HH in coin flips

2009-08-31 Thread Erik Iverson
http://www.mit.edu/~emin/writings/coinGame.html Best, Erik -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erik Iverson Sent: Monday, August 31, 2009 2:17 PM To: r-help@r-project.org Subject: [R] Offtopic, HT vs. HH in coin fl

Re: [R] Function to find angle between coordinates?

2009-09-01 Thread Erik Iverson
?atan2 is a possible starting point. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of clair.crossup...@googlemail.com Sent: Tuesday, September 01, 2009 8:09 AM To: r-help@r-project.org Subject: [R] Function to find angle between coo

Re: [R] cbind objects using character vectors

2009-09-01 Thread Erik Iverson
Not tested: Instead of: cbind(vec.names[1], vec.names[2]) cbind(get(vec.names[1]), get(vec.names[2])) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jonas garcia Sent: Tuesday, September 01, 2009 12:53 PM To: r-help@r-project.or

Re: [R] Date format in plot

2009-09-01 Thread Erik Iverson
We will need a reproducible example! Please give us R commands that display the behavior you're observing: For example, I am having trouble understanding the as.Date function. When I input 39939, I would like to get "06.05.2009", but when I try it, I get > as.Date(39939) Error in as.Date.nu

Re: [R] strange results in summary and IQR functions

2009-09-08 Thread Erik Iverson
% 222 2.02 2.00 2.00 2.0 2. 25%11 114 7.5 11 9.25 11.25 10.41667 10.5625 50%13 14 13 13.0 14 14.00 14.00 14.0 14. 75%31 31 31 31.0 31 32.50 31.00 31.5 31.3750 100% 47 47 47 47.0 47 47.00 47.00 47.0 47. Best, E

Re: [R] Count number of different patterns (Polytomous variable)

2009-09-08 Thread Erik Iverson
If your data.frame was called "test" below, nrow(unique(test)) would do what you want, I believe. Erik -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of "Biedermann, Jürgen" Sent: Tuesday, September 08, 2009 9:24 AM To: r-help@

Re: [R] The code behind the function

2009-09-09 Thread Erik Iverson
ran.r-project.org/doc/manuals/R-intro.html#Object-orientation Best Regards, Erik Iverson __ 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.ht

Re: [R] Joining Characters in R {issue with paste}

2009-09-09 Thread Erik Iverson
And did you read the help file, ?paste , paying attention to the arguments and their descriptions, specifically the "sep" argument? Presumably, you want, paste(a, b, sep = "") -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Abhi

Re: [R] Help with for loop

2009-09-14 Thread Erik Iverson
It is difficult to know what you're trying to do here, I think. Is this it? You almost surely don't need a for loop to accomplish your task, and should make use of the pre-existing vectorized functions provided to you. a <- c(4, 5, 1, 7, 8, 12, 39) b <- c(3, 7, 8, 4, 7, 25, 78) d <- a - b whi

Re: [R] average for files and graph

2009-09-14 Thread Erik Iverson
It would be even greater if you could get us started with some commented, minimal, self-contained, reproducible code. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of kylle345 Sent: Monday, September 14, 2009 1:35 PM To: r-help@r-pr

Re: [R] Putting together a constantly evolving package

2009-09-15 Thread Erik Iverson
Steve, I can't speak to your exact question, but perhaps suggest a simple alternative. What I do is simply make changes to the .R file containing my code, and use the "source" function to read in the new definitions of my functions while I'm tweaking them. Then, at the end of the day, I do my

Re: [R] Viewing Function Code

2009-09-15 Thread Erik Iverson
See the reference to ?getAnywhere in the following post: http://www.nabble.com/The-code-behind-the-function-td25370743.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Pearmain Sent: Tuesday, September 15, 2009 3:14 PM

Re: [R] How to remove 'NA's?

2009-09-15 Thread Erik Iverson
Well, how about the nomatch argument to the match function, see ?match . The nomatch argument is NA by default. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Tuesday, September 15, 2009 4:05 PM To: r-h...@stat.math.

Re: [R] R console line-wrapping

2009-09-15 Thread Erik Iverson
See ?options, particularly the "width" setting. > options(width=200) Might do what you want, by default it is 80... Best, Erik Iverson -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Nick Matzke Sent: Tuesday,

Re: [R] T-test to check equality, unable to interpret the results.

2009-09-16 Thread Erik Iverson
gards, Erik Iverson -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Robert Hall Sent: Wednesday, September 16, 2009 1:55 PM To: r-help Subject: [R] T-test to check equality, unable to interpret the results. Hi, I have the precision valu

Re: [R] apply function across two variables by mult factors

2009-09-16 Thread Erik Iverson
Hello, > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Jon Loehrke > Sent: Wednesday, September 16, 2009 2:23 PM > To: r-help@r-project.org > Subject: [R] apply function across two variables by mult factors > > Greetings, >

Re: [R] apply function across two variables by mult factors

2009-09-16 Thread Erik Iverson
One correction below, ---snip--- > > > > # example data frame > > testDF<-data.frame( > > x=rnorm(12), > > y=rnorm(12), > > f1=gl(3,4), > > f2=gl(2,2,12)) > > > > Try this using lapply, split, mapply? Maybe it is in a nicer output > object for you? > > testFun2 <- function(x,

Re: [R] generating unordered combinations

2009-09-17 Thread Erik Iverson
Dan, Still maybe a bit ugly, but no looping... > unique(as.data.frame(t(apply(expand.grid(0:2, 0:2, 0:2), 1, sort V1 V2 V3 1 0 0 0 2 0 0 1 3 0 0 2 5 0 1 1 6 0 1 2 9 0 2 2 14 1 1 1 15 1 1 2 18 1 2 2 27 2 2 2 Best, Erik > -Original Message- > F

Re: [R] Basic function output/scope question

2009-09-21 Thread Erik Iverson
nt their values accessible, simply return them. ## return just y testfunc2 <- function(x) { y <- 10 y } ## return both x and y testfunc2 <- function(x) { y <- 10 list(x, y) } There are ways to make x and y global from within a function, but in general that is not the R

Re: [R] Basic function output/scope question

2009-09-21 Thread Erik Iverson
urther. For example, ## return both x and y testfunc2 <- function(x) { y <- 10 list(x, y) } my.var <- testfunc2(4) another.function(my.var) > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Erik Iver

Re: [R] missing level of a nested factor results in an NA in lm output

2009-09-21 Thread Erik Iverson
> > estimable(fit, myEstimate) > Estimate Std. Error t value DF Pr(>|t|) > test 12.18198 0.6694812 18.19615 10 5.395944e-09 Where are you getting this "estimable" function from? A package? Did you define it yourself? __ R-help@r-project

Re: [R] More elegant way of excluding rows with equal values in any 2 columns?

2009-09-21 Thread Erik Iverson
Hello, Do you mean exactly any 2 columns. What if the value is equal in more than 2 columns? > > I built a data frame "grid" (below) with 4 columns. I want to exclude > all rows that have equal values in ANY 2 columns. Here is how I am > doing it: > > index<-expand.grid(1:4,1:4,1:4,1:4) If

Re: [R] More elegant way of excluding rows with equal values in any 2 columns?

2009-09-21 Thread Erik Iverson
could also replace "!duplicated" in my function with "unique" ... Erik > -Original Message- > From: Dimitri Liakhovitski [mailto:ld7...@gmail.com] > Sent: Monday, September 21, 2009 2:02 PM > To: Erik Iverson > Cc: R-Help List > Subject: Re: [R] M

Re: [R] More elegant way of excluding rows with equal values in any 2 columns?

2009-09-21 Thread Erik Iverson
> > You could also replace "!duplicated" in my function with "unique" ... > It turns out you can't, of course :). __ 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.o

Re: [R] Working around 256 byte variable names? + trouble opening large file

2009-09-21 Thread Erik Iverson
> I did just try to do that, and it is still returning the same error when I > try to attach the csv file.. > > > vc1<-read.table("P:\\R\\Everything-I.csv",header=T, sep=" ", dec=".", > na.strings=NA, strip.white=T) > > attach(vc1) > Error in attach(vc1) : variable names are limited to 256 bytes

Re: [R] Linear Model "NA" Value Test

2009-09-21 Thread Erik Iverson
> if("fit$coef[[2]]" == "NA") {.cw = 1} See ?is.na __ 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-conta

Re: [R] How to use a string to refer a function?

2010-02-11 Thread Erik Iverson
Hint: "somebody let me know how to >>>get< the function from the name 'f'?" __ 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] Which method is called when print(a_list)?

2010-02-15 Thread Erik Iverson
blue sky wrote: I don't find print.list. Could somebody let me know which method is called when I run command print(a_list), where a_list is a list? Is 'print.default' used for printing a list? Yes. You can always debug functions to investigate what's going on, too. See ?debug. __

Re: [R] How to check the two different nulls?

2010-02-15 Thread Erik Iverson
blue sky wrote: x=list(a=1,b=NULL) is.null(x$b) is.null(x$c) Both the above two commands give me TRUE, but in the first one, b is NULL, in the second one, c doesn't exist. Are there functions that can help me distinguish the two different nulls? __ R-

Re: [R] delete repeated values - not unique...

2010-02-16 Thread Erik Iverson
Well, can you algorithmically describe what you are trying to do? Your example is not sufficient to determine it. For instance, are you trying to: 1) remove repeated elements of a vector and concatenate the first element at the end? 2) remove repeated elements of a vector and concatenate the

Re: [R] delete repeated values - not unique...

2010-02-16 Thread Erik Iverson
Ah, the request was 'hidden' in the subject of the message, apologies! Erik Iverson wrote: Well, can you algorithmically describe what you are trying to do? Your example is not sufficient to determine it. For instance, are you trying to: 1) remove repeated elements of a

Re: [R] Keyboard

2010-02-16 Thread Erik Iverson
Steven Martin wrote: All, I installed R-2.10.1 with Readline=no. Now for some reason R does not recognize some key strokes like the directional arrows. I am not sure if Readline is the problem or not. What particular OS are you using? In many cases, there is a preconfigured package avail

Re: [R] Use of R in clinical trials

2010-02-17 Thread Erik Iverson
Frank E Harrell Jr wrote: Cody, How amazing that SAS is still used to produce reports that reviewers hate and that requires tedious low-level programming. R + LaTeX has it all over that approach IMHO. We have used that combination very successfully for several data and safety monitoring rep

Re: [R] Problems installing R-2.10.1 on Linux

2010-02-17 Thread Erik Iverson
Rhett Harrison wrote: Hi, I have been having problems installing the newest version on Linux (Ubuntu 9.10) (tried on two machines). The ./configure appears to work but I get the following error on the 'make' command. Don't know about this, but if there's no particular reason you need to com

Re: [R] variable substitution

2010-02-18 Thread Erik Iverson
Hello, Jon Erik Ween wrote: Hi I would like to write a script that reads a list of variable names. These variable names are some of the column headers in a data.frame. Then I want do a for-loop to execute various operations on the specified variables in the data.frame, but can't figure out ho

Re: [R] subset() for multiple values

2010-02-18 Thread Erik Iverson
subset(df, x %in% c(...)) chipmaney wrote: This code works: subset(NativeDominant.df,!ID=="37-R17") This code does not: Tree.df<-subset(NativeDominant.df,!ID==c("37-R17","37-R18","10-R1","37-R21","37-R24","R7A-R1","3-R1","37-R16")) how do i get subset() to work on a range of values? ___

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Erik Iverson
Cannot reproduce, what is branches? If you can narrow it down to a "commented, minimal, self-contained, reproducible" example, you're far more likely to get help from the list. dkStevens wrote: I'm observing odd behavior of the rep(...) procedure when using variables as parameters in a loop.

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Erik Iverson
Erik Iverson wrote: Cannot reproduce, what is branches? If you can narrow it down to a "commented, minimal, self-contained, reproducible" example, you're far more likely to get help from the list. My blinded guess though, is something to d

Re: [R] R error- "more columns than column names"

2010-02-24 Thread Erik Iverson
I had a comment character "#" in my header names earlier today that threw this error. Euphoria wrote: Hi all! I am desperately trying to figure out the solution to this error, but nothing as of yet is working. As noted in an earlier post I am using GenABEL. In an attempt to read in the phe

Re: [R] Subset Question

2010-02-25 Thread Erik Iverson
Chertudi wrote: Hello helpful R folks, First off, please forgive my English. Second, I'm new with R, I've searched the archives about subsets, and I haven't found quite the help I need. I'm currently analysing a population survey whose data set has about 15000 households (the rows/observati

Re: [R] text editors

2010-02-26 Thread Erik Iverson
Dwayne Blind wrote: Dear all, Do you use a text editor ? What would you recommend for Windows users ? What about Tinn-R ? Dwayne, Perhaps you have seen http://www.sciviews.org/_rgui/ , it has information on several possibilities. It would be hard to pull me away from using Emacs with ESS

Re: [R] R Experts

2010-02-26 Thread Erik Iverson
Hello, Ryan Kinzer wrote: I am trying to understand why R is working in a particular way. I have a data set with two variables; mark date (markd) and recap date (recapd). I would like to know the number of days between capture dates. But if I subtract recap date from mark date I often get the

Re: [R] How to add a variable to a dataframe whose values are conditional upon the values of an existing variable

2010-02-26 Thread Erik Iverson
You mention ifelse, so for completeness, I will show you a solution that should work with that. There are other plenty of other possibilities though, I am sure. The follow is not tested.. Assume 'my.df' is your data.frame, containing a variable "DOW". my.df$DOW1 <- ifelse(my.df$DOW == "SAT",

Re: [R] R Experts

2010-02-26 Thread Erik Iverson
Ryan Kinzer wrote: Erik Thanks for helping. Both of them are factors. That's the problem, they need to be of class Date. See the R NEWS article about Date classes in Volume 4/1. http://cran.r-project.org/doc/Rnews/ I don't see how they could be factors though, since you shouldn't be

Re: [R] quickest way convert 1-col df to vector?

2010-03-08 Thread Erik Iverson
sjaffe wrote: anything shorter than as.vector(as.matrix( df ) )? df[[1]] __ 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 comm

[R] page boundaries for latex printing of summary.formula objects in Hmisc

2010-03-08 Thread Erik Iverson
this but immediately ran into some misconceptions I had about how continuous variables are represented internally within the latex function. Is there any easier way to accomplish this breaking of pages on variable boundaries using this set of functions? I suspect not, but thought I'd ask. I

Re: [R] Problem with mean

2010-03-09 Thread Erik Iverson
See FAQ 7.31 venkata kirankumar wrote: Hi all, I got one intresting problem with caliculating mean that is while i am taking mean of values *0.6, -0.8, 4, -3.8* using *val<-c(0.6, -0.8, 4, -3.8)* *mean(val)* it given result as *2.775558e-17* but the actual result is *"0"* can any one sugge

Re: [R] How good is R at making publication quality tables?

2010-03-17 Thread Erik Iverson
Paul Miller wrote: Hello Everyone, I have just started learning R and am in the process of figuring out what it can and can't do. I must say I am very impressed with R so far and am amazed that something this good can actually be free. Recently, I finished reading R for SAS and SPSS Users and

Re: [R] How to use "ifelse" to generate random value from a distribution

2010-03-17 Thread Erik Iverson
alex46015 wrote: I think I figure it out. ifelse(data1$x==1,rnorm(12,2,1),ifelse(data1$x==2,rnorm(12,-2,1),rnorm(12,110,1))) Where is the number 12 coming from? Is that the length of data1$x? Here is a sample using the fact that rnorm can accept vectors of means and sds. My x is rand

Re: [R] Locating an error

2010-03-17 Thread Erik Iverson
Worik R wrote: Related: I found the problem eventually. It was a parameter that was too large and the function called "stop". Looking at the documentation I see I can supply my own error handler. Cool. Are there already written error handlers that dump a stack trace? Is ?traceback what you

Re: [R] multiple logical comparisons

2010-03-21 Thread Erik Iverson
Martin Batholdy wrote: Hi, I would like to compare a column of data with a vector. I have this data.frame for example; x <- data.frame(A = c(1:5), B = c(1,1,2,2,2)) Now I have a search vector: search <- c(1,3,5) when I now try to get all the data-rows which have a 1, a 3, or a 5 in column

[R] quoting expressions in a list

2009-07-16 Thread Erik Iverson
side individually for each component: names(list.example) <- c("df.example$a > 7", "df.example$b < 4") Any ideas? Best Regards, Erik Iverson __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listi

  1   2   3   4   5   6   7   8   >