Re: [R] SAPPLY function XXXX

2011-05-04 Thread Erik Iverson
Dan, I am attempting to write a function to count the number of non-missing values of each column in a data frame using the sapply function. I have the following code which is receiving the error message below. n.valid-sapply(data1,sum(!is.na)) Error in !is.na : invalid argument type

Re: [R] SAPPLY function XXXX

2011-05-04 Thread Erik Iverson
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=sapply(data1,sum(is.na)))

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 or

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 on the

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 by

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, but

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

2011-02-15 Thread Erik Iverson
Julia, While not a direct answer to your question, you may find the pgfSweave driver/package to be interesting. http://cran.r-project.org/web/packages/pgfSweave/ Among other things, it uses the tikzDevice package for figures, which will cause the labels and text to use the same font as in your

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
On 02/09/2011 09:21 PM, Benjamin Caldwell wrote: Am trying to merge about 15 .csv tables - tried a test run but came up with 0 rows (no data for each variable/column head) CAHSEE.EA.feb.2009-read.csv(2009 CAHSEE EA feb 2009.csv, header=TRUE) CAHSEE.IM.MATH.2009-read.csv(2009 CAHSEE Impact

Re: [R] Merging by factor variables

2011-02-02 Thread Erik Iverson
H Roark wrote: I'm wondering about the behavior of the merge function when using factors as by variables. I know that when you combine two factors using c() the results can be odd, as in: c(factor(1:5),factor(6:10)) which prints: [1] 1 2 3 4 5 1 2 3 4 5 I presume this is because factors

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
Suppose I have a function, like list, that takes a variable number of arguments, and I have those arguments in some vector x. How can execute the function with the *contents* of x as its arguments? I.e., I don't want list(x), but rather list(x[[1]], x[[2]], ..., x[[n]]), but I don't want to

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 -

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.

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] 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

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] Changing names of a string variable

2010-12-07 Thread Erik Iverson
Hello, To do what you want, see ?toupper : levels(dat$target) - toupper(levels(dat$target)) However, for clarity, dat$target is not a string variable, it is a factor, which you can verify with str(dat) Factors are enumerated types, and have a discrete set of 'levels' associated with them,

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
On 12/07/2010 05:29 PM, Paul Miller wrote: Hello Everyone, Been learning R over the past several months. Read several books and have learned a great deal about data manipulation, statistical analysis, and graphics. Now I want to learn how to make nice looking documents and about literate

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

2010-12-02 Thread Erik Iverson
On 12/02/2010 09:35 PM, Jinsong Zhao wrote: Hi there, In function, it's usually using ``='' to assign default value for function argument. For newbie, it's possible to using ``- '' to assign value for function argument. Although it's not a correct way, R don't give any warning message.

Re: [R] how to update my own function

2010-11-23 Thread Erik Iverson
Edwin - I think the usual way to do this would be to use a function like lapply or mapply to call your function multiple times with varying arguments. For example, with one varying argument: lapply(list(3,5), test, z = 4) With multiple varying arguments: mapply(test, y = list(3,5), z = list(4,

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
Well, %in% returns a logical vector... So subset(dat, ! ID %in% someID) Also, from ?subset: Note that ‘subset’ will be evaluated in the data frame, so columns can be referred to (by name) as variables in the expression Thus, you don't need 'dat$ID', bur just 'ID' in the subset

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
Just read the help page :). This is under Note in the ?pdf. On some systems the default plotting character ‘pch = 1’ is displayed in some PDF viewers incorrectly as a ‘q’ character. (These seem to be viewers based on the ‘poppler’ PDF rendering library). This may be due to

Re: [R] Loop

2010-11-04 Thread Erik Iverson
Hello, The best way to get help from people on the list is for you to give us *reproducible* examples of exactly what is you want. Usually, you can come up with some sample data and code that corresponds to your situation, and that we can run directly by cutting and pasting from the email. You

Re: [R] Converting Strings to Variable names

2010-11-04 Thread Erik Iverson
Anand Bambhania wrote: Hi all, I am processing 24 samples data and combine them in single table called CombinedSamples using following: CombinedSamples-rbind(Sample1,Sample2,Sample3) Please use reproducible examples. Now variables Sample1, Sample2 and Sample3 have many different

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
The learning curve of R is rather steep at start. Yes, it can be. I think the general advice would be to get a good Intro to R book if you're just starting out. That's certainly my advice. Or, get a book on some methods you're interested in that uses R (the Springer useR! series is really

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
alas, should R not come with an is.defined() function? ?exists a variable may never have been created, and this is different from a variable existing but holding a NULL. this can be the case in the global environment or in a data frame. is.null(never.before.seen) Error: objected

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 that

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
Hadley's reshape package (google for it) can do this. There's a nice intro on the site. library(reshape) cast(melt(mydf, measure.vars = value), city ~ brand, fun.aggregate = sum) city x y z 1a 3 23 450 2b 12 42 231 Although the numbers differ slightly? I've heard of

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] 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

Re: [R] Importing CSV File

2010-10-24 Thread Erik Iverson
On 10/24/2010 04:57 PM, Jason Kwok wrote: I'm trying to import a CSV file into R and when it gets imported, the entries get numbered down the left side. How do I get rid of that? When you imported the CSV file into R, an object of class data.frame was created, and since you did not assign it

[R] Question on passing the subset argument to an lm wrapper

2010-10-24 Thread Erik Iverson
Hello, How would you go about handling the following situation? This is on R 2.12.0 on Ubuntu 32-bit. I have a wrapper function to lm. I want to pass in a subset argument. First, I just thought I'd use ## make example reproducible set.seed(123) df1 - data.frame(age = rnorm(100, 50, 10),

Re: [R] change library path (for dummies)

2010-10-21 Thread Erik Iverson
?.libPaths clee wrote: hi all, How can I change the library path in R? I don't have permission to write to the default R library on the computer I am running R on. I have searched the forum and have not found anything that I understand, so I apologize if this has been asked before. Thanks

Re: [R] Coin Toss Simulation

2010-10-13 Thread Erik Iverson
Shiv wrote: I am trying a simple toin coss simulation, of say 200 coin tosses. The idea is to have a data frame like so: Experiment#Number_Of_Heads 1 104 296 3101 So I do: d -data.frame(exp_num=c(1,2,3)); /*

Re: [R] Regular expression to find value between brackets

2010-10-13 Thread Erik Iverson
Bart, I'm hardly one of the lists regex gurus: but this can get you started... tests - c(pH, Assay (%), Impurity A(%), content (mg/ml)) x - regexpr(\\((.*)\\), tests) substr(tests, x + 1, x + attr(x, match.length) - 2) Bart Joosen wrote: Hi, this should be an easy one, but I can't figure

Re: [R] Change global env variables from within a function

2010-10-13 Thread Erik Iverson
Hello, Jon Zadra wrote: Hi, I've looked all over for a solution to this, but haven't had much look in specifying what I want to do with appropriate search terms. Thus I'm turning to R-help. In the process of trying to write a simple function to rename individual column names in a data

Re: [R] loop

2010-10-13 Thread Erik Iverson
Julia, Can you provide a reproducible example? Your code calls the 'rq' function which is not found on my system. Any paring down of the code to make it more readable would help us help you better, too. Julia Lira wrote: Dear all, I am trying to run a loop in my codes, but the software

Re: [R] vectorizing: selecting one record per group

2010-10-13 Thread Erik Iverson
Hello, There are probably many ways to do this, but I think it's easier if you use a data.frame as your object. The easy solution for the matrix you provide is escaping me at the moment. One solution, using the plyr package: library(plyr) A - data.frame(a = rnorm(100),b = runif(100), c =

Re: [R] Import Multiple csv files and merge into one Master file

2010-10-07 Thread Erik Iverson
See the R Data Import/Export manual for the first step: http://cran.r-project.org/doc/manuals/R-data.html ?read.table should help you out. You might use ?lapply along with read.table to read in multiple files. Then, use ?merge, possibly in tandem with the ?Reduce function, depending on how

Re: [R] selected value in a vector to make bold

2010-10-06 Thread Erik Iverson
What output medium? On a graphic? In LaTeX ouput? Or do you mean in the R console? Joe P King wrote: I wasn't sure about the subject so I am sorry about the vagueness, but if I have a vector of values, how do I get a certain type of vectors to be bold or italics? So let x be a vector from

Re: [R] tapply output

2010-10-06 Thread Erik Iverson
Hello, You can use ddply from the very useful plyr package to do this. There must be a way using base R functions, but plyr is worth looking into in my opinion. install.packages(plyr) library(plyr) ddply(myData, .(class, group, name), function(x) mean(x$height)) class group name V1 1

Re: [R] R editor in ubuntu!

2010-10-05 Thread Erik Iverson
Another alternative is to use Geany [1]. It would save you the trouble of learning Emacs, /s/save/deprive /s/trouble/thrill :) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] r-help@r-project.org

2010-10-05 Thread Erik Iverson
1) Please use an informative subject line 2) The answer may depend on the package, and can be easy to difficult. Which package are you trying to install? wenyue sun wrote: *Dear All, * ** *I want to install tar.gz in R on a Windows operating system. I know that R in Win accepts packages

Re: [R] cleaning up a vector

2010-10-01 Thread Erik Iverson
Mike, Small, reproducible examples are always useful for the rest of the us. x - c(0, NA, NaN, 1 , 10, 20, 21, Inf) x[!is.na(x) x =1 x= 20] Is that what you're looking for? mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data

Re: [R] gridExtra question

2010-10-01 Thread Erik Iverson
Well, a quick check of http://r-forge.r-project.org/bin/windows/contrib/ shows that there is no 2.10 directory, possibly because it's not very new, 2.12 is scheduled for release in 2 weeks. Felipe Carrillo wrote: Hi: I get a couple of warnings when trying to download gridExtra:

Re: [R] gridExtra question

2010-10-01 Thread Erik Iverson
Forgot to mention you should be able to install from a CRAN mirror. Felipe Carrillo wrote: Hi: I get a couple of warnings when trying to download gridExtra: install.packages(gridExtra,repos=http://R-Forge.R-project.org) Warning: unable to access index for repository

Re: [R] can I add line breaks to the paste() function?

2010-09-30 Thread Erik Iverson
Hello, Although on the surface a simple request, I think you need to be more specific. ?paste returns a character vector. The first question is: do you want a character vector of length 1 or 2? It sounds like you're trying to format text for display on screen or on a graphics device. Perhaps

Re: [R] defining set of variables in a formula

2010-09-22 Thread Erik Iverson
Ozlem, Just read ?formula, where it says: There are two special interpretations of ‘.’ in a formula. The usual one is in the context of a ‘data’ argument of model fitting functions and means ‘all columns not otherwise in the formula’: see ‘terms.formula’. In the context of

Re: [R] import csv file problem

2010-09-22 Thread Erik Iverson
On 09/22/2010 07:24 PM, sisxy wrote: Hello, i am trying to import the csv file into R . i have a file saved as csv in my desktop. My laptop is Window vista, version R is 2.10.1. then i used the code Q-read.csv(Q.csv,header=TRUE) R will search in its working directory for Q.csv. What is the

Re: [R] Trouble installing pwr package

2010-09-21 Thread Erik Iverson
Brian J Mingus wrote: Hi all, I'm having trouble getting access to the pwr. This is on Ubuntu Lucid Lynx, 64 bit. I'm installing pwr via packages.install('pwr'), and loading it via library(pwr), both of which appear successful. Perhaps the actual output would help here. Strangely, I

Re: [R] Trouble installing pwr package

2010-09-21 Thread Erik Iverson
Erik Iverson wrote: Brian J Mingus wrote: Hi all, I'm having trouble getting access to the pwr. This is on Ubuntu Lucid Lynx, 64 bit. I'm installing pwr via packages.install('pwr'), and loading it via library(pwr), both of which appear successful. Perhaps the actual output would help

Re: [R] Web forum - should I make one?

2010-09-21 Thread Erik Iverson
Everyone is free to create as they please. My opinion is that between this list and stackexchange (as Tal pointed out), that there isn't a market for such a thing. If you want a web front-end to this list, such things exist, like nabble. Vojtěch Zeisek wrote: Hello, this might be little

Re: [R] R on ESS

2010-09-17 Thread Erik Iverson
On 09/17/2010 09:52 PM, Stephen Liu wrote: Hi folks, Debian 504 64-bit Emacs Version 22.1.1 I have Emacs+ESS running on the box. R can work on ESS. But the fonts on the menu bar (top) of Emacs are NOT clear, difficult to read, grey foreground. I have been googling around for solution

Re: [R] How to check the available of a package on R repo

2010-09-17 Thread Erik Iverson
What are you trying to do? Did you look at the arguments for the first argument of ?available.packages ? What did you expect emacs to do? On 09/17/2010 10:20 PM, Stephen Liu wrote: Hi folks, Debian 504 64-bit What is the correct syntax to check the available of a package on R repo?

Re: [R] Local Variable

2010-09-16 Thread Erik Iverson
Sarah Goslee wrote: Leaving aside the question of whether this is a good thing to do, Let's not leave that aside. Surely there is a much more straight-forward way to accomplish what you want. Why not store all the X's in a vector, and then you can avoid this for/assign/get hack. you can

Re: [R] Sas to R

2010-09-15 Thread Erik Iverson
Sarah, This is a SAS question, not R. However, it seems clear that it has something to do with the fact that there are spaces in the command that you're sending to Windows. Maybe try calling with the 'short directory name' notation, I forget what that's called in Windows. Or else follow-up on

Re: [R] Sas to R

2010-09-15 Thread Erik Iverson
David Winsemius wrote: On Sep 15, 2010, at 1:44 PM, Sarah Jilani wrote: Hi, I need to call an R program from Sas. I have tried using the following code in Sas using the x command but it just calls up dos and says I went searching for a worked example and found this:

Re: [R] Model fitting

2010-09-15 Thread Erik Iverson
Diogo B. Provete wrote: I have a data set and I want to procedure to model fitting (e.g., Poisson, Gausian, binomial, quasipoisson etc.). I'd like to know if there is an easier way to do this in R. Easier than what ? There is no shortage of R functions and packages to fit almost any type of

Re: [R] Reading highest numbered file

2010-09-14 Thread Erik Iverson
See ?list.files and ?file.info. E.g., file.info(list.files(~/tmp, full.names = TRUE)) Michael D wrote: I have a bunch of files named [identifier1].[identifier2].[mmdd].[hhmmss].txt and im having trouble updating my read script for the timestamp. I've been using file.exists and a for loop

  1   2   3   4   5   6   7   8   >