Re: [R] concise syntax for selecting multiple rows

2010-04-26 Thread Erik Iverson
See ?%in% result$Subject %in% c(JEFF, BG) John Sorkin wrote: I would like to select rows if a row contains any one of several values. I can do the selection as follows: result[,Subject]==JEFF | result[,Subject]==BG But this is very unwieldily if one wishes to select many, many rows as one

Re: [R] Help with replacement of certain values in dataset with SAS code equivalent

2010-04-26 Thread Erik Iverson
What I want to do is to be able to select certain FTIStandKey's and change values in the dataset. For example, I would like to select by FTIStandKey==NAH6253-003, and change the entries for CoverType= XSOP--C and change the V_SpGrp==T, and also change V_Origin==T. I only want to change

Re: [R] Passing values to a function when using apply

2010-04-27 Thread Erik Iverson
This is not a reproducible example. You might simply want: apply(veh_drg_animal1[, c(readCount, gene_length)], 1, stats, arg2, arg3) But your two parameters from the data.frame are really going to be passed as one vector, and then within the stats function you can access them individually.

Re: [R] Passing values to a function when using apply

2010-04-27 Thread Erik Iverson
Henrique Dallazuanna wrote: try this: apply(veh_drg_animal1[ ,c(readCount,gene_length)] ,1, function(x)stats(x[1], x[2], total=5500)) I agree with this, that was my point in my original reply. Apply is *not* passing 2 arguments simply because you are selecting two columns of the

Re: [R] Passing values to a function when using apply

2010-04-27 Thread Erik Iverson
Abhishek Pratap wrote: Hi Guys Thank you for clearing something I dint know. Just wondering the reason of putting the word function(x) in the apply function when we have already declared stats function separately. I better understand how the arguments are passed. Thanks! -Abhi That's

Re: [R] How to read contents of a text file into a single string?

2010-04-28 Thread Erik Iverson
Dimitri Shvorob wrote: ... Both readLines() and scan() produce a number_of_lines x 1 vector; trying paste(s, collapse = NULL) leaves it unaffected. How can I concatenate vector elements (lines) into a single string? Thank you. Read ?paste, specifically: If a value is specified for

Re: [R] data frame move columns

2010-04-28 Thread Erik Iverson
avprix - structure(list(DESCRIPTION = c(CORN Jul/10, CORN May/10, ROBUSTA COFFEE (10) Jul/10, SOYBEANS Jul/10, SPCL HIGH GRADE ZINC USD, STANDARD LEAD USD), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8, 2, -1, 0), fees = c(-8.64, -30.24, -26.4, -25.92, -37.5,

Re: [R] bwplot - scattered

2010-04-28 Thread Erik Iverson
someone wrote: Hi, I'm using the bwplot from the agsemisc package which has a scattered attribute which can be set so that the single dots can bee seen better. my problem is, that I am having so many dots that they still overlap. I could increase the output of the diagram but thats not really

Re: [R] Size limitations for model.matrix?

2010-04-28 Thread Erik Iverson
gerald.j...@dgag.ca wrote: Hello, I am running: R version 2.10.0 (2009-10-26) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 on a RedHat Linux box with 48Gb of memory. I am trying to create a model.matrix for a big model on a moderately large data set. It

Re: [R] EBCDIC

2010-04-29 Thread Erik Iverson
Perhaps ?read.table, ?file, and ?iconv will offer some information about how to use different encodings in R. Michael Steven Rooney wrote: Does R have package/function that can read a file that has been downloaded from a mainframe in EBCDIC format? Thanks, Mike [[alternative HTML

Re: [R] getting random integers

2010-04-29 Thread Erik Iverson
Hans Ekbrand wrote: I want 100 integers. Each integer, x, can be in the range 1 = x = 10. Does the following code give 1 and 10 the same chances to be selected as 2:8? round(runif(100, min = 1, max = 10)) If you just want to sample integers, use ?sample

Re: [R] Upgrade process for libraries: can I use installed.packages on an old installation followed by install.packages in a new one

2010-04-29 Thread Erik Iverson
Ted Byers wrote: I tend to have a lot of packages installed, in part because of a wide diversity of interests and a disposition of examining different ways to accomplish a given task. I am looking for a better way to upgrade all my packages when I upgrade the version of R that I am running.

Re: [R] Is it possible to transform a factor to a number like this way?

2010-04-29 Thread Erik Iverson
song song wrote: such a factor as a=as.factor(c(1.23, 4.56, 7.89)) and I want to get this vector: c(1.23, 4.56, 7.89). You're told how to do this in the help page for ?factor. See the Warning section. __ R-help@r-project.org mailing list

Re: [R] dopar parallel assignments

2010-04-29 Thread Erik Iverson
Vivek Ayer wrote: Hi guys, I was wondering why this piece of code doesn't work: foreach (i = c(1.25,1.50)) %dopar% { assign(paste(test_,i,sep=),i) } but, this does: foreach (i = c(1.25,1.50)) %do% { assign(paste(test_,i,sep=),i) } ... and which package are these functions in?

Re: [R] replace elements in a list

2010-04-29 Thread Erik Iverson
Wincent wrote: Dear all, I have a list like this: l - list(list(a=1,b=NULL), list(a=2,b=2)) I want to find out the elements with value of NULL and replace them with NA. The actual case has a very long list, so manually find out and replace them is not an option. I can use for loop to do this,

Re: [R] Why do data frame column types vary across apply, lapply?

2010-04-30 Thread Erik Iverson
I still have little ability to predict how these functions will treat the columns of data frames: All of this is explained by knowing what class of data functions *work on*, and what class of data *you have*. # Here's a data frame with a column a of integers, # and a column b of

Re: [R] Why do data frame column types vary across apply, lapply?

2010-04-30 Thread Erik Iverson
See ?apply. The apply function works on *matrices*. Actually arrays, and matrices are arrays with 2 dimensions. characters. This is all explained in the first paragraph of ?apply. Also see ?as.matrix __ R-help@r-project.org mailing list

Re: [R] Likelihood ratio based confidence intervals for logistic regression

2010-04-30 Thread Erik Iverson
jh556 wrote: I'm applying logistic regression to a moderate sized data set for which I believe Wald based confidence intervals on B coefficients are too conservative. Some of the literature recommends using confidence intervals based on the likelihood ratio in such cases, but I'm having

[R] confused on model.frame evaluation

2010-04-30 Thread Erik Iverson
Hello! I'm reading through a logistic regression book and using R to replicate the results. Although my question is not directly related to this, it's the context I discovered it in, so here we go. Consider these data: interco - structure(list(white = c(1, 1, 0, 0), male = c(1, 0, 1, 0),

Re: [R] confused on model.frame evaluation

2010-04-30 Thread Erik Iverson
snip I'm sure it's not a bug, but could someone point to a thread or offer some gentle advice on what's happening? I think it's related to: test - data.frame(name1 = 1:5, name2 = 6:10, test = 11:15) eval(expression(test[c(name1, name2)])) eval(expression(interco[c(name1, test)])) scratch

Re: [R] / Operator not meaningful for factors

2010-05-03 Thread Erik Iverson
The stringAsFactors = False option did not work either. False FALSE in addition Vincent was getting an error since he used stringAsFactors, instead of stringsAsFactors as the argument name. __ R-help@r-project.org mailing list

Re: [R] t.test per line

2010-05-05 Thread Erik Iverson
Mohamed Lajnef wrote: Dear All, I apologize for this trivial question, I can not find the solution I try to use t.test function per line in the data.frame, But i dont'understand the error message my program is as follows group1-gl(2,20) fun-function(x){ m-data.frame(group1,x)

Re: [R] Using statistical test to distinguish two groups

2010-05-05 Thread Erik Iverson
One of many possible approaches is called k-means clustering. my.data - c(1,2,3,2,3,2,3,4,3,2,3,4,3,2,400,340,3,2,4,5,6,4,3,6,4,5,3) split(my.data, kmeans(my.data, 2)$cluster) $`1` [1] 400 340 $`2` [1] 1 2 3 2 3 2 3 4 3 2 3 4 3 2 3 2 4 5 6 4 3 6 4 5 3 Ralf B wrote: Hi R friends, I am

Re: [R] Read data from .csv file as a matrix

2010-05-05 Thread Erik Iverson
Hello, I have a csv file that contains weather observation (rows) by days (in columns). I open using: temp = read.csv(Weather.csv, sep=,) and read: X X1.Jan X2.Jan X3.Jan X4.Jan 1 Min 2 3 4 1 2 Max 6 10 8 6 3

Re: [R] ordering data frame

2010-05-05 Thread Erik Iverson
phoebe kong wrote: Hi all, I have problem in ordering data frame. Could anyone help me? x [,1] [,2] [,3] [1,] A 1 2 [2,] G 3 2 [3,] E 2 3 y [,1] [,2] [,3] [1,] G 3 3 [2,] A 3 3 [3,] E 3 3 Are these really data.frames? They looks like matrices. You do not provide

Re: [R] Dynamic clustering?

2010-05-05 Thread Erik Iverson
Hello, Ralf B wrote: Are there R packages that allow for dynamic clustering, i.e. where the number of clusters are not predefined? I have a list of numbers that falls in either 2 or just 1 cluster. Here an example of one that should be clustered into two clusters: two -

Re: [R] Has Anyone created any good R wallpapers ?

2010-05-05 Thread Erik Iverson
Paul wrote: I was googling around today to see if anyone had created any R wallpapers, given some of the amazing graphics that can be created with R I'd like to display the capabilities for others. I didn't come up with much. Don't know what you mean by 'wallpaper'. This site has a bunch

Re: [R] any function in R similar to the scan function in SAS?

2010-05-05 Thread Erik Iverson
karena wrote: I am wondering if there is any function in R that is similar to the scan function in SAS. I have a data.frame which has two columns as the following: one two 1 2 3 4 5 6 I used the paste function to create the third column: three - paste(one,'-',two,sep=) so the

Re: [R] stopping emails

2010-05-05 Thread Erik Iverson
Steve Hempell wrote: I would like to stop recieving all the emails from R-Help. I cannot get back to the preference page given when I first registered. How do I stop the e-mails? It's in the footer of all emails from the list. https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] Merge Multiple Datasets

2010-05-06 Thread Erik Iverson
Wang, Kevin (SYD) wrote: Hi, I've got a bunch of datasets (each has an ID column) that I'd like to merge into one big datasets. After a google search I found http://tolstoy.newcastle.edu.au/R/help/05/08/11131.html . However, I'm wondering if there is an easy way to do this as I've got about

Re: [R] Dataframe horizontal scrolling

2010-05-10 Thread Erik Iverson
Perhaps even ?View would be useful here. I've never used R Commander, so don't know it would be useful in that environment. Michael H wrote: R experts, I am working with large multivariable data frames ( 50 variables) and I would like to scroll horizontally across my output to view each

Re: [R] Is there an easier way to replace the object name in the R code

2010-05-11 Thread Erik Iverson
mam3xs wrote: Hi all, I have a R code with quite a few lines. For instance AA - read.csv(C:\\AA.txt) AA.diff - diff(log(AA)) . Now I want to re-define the code with different object, like BB, CC..ZZ(the codes are the same). Thus, I was wondering whether their is an efficient way

Re: [R] what the problem could be if i am suddenly unable to add abline to the scatter plot?

2010-05-12 Thread Erik Iverson
David Winsemius wrote: On May 12, 2010, at 11:57 AM, xin wei wrote: I am doing very regular stuff like the following: attach(wtana) fm- lm(Body.Wt.on.SD1~Heart.Wt, data=wtana) #fm- lm(wtana$Body.Wt.on.SD1~wtana$Heart.Wt) lrf- loess(Body.Wt.on.SD1~Heart.Wt, wtana) #lrf-

Re: [R] Reading R code help--Beginner

2010-05-12 Thread Erik Iverson
Hi, I am brand new to R and not familiar with the language, though I have been reading the manuals and making some slow going progress. I am working with some source code from a Global Vector Auto -Regressive program written by Ranier Puhr from the R-forge group. I need help interpreting the

Re: [R] difference along a vector

2010-05-12 Thread Erik Iverson
help.search(difference) would lead you to ?diff, see the lag argument Clark Johnston wrote: I was looking for a function which would take the difference along a vector? a-c(1,12,23,44,15,28,7,8,9,10) if I set the number difference to 3 would return 43 2 5 -37 -7 -19 3 or do I need to

Re: [R] Changing R opening message

2010-05-12 Thread Erik Iverson
gvrocha wrote: Hi, I am using some python code to execute small R code snippets. I would like to save the messages output to the screen when R is executed. However, I will just save the opening message a zillion times since many thousands of little snippets will be executed.

Re: [R] manipulating a matrix

2010-05-12 Thread Erik Iverson
Clark Johnston wrote: Is there a way to create a new matrix from and existing matrix with A [,1] [,2] [1,] 113 [2.] 218 [3,] 314 [4,] 420 if(A[,2] 15) B [,1] [,2] [1,] 2 18 [2,] 4 20 It's

Re: [R] a question about latex in Hmisc

2010-05-12 Thread Erik Iverson
Shi, Tao wrote: Hi list, Excuse me b/c this is probably a more TeX then R question. I've been using latex function in my .Rnw file to generate tables, but I've always been using it without assigning the result to a object, i.e. x - matrix(1:6, nrow=2,

Re: [R] a question about latex in Hmisc

2010-05-12 Thread Erik Iverson
Ista Zahn wrote: Hi Tao, I think you just need latex(x, file=) I think I misunderstood the question, I believe that is what is needed here. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] Path to R script

2010-05-12 Thread Erik Iverson
While not a direct answer to your question, do ?getwd and ?setwd help at all? Johannes W. Dietrich wrote: There is certainly a trivial solution for my question, but I can't find the answer in the documentation. I need a platform independent method to obtain the file path of the current R

Re: [R] a question about latex in Hmisc

2010-05-12 Thread Erik Iverson
Shi, Tao wrote: Hi Richard, Obviously, the list doesn't like my attachment. Here it is: http://i41.tinypic.com/15qz387.jpg I set the path using Windows control panel. And didn't work means I'm still getting the same error window shown above. Well, it's hard to say what's going on

Re: [R] Calling a list element

2010-05-12 Thread Erik Iverson
The key is that [ is a function. So, you have a list, you want to apply a function to a list, and return a vector, think sapply. sapply(strsplit(as.character(Elecciones$Municipios),\\.), [, 1) Luis Felipe Parra wrote: Hello, i have the following list

Re: [R] A primitive OO in R -- where next?

2010-05-12 Thread Erik Iverson
(Ted Harding) wrote: Greetings All, Out of curiosity, I've just done a very primitive experiment: Obj - list(Fun=sum, Dat=c(1,2,3,4)) Obj$Fun(Obj$Dat) # [1] 10 That sort of thing (much more sophisticated) must be documented mind-blowingly somewhere. Where? Where I stand right now:

Re: [R] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson
Felipe Carrillo wrote: HI: If you don't mind me asking this question about latex: Based on Duncan's comment: The print method for latex objects tries to run latex and then display the resulting .dvi file. (Or maybe it runs pdflatex and displays the .pdf file). Where in MikTex can I change to

Re: [R] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson
Looks good. I came up with something on my own which was basically to re-write print.latex. I call pdflatex a few times because with the longtable package, sometimes things don't line up right until you run pdflatex multiple times. I think mine is less flexible though, and I like your

Re: [R] Help with reading information of summary-Object

2010-05-13 Thread Erik Iverson
Hello, Tino Schöllhorn wrote: Hi, I am quite new to R - but quite expierience in programming. Welcome to R! It's easiest if you give reproducible examples so we can help you. You can include code to create objects, or use the ?dput function. Nonetheles I have some problemes in

Re: [R] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson
snip Notice that I didn't quite get my function into the Hmisc environment and that is why you need the awkward phrase show.dvi(dvi(x.tex - latex(x))) instead of the smooth phrase latex(x) Somehow with my own data and not using the awkward bit, it worked on my Linux machine? At

Re: [R] Access to files downloaded

2010-05-13 Thread Erik Iverson
Joey Zhou wrote: Dear All: I downloaded gee source code and now I am having problem accessing the file. download.packages(gee, type=source, destdir=~) --- Please select a CRAN mirror for use in this session --- trying URL '

Re: [R] How to display data values for points in a plot?

2010-05-13 Thread Erik Iverson
Nish wrote: Hello, I would like to know how to display values for points in a plot funtion. For example, plot( y=dat$a, x=dat$b, main=plot1, ylab=a, xlab=b, ylim=c(-10, 10), xlim=c(-10, 10), type = p, pch=17, col=vector of colors

Re: [R] Simple question on binning data

2010-05-13 Thread Erik Iverson
There would be several people who could help if you gave us a minimal, reproducible example like the posting guide asks for. If you have a vector of continuous data, and need to create a categorical variable (in R, a factor) from that continuous variable, then ?cut can help you.

Re: [R] Adding name to nth row

2010-05-13 Thread Erik Iverson
We need a self-contained, reproducible example of what you have, and what you want. Is this close? tmp - data.frame(a = rnorm(278)) tmp$newcol - tmp[seq(97,278, by = 12), newcol] - A Name ecvet...@uwaterloo.ca wrote: Hello, I have a data frame with many rows, and I want to create a column

Re: [R] frequencies of time series data

2010-05-13 Thread Erik Iverson
Hello, Adam Sean wrote: I have an excel file in following shape: date Category 01/21/2010turf 01/21/2010jack 01/21/2010jack 01/22/2010 turf 01/22/2010 jack 01/22/2010 psi 01/22/2010 psi 01/22/2010 psi 01/23/2010 turf 01/23/2010 turf 01/23/2010 jack

Re: [R] SAS for R-users

2010-05-14 Thread Erik Iverson
Thomas Levine wrote: There are loads of resources for users of any other statistics package who are learning R. For example http://www.google.com/search?q=r+for+sas-users; The reverse isn't the case http://www.google.com/search?q=sas+for+r-users; snip I can't wait that long. Until then

Re: [R] insert values based on common ID

2010-05-14 Thread Erik Iverson
Hello, Good reproducible example. Is merge(a[names(a) != weekAvg], b) what you want? emorway wrote: Forum, with the datasets a and b below, I'm trying to establish a relationship based on the common column week and insert the value from the column weekAvg in b to the column weekAvg in a.

Re: [R] max number from a list of numbers

2010-05-20 Thread Erik Iverson
You have a list that you want to treat as a vector, so ?unlist it. Jonathan wrote: Hi all, I'm hoping this question has a simple answer, but I can't find it through searching or trying commands. I have a list of numeric vectors called 'husk'. I'd just like to treat the set of all numbers

Re: [R] multiple qplot histograms in one plot

2010-05-21 Thread Erik Iverson
rajesh j wrote: Hi, I wish to plot multiple histograms(representing different data so different range along xaxis but y axis is the same) horizontally in ggplot2. I'd like it to look like facets. Is this possible? Can you give a small example, say, using the diamonds dataset, or one of

Re: [R] loop for in and decimals

2010-05-21 Thread Erik Iverson
Robert U wrote: Dear R-users, I'm trying to make the following loop: for (x in 0 : 10) and i would like x to be decimals rather than integers, giving a x range of e.g. 0.0 0.1 0.2 0.3 ... 9.9, 10. Would anyone know how to do that ? Please start new threads when you have a new question, do

Re: [R] multiple qplot histograms in one plot

2010-05-21 Thread Erik Iverson
rajesh j wrote: Hi, I wish to plot multiple histograms(representing different data so different range along xaxis but y axis is the same) horizontally in ggplot2. I'd like it to look like facets. Is this possible? Can you give a small example, say, using the diamonds dataset, or one of

Re: [R] Error in FUN(X[[1L]], ...) : STRING_ELT() can only be applied to a 'character vector', not a 'integer'

2010-05-21 Thread Erik Iverson
Hello, PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. We don't know the function you're using or the data you applied the function to, which makes it almost impossible to help. Can you use ?dput

Re: [R] Increasing the maximum number of rows

2010-05-22 Thread Erik Iverson
Alex Ruiz E. wrote: Dear R helpers, I created a somewhat big database (+206,700 rows) in MySQL and have exported into a csv file, but I can't open the whole thing in R. I am using: base-read.csv(/path/to/file.csv, header=F, sep=, nrows=206720) R doesn't complain but it only opens 128,328

Re: [R] Bernoulli random variable with different probability

2010-05-22 Thread Erik Iverson
Carrie Li wrote: Dear R-helpers, I would like to generate a variable that takes 0 or 1, and each subject has different probabilities of taking the draw. So, which of the following code I should use ? snip I don't think either. Try this: probs - seq(0,1, by = .1) sapply(probs, function(x)

Re: [R] Selecting first 7 elements

2010-05-23 Thread Erik Iverson
Kang Min wrote: Hi, I have a list of 100, each list has 20 elements, and I would like to select the first 7 elements in each list. Let's take the alphabet as an example. x - lapply(1:100, function(i) sample(LETTERS)) I tried x[[1:7]], but it doesn't work. Can anyone enlighten me on how to do

Re: [R] Selecting first 7 elements

2010-05-23 Thread Erik Iverson
[ is a function, and you want to use it on each element of the list, so... lapply(x, [, c(1:7)) and the call to c() is of course not necessary, since : will generate a vector. __ R-help@r-project.org mailing list

Re: [R] importing columns as factors

2010-05-23 Thread Erik Iverson
Caitlin Sadowski wrote: I have a large csv table I am trying to read into R. I would like each column to be of type factor. However, most columns have only numeral entries (e.g. likert scales), so are automatically imported as type numeric. Is there a way to convert ALL columns to be of type

Re: [R] Error in FUN(X[[1L]], ...) : STRING_ELT() can only be applied to a 'character vector', not a 'integer'

2010-05-23 Thread Erik Iverson
Hello, sedm1000 wrote: Sorry - I figured that this to be a more common defined error than anything specific to the data/function... Thanks for looking at this. The data and function are below. Creating a single line of the data.frame at a time will work (i.e. fold(s)) For multiple line

Re: [R] How sample without replacement on more than one variables?

2010-05-23 Thread Erik Iverson
thmsfuller...@gmail.com wrote: Hello All, sample() only sample on one variable x. But I'm interested in sampling more than one variable without replacement. Suppose I have 3 vectors x, y, z. I want to draw samples from all three vectors such that the combination of the three elements in each

[R] creating a reverse geometric sequence

2010-05-23 Thread Erik Iverson
Hello, Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? For example, for a hypothetical function dg, I would like: dg(20) [1] 20 10 5 2 1 where I am using integer division by 2 to get each subsequent value in the sequence. There is of course:

Re: [R] list of complex objects?

2010-05-25 Thread Erik Iverson
Nick Matzke wrote: Hi all, If I would like to make a list of complex objects -- in my case, phylogenetic trees, but it could be e.g. statistical results from something like lm, or whatever -- how can I put them into a list? When I try the obvious methods, e.g. cat, append, list, etc., I

Re: [R] Counting indexes

2010-05-25 Thread Erik Iverson
Robin Jeffries wrote: Hallo! I have a vector of ID's like so, id - c(1,2,2,3,3,3,4,5,5) I would like to create a [start,stop] pair of vectors that index the first and last observation per ID. For the ID list above, it would look like 1 1 2 3 4 6 7 7 8 9 which(!duplicated(id)) [1] 1 2 4 7 8

Re: [R] How to: highlight R syntax on webpages ?

2009-11-20 Thread Erik Iverson
Hello, I wrote a Wordpress blog entry about not only highlighting R syntax, but embedding R commands within an entry and using Sweave to produce the R output, all within Emacs. The output of the process is ready to paste Wordpress HTML, and a few other R blogs have started using it to

Re: [R] how to change the class of a group of objects

2009-11-23 Thread Erik Iverson
Ben, In general, when you define a, b, and c as below, the c() wrapper is not needed, since the : operator returns a vector anyway. Also, best not to name variables 'c' to avoid confusion with the function you're using. Regarding your actual question, lapply(list(a, b, c), class-, dist)

Re: [R] From R to LaTeX to pdf?

2009-11-24 Thread Erik Iverson
While what you say is true for base R, someone already mentioned Hmisc's latex function, and I have written several custom functions to output tables in LaTeX, the benefit being the elimination of manual formatting and intervention when preparing tables. Add this in with Sweave and make files,

Re: [R] Random data

2009-11-25 Thread Erik Iverson
One option, first, generate the range of x data that you want, then add normally distributed noise to each x, these will be your y data. n - 20 x - sample(20:50, n) y - rnorm(n, mean = x, sd = 3) plot(y ~ x) Erik -Original Message- From: r-help-boun...@r-project.org

Re: [R] Importing many files from a single code

2009-11-25 Thread Erik Iverson
See the example in ?source, which does exactly this... or make a package depending on your needs. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ram basnet Sent: Wednesday, November 25, 2009 8:35 AM To: R help Subject: [R]

Re: [R] bug or bizarre feature?

2009-11-30 Thread Erik Iverson
Simply a manifestation of FAQ 7.31, i.e., a floating-point arithmetic issue. On my machine, 1.16 * 100 == 116 [1] FALSE -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rupert Mazzucco Sent: Monday, November 30, 2009 1:15

Re: [R] documentation of intersect() on string vector and num vector and on duplicated elements

2009-12-02 Thread Erik Iverson
intersect(c(1,3,2),c('1','3')) [1] 1 3 Apparently, intersect() treats num as string. But this is not documented in the help. Could somebody add it in the future version of R? This is more a general coercion feature. For example 1 == 1, see ?Comparison. Also according to the help, the

Re: [R] documentation of intersect() on string vector and num vector and on duplicated elements

2009-12-02 Thread Erik Iverson
It is documented that intersect will return a value of that is same mode as its y argument. How could it be any more clear? Oops, this makes my previous response to this question inaccurate, apologies. __ R-help@r-project.org mailing list

Re: [R] R will not load

2009-12-02 Thread Erik Iverson
The file is probably called .Rdata and is probably somewhere under your home directory on Windows, perhaps under C:\documents and settings\username or even C:\documents and settings\username\My Documents ? Hope that helps. I don't have R installed on Windows or I would narrow it down for

Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread Erik Iverson
One problem I've been having is the special case in which only one row/column remains and the variable gets converted into a vector when entries are removed by logical masking. This is a problem because subsequent code may rely on matrix operations (apply, colsums, dim, etc) For example:

Re: [R] Problem with if statement

2009-12-08 Thread Erik Iverson
You can use the ifelse function for vectorized conditionals like you have here. See ?ifelse. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Arthur Burke [art.bu...@educationnorthwest.org] Sent: Tuesday, December 08, 2009

Re: [R] Counting in Matrix

2009-12-15 Thread Erik Iverson
?rowSums -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tom Pitt Sent: Tuesday, December 15, 2009 2:57 PM To: r-help@r-project.org Subject: [R] Counting in Matrix Hi All, Is there an easy way to count TRUEs for each

Re: [R] counts of a vector

2010-05-26 Thread Erik Iverson
speretti wrote: Hi, I need help to find an efficient way to transform a vector like: a-c(1,1,0,1,0,0,0,1,1,1,1,0,1,0,1,1) in a vector that counts only di 1 elements, like: b-c(1,2,0,1,0,0,0,1,2,3,4,0,1,0,1,2) Thank you! One way: rl - rle(a) unlist(mapply(*, lapply(rl$lengths,

Re: [R] error variable names are limited to 256 bytes when sourcing code

2010-05-26 Thread Erik Iverson
Is the '`' character supposed to be there before the ## Add error bars comment? If that is the problem, let it be a good lessonto use an editor with syntax highlighting. :) Brian Frizzelle wrote: All, I think there may be some misunderstanding about my problem. In my code, which

Re: [R] R editor

2010-05-26 Thread Erik Iverson
Joris' suggestions are good ones. I use Emacs with ESS (and now org-babel) for R programming and for interaction with the R process. But I use Emacs for everything. Emacs is actually pretty easy to install these days on Windows, and Vincent Goulet provides a nice package with all you need to

Re: [R] wildcard operator

2010-05-26 Thread Erik Iverson
Eric Fail wrote: Hi Ruser As so usual I'm trying to replicate some SAS code. I wold like to know if there is a wildcard operators, as : in SAS, in R? When running: lm(y ~ x1 + x2 + x3 + x4 + x5 + x6 x9860, data=mydata) I would like to be able to get around it by just writing

Re: [R] How to catch Error Messages in R

2010-05-27 Thread Erik Iverson
?try g...@ucalgary.ca wrote: As we knew, if a function is not used correctly, an error message will throw/display in R: rnorm(-1) Error in rnorm(-1) : invalid arguments I would like to catch the error message or assign an error message to a variable so that I can use them some where else.

Re: [R] how to create automatically names for vectors in a loop?

2010-05-27 Thread Erik Iverson
Zoppoli, Gabriele (NIH/NCI) [G] wrote: Hi, I want to generate a number of vectors and store them with different names, like this: x=1 while (x100) { vector#x# = rnorm(100) x=x+1 } where each vector has, at its hand, instead of #x# a number which goes from 1 to 99. How can I do

Re: [R] 2.11.0 on ubuntu (hardy) inadvertently installed

2010-05-28 Thread Erik Iverson
You might want to ask on R-SIG-Debian https://stat.ethz.ch/mailman/listinfo/r-sig-debian Cedrick W. Johnson wrote: Hi- Looks like this morning, I did the ultimate in foobar to a main prod box. I was using apt-get upgrade on the box and totally missed the fact that my entire R installation

Re: [R] Help on aggregate method

2010-06-01 Thread Erik Iverson
It's easiest for us to help if you give us a reproducible example. We don't have your datasets (ap.dat), so we can't run your code below. It's easy to create sample data with the random number generators in R, or use ?dput to give us a sample of your actual data.frame. I would guess your

Re: [R] as.date

2010-06-01 Thread Erik Iverson
Where does the problem comes from?? Maybe from my sytem date ?? Simply from not reading the options carefully enough, from ?strptime, ‘%y’ Year without century (00-99). If you use this on input, which century you get is system-specific. So don't! Most often values

Re: [R] Help on aggregate method

2010-06-01 Thread Erik Iverson
Stella Pachidi wrote: Dear Erik and R experts, Thank you for the fast response! I include an example with the ChickWeight dataset: ap.dat - ChickWeight matchMeanEx - function(ind,dataTable,aggrTable) { index - which((aggrTable[,1]==dataTable[[Diet]][ind])

Re: [R] textbox in lattice

2010-06-01 Thread Erik Iverson
Noah Silverman wrote: That's amazing. (It would have taken me many hours to figure this out on my own.) Two quick last questions and then I'm off to plotting: 1) How can I reduce the font size of the table. (It is huge on my plot.) 2) How can I control the ratio of plot area to table area in

Re: [R] regexpr help (match.length=0)

2010-06-01 Thread Erik Iverson
McGehee, Robert wrote: R-help, Sorry if this is more of a regex question than an R question. However, help would be appreciated on my use of the regexpr function. In the first example below, I ask for all characters (a-z) in 'abc123'; regexpr returns a 3-character match beginning at the first

Re: [R] problem with intToChar

2010-06-01 Thread Erik Iverson
Changbin Du wrote: It does not work. outcome.label-LETTERS(outcome.predict) Error: could not find function LETTERS That is not when Henrique typed. LETTERS is a vector, and must be indexed as such, i.e., with []. __ R-help@r-project.org

Re: [R] problem with intToChar

2010-06-01 Thread Erik Iverson
Changbin Du wrote: Hi, Dear R- community, I am use the intToChar function to convert the integers to letters. But the output is mess. Can you guys give some suggestions? Thanks! I suggest you tell us what you were expecting to happen, that is, what do you actually want? It looks like

Re: [R] lapply with functions with changing parameters

2010-06-01 Thread Erik Iverson
Bunny, lautloscrew.com wrote: Dear all, I am trying to avoid a for loop here and wonder if the following is possible: I have a data.frame with 6 columns and i want to get a cross-correlogram (by using ccf) . Obivously ccf only accepts two columns at once and then returms a list. In fact,

Re: [R] Sweave glm.fit

2010-06-02 Thread Erik Iverson
How could we possibly tell without your code? Do you call glm or fit *any* models in your code? Can you use traceback() to see the trace of function calls that generated the error? Jimmy Söderly wrote: Dear R users, After running Sweave, this is what I get : Warning messages: 1:

Re: [R] Sweave glm.fit

2010-06-02 Thread Erik Iverson
Erik Iverson wrote: How could we possibly tell without your code? Do you call glm or fit *any* models in your code? Can you use traceback() to see the trace of function calls that generated the error? Sorry you aren't getting an error, but a warning, my mistake

Re: [R] import text file into R

2010-06-03 Thread Erik Iverson
dhanush wrote: can anyone tell me how to import a text file in R? the text file I want to import is a large file, about 800MB in size. Thanks in advance. I tried using the following data-read.table(file,header=T,sep=\t) And what happened?? Your specification is incomplete, as we don't

Re: [R] import text file into R

2010-06-03 Thread Erik Iverson
Dhanasekaran wrote: Sorry guys It is a tab delimited text file which I just exported from SAS. I want to import this in R. Pl let me know what is the delimiter I should use and R syntax. You still don't say the error you're getting when you try your read.table command.

<    1   2   3   4   5   6   7   8   >