[R] field index given name.

2009-10-11 Thread tdm
Hi, How do I access the index number of a field given I only know the field name? eg - I want to set the probability of the field 'species' higher than the other fields to use in sampling. > colprob <- array(dim=NCOL(iris)) > for(i in 1:NCOL(iris)){colprob[i]=0.5} > colprob[iris$species] = 1 #t

Re: [R] user input in R

2009-10-11 Thread Petr PIKAL
And try also search statsrus The first hit shall be Paul Johnsons's howto's which helped me several years ago especially with basic issues. Regards Petr r-help-boun...@r-project.org napsal dne 10.10.2009 18:00:19: > > I'm just learning R (I don't know any other programming languages), > >

Re: [R] Loading same libraries (old version & newest version) in r

2009-10-11 Thread Patrick Connolly
On Mon, 12-Oct-2009 at 10:54AM +1100, Steven Kang wrote: |> Hi all, |> |> I require 2 RMySQL libraries in order to query from a database. You mean you require 2 RMySQL packages. We must be pedantic to answer your question. |> |> 'RMySQL_0.7-4' (newest version) results in an error when more th

Re: [R] Loading data to Trellis barchart plot.

2009-10-11 Thread Schalk Heunis
Hi I think the following will help: #Load some packages library(lattice) library(reshape) #Sample data dataset.frame <- data.frame(id=c("a","b","c","a","c","b","a"),colour=c("blue","green","red","red","red","green","green")) # calculate the counts dataset.table <- table(dataset.frame) #and res

[R] r package for Probabilistic neural networks?

2009-10-11 Thread Wensui Liu
I am wondering if there is an implementation of PNN by Specht in R. thank you so much! -- == WenSui Liu Blog : statcompute.spaces.live.com Tough Times Never Last. But Tough People Do. - Robert Schuller __ R-help@r-project

Re: [R] add=TRUE function not working

2009-10-11 Thread David Winsemius
What do you mean by "define the scale"? -- On Oct 11, 2009, at 9:26 PM, Mehdi Khan wrote: Okay it worked, is there any way I can define the scale though? thanks a lot! On Sun, Oct 11, 2009 at 6:08 PM, Daniel Malter wrote: x1=rnorm(100) x2=rnorm(100) e=rnorm(100) y=1.5*x1+x2+e plot(y~x1,p

Re: [R] add=TRUE function not working

2009-10-11 Thread Mehdi Khan
Okay it worked, is there any way I can define the scale though? thanks a lot! On Sun, Oct 11, 2009 at 6:08 PM, Daniel Malter wrote: > x1=rnorm(100) > x2=rnorm(100) > e=rnorm(100) > y=1.5*x1+x2+e > > plot(y~x1,pch=1,xlim=c(min(x1,x2),max(x1,x2))) > points(y~x2,pch=16) > > HTH > Daniel > > >

Re: [R] add=TRUE function not working

2009-10-11 Thread Daniel Malter
x1=rnorm(100) x2=rnorm(100) e=rnorm(100) y=1.5*x1+x2+e plot(y~x1,pch=1,xlim=c(min(x1,x2),max(x1,x2))) points(y~x2,pch=16) HTH Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-hel

Re: [R] Function Help

2009-10-11 Thread Ben Bolker
cls59 wrote: > > > > jimdare wrote: >> >> Hi there, >> >> I have created the function below: >> >> pirate<-function(x){ >> a<-x-1; b<-a/5; c<-a-b; >> d<-c-1; e<-d/5; f<-d-e; >> g<-f-1; h<-g/5; i<-g-h; >> j<-i-1; k<-j/5; l<-j-k; >> m<-l-1; n<-m/5; o<-m-n; >> final<-o/5; >> >> final >> } >>

Re: [R] add=TRUE function not working

2009-10-11 Thread Sarah Goslee
You're going about it the wrong way: plot(p, q1) lines(p, q2) or points(p, q2) depending on what you want it to look like. Sarah On Sun, Oct 11, 2009 at 8:52 PM, Mehdi Khan wrote: > Hey everybody, I have a matrix with three columns. > > I want to plot two columns (independent variable) against

[R] add=TRUE function not working

2009-10-11 Thread Mehdi Khan
Hey everybody, I have a matrix with three columns. I want to plot two columns (independent variable) against one column (the defendant). This is my code and the error associated with it: plot(p, q, data=columns) > plot(pprime,q, add=TRUE) Warning messages: 1: In plot.window(...) : "add" is not a

Re: [R] Loading data to Trellis barchart plot.

2009-10-11 Thread kaixin maleA
Dear all, I have a question about loading the data to barchart plot. I know this could be a very easy question, but I just can not get my head around. What I need to do is to create a trellis plots barchart style (horizontal bar), with levels of one variable (ie. variable “colour” in my examp

Re: [R] Function Help

2009-10-11 Thread cls59
jimdare wrote: > > Hi there, > > I have created the function below: > > pirate<-function(x){ > a<-x-1; b<-a/5; c<-a-b; > d<-c-1; e<-d/5; f<-d-e; > g<-f-1; h<-g/5; i<-g-h; > j<-i-1; k<-j/5; l<-j-k; > m<-l-1; n<-m/5; o<-m-n; > final<-o/5; > > final > } > > I want to run this function until th

Re: [R] Ubuntu, Revolutions, R

2009-10-11 Thread gunksta
A.J. Rossini wrote: > > > Ubuntu is a commercial distribution, for loose definitions of commercial. > Why shouldn't they cut a deal with Revolution, who is doing a very similar > thing? > > If you want something closer to the ideal of volunteer-driven free as in > beer and speech, you'll need

[R] Loading same libraries (old version & newest version) in r

2009-10-11 Thread Steven Kang
Hi all, I require 2 RMySQL libraries in order to query from a database. 'RMySQL_0.7-4' (newest version) results in an error when more than 1 field is queried. ''RMySQL_0.5-11' (old version) resolves this issue where more than 1 field can be queried without any errors. However, other queries resu

[R] CRAN (and crantastic) updates this week

2009-10-11 Thread Crantastic
CRAN (and crantastic) updates this week New packages * AGSDest (1.0) Niklas Hack http://crantastic.org/packages/AGSDest Estimation in adaptive group sequential trials * atmi (1.0) Waldemar Kemler, Peter Schaffner, http://crantastic.org/packages/atmi Analysis and usage

[R] Function Help

2009-10-11 Thread jimdare
Hi there, I have created the function below: pirate<-function(x){ a<-x-1; b<-a/5; c<-a-b; d<-c-1; e<-d/5; f<-d-e; g<-f-1; h<-g/5; i<-g-h; j<-i-1; k<-j/5; l<-j-k; m<-l-1; n<-m/5; o<-m-n; final<-o/5; final } I want to run this function until the output ('final') is an exact integer (e.g. 893.000

Re: [R] Solving a nonlinear System of equations

2009-10-11 Thread Ravi Varadhan
There are two packages for solving nonlinear systems: one is the `BBsolve' function in the "BB" package, and the other is `nleqslv' in the "nleqslv" package. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Ger

[R] COVARIANCE MATRIX FOR RANDOM EFFECTS - nlme

2009-10-11 Thread Charles Obuya Sabatia
R-Help, I been using nlme to fit a model with 2 random effects. The correlation matrix I get with the VarCorr command does not seem to have the correct value for the correlation entry. E.g., below is a VarCorr matrix of random effects from data that I am working on: Variance StdDev

[R] Solving a nonlinear System of equations

2009-10-11 Thread Andrej Iljitsch Schmelzer
Hello there, I wish to solve the following nonlinear System of equations: + u1 - Vmax11*S1/(S1 + Km11 *(1 + S2/Km21)) - Vmax12*S1/( S1 + Km12 *(1+S2/Km22)) == 0 + u2 - Vmax22*S2/(S2 + Km22 *(1 + S1/Km12)) - Vmax21*S2/( S2 + Km21 *(1+S1/Km11)) == 0 + Vmax11*S1/(S1 + Km11 *(1 + S2/Km21)) + Vmax1

Re: [R] Random number

2009-10-11 Thread Peter Ehlers
Ashta wrote: Hi All, I have the matrix called 'X' with 200 rows and 12 variables. I want to create 2 new variables (V1 and V2) based on random number generator p1<-rnorm(200. mean=0, std=1) p2<-rnorm(200. mean=0, std=1) x <- cbind(x, v1=ifelse(x[,'p1'] > 0.4, 1, 0), v2=ifelse(x[,'p2'] > 0.6

Re: [R] Random number

2009-10-11 Thread Jorge Ivan Velez
Hi Ashta, On Sun, Oct 11, 2009 at 4:06 PM, Ashta <> wrote: > Hi All, > I have the matrix called 'X' with 200 rows and 12 variables. I want to > create 2 new variables (V1 and V2) based on random number generator > > p1<-rnorm(200. mean=0, std=1) > p2<-rnorm(200. mean=0, std=1) >

[R] Random number

2009-10-11 Thread Ashta
Hi All, I have the matrix called 'X' with 200 rows and 12 variables. I want to create 2 new variables (V1 and V2) based on random number generator p1<-rnorm(200. mean=0, std=1) p2<-rnorm(200. mean=0, std=1) x <- cbind(x, v1=ifelse(x[,'p1'] > 0.4, 1, 0), v2=ifelse(x[,'p2'] > 0.6, 0, 1)) I found

Re: [R] Saving Seed In a Lopp

2009-10-11 Thread Simon Bonner
Hey Galois (?), See the help file for set.seed() (help(set.seed)). In short, the current seed is stored in the variable .Random.seed. You can save the seed with: myseed <- .Random.seed Hope that helps, Simon - Simon Bonner Post-Doctoral Fellow Department of Statistics, UBC www.simon.bonners

Re: [R] Social networking around R

2009-10-11 Thread Barry Rowlingson
On Sun, Oct 11, 2009 at 7:51 PM, HBaize wrote: > > > > Harsh-7 wrote: >> >> Hi R users, >> >> I'd be interested in what R users think about social networking around all >> things R. For this, I've set up a social network @ >> www.rstuff.socialgo.comand it would be great if you could post your >> c

Re: [R] About finding NA values sources

2009-10-11 Thread Paul Murrell
Hi Are you one of my 380 students? If so, please contact me directly about any difficulties you are having with assignment work. Sending questions via R-help like this is inefficient because there is a chance that I might not spot it. At the very least, you should declare to all of the kin

[R] Saving Seed In a Lopp

2009-10-11 Thread Galois Theory
I'm trying to save the random seed in a for loop. How can one go about doing that and preserving the seed for the next session. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-hel

Re: [R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread romunov
Hello Sundar, I checked the ls() and it was full of "something" (something that I should have removed long ago but was not diligent enough). I have cleared the list (via rm(list=ls()) and the glm function works fine now. Cheers, Roman On Sun, Oct 11, 2009 at 9:21 PM, Sundar Dorai-Raj wrote: >

Re: [R] Why H1=1? (H's the hat matrix)

2009-10-11 Thread John Fox
Dear Simon, > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Simon Bonner > Sent: October-11-09 2:33 PM > To: Peng Yu > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] Why H1=1? (H's the hat matrix) > > Another, less geometric,

Re: [R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread Sundar Dorai-Raj
Check to see if you have an old workspace being loaded. You might have an object called 'family' which you might need to remove. --sundar On Oct 11, 2009 12:15 PM, "romunov" wrote: Thank you Jorge and Barry for your input. I've fiddled around a bit and as a result, am even more confused. If I

Re: [R] Manipulating Arrays

2009-10-11 Thread ampc
Thanks baptiste. Works as expected. ampy ampc wrote: > > Manipulating Arrays > Using the below data: > > df <- structure(list(dim1 = structure(c(1L, 3L, 1L, 4L, 1L, 2L, 2L, > 2L, 3L, 1L, 4L, 3L, 4L, 4L, 3L, 2L), .Label = c("a1", "a2", "a3", > "a4"), class = "factor"), dim2 = structure(c(2L

Re: [R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread romunov
Thank you Jorge and Barry for your input. I've fiddled around a bit and as a result, am even more confused. If I start R console via Notepad++ (I use Npp2R) and execute the model1, it goes through just fine. Here is the sessionInfo() for this "working" session: > sessionInfo() R version 2.9.2 (20

Re: [R] Social networking around R

2009-10-11 Thread HBaize
Harsh-7 wrote: > > Hi R users, > > I'd be interested in what R users think about social networking around all > things R. For this, I've set up a social network @ > www.rstuff.socialgo.comand it would be great if you could post your > comments on the forum created > for this discussion. > >

Re: [R] Why H1=1? (H's the hat matrix)

2009-10-11 Thread Simon Bonner
Another, less geometric, way to think about this: The fitted response for a linear model is a weighted average of the observed responses. The i-th row of the hat matrix list the coefficients of the average for the i-th fitted value. These values sum to 1 for each row, and so H %*% 1=1. Cheers...

Re: [R] Why H1=1? (H's the hat matrix)

2009-10-11 Thread John Fox
Dear Peng, This seems a curious question to pose on r-help: The vector 1 is the first column of X, and hence lies in the subspace spanned by the columns of X. H projects any vector orthogonally onto the subspace spanned by X. Thus, if a vector, such as 1, lies in this subspace, it's projected onto

Re: [R] Why H1=1? (H's the hat matrix)

2009-10-11 Thread Gabor Grothendieck
H projects vectors onto the range of X so any vector already in the range of X gets projected onto itself. On Sun, Oct 11, 2009 at 2:03 PM, Peng Yu wrote: > Suppose I have the following hat matrix: > > H=X(X'X)^{-1}X' > X is a n by p matrix, where n >= p and X_{i,1} = 1 > > I'm wondering why H1 =

[R] Why H1=1? (H's the hat matrix)

2009-10-11 Thread Peng Yu
Suppose I have the following hat matrix: H=X(X'X)^{-1}X' X is a n by p matrix, where n >= p and X_{i,1} = 1 I'm wondering why H1 = 1. (Here, 1 is column vector, whose each element is the number 1) Thank you! __ R-help@r-project.org mailing list https:

Re: [R] Social networking around R

2009-10-11 Thread Kenny Shen
Hi, I'm new to R to and think it might be a good idea... who knows? I was lurking in the R channel on freenode some days back and someone was complaining about how no one ever talks there... Anyway, signing up now... Cheers, Kenny On Mon, Oct 12, 2009 at 1:10 AM, Harsh wrote: > Hi R users,

[R] Social networking around R

2009-10-11 Thread Harsh
Hi R users, I'd be interested in what R users think about social networking around all things R. For this, I've set up a social network @ www.rstuff.socialgo.comand it would be great if you could post your comments on the forum created for this discussion. The News section has feeds from some of

Re: [R] many weighted means: is there a simpler way?

2009-10-11 Thread Charles C. Berry
On Sun, 11 Oct 2009, Ozan Bak???~_ wrote: Hi R-users, I would like to calculate weighted mean of several variables by two factors where the weight vector is the same for all variables. Below, there is a simple example where I have only two variables: "v1","v2" both weighted by "wt" and my fact

Re: [R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread Jorge Ivan Velez
Hi Romain, It works for me: model1 <- glm(as.vector(x) ~dept*sex*admit,poisson) model1 Call: glm(formula = as.vector(x) ~ dept * sex * admit, family = poisson) Coefficients: (Intercept) dept2 dept3 dept4 dept5 6.23832 -

Re: [R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread Barry Rowlingson
On Sun, Oct 11, 2009 at 4:54 PM, romunov wrote: > Dear List, > > I'm having problem with an exercise from The R book (M.J. Crawley) on page > 567. > Here is the entire code upto the point where I get an error. > > data(UCBAdmissions) > x <- aperm(UCBAdmissions, c(2, 1, 3)) > names(dimnames(x)) <-

Re: [R] permutations

2009-10-11 Thread Jorge Ivan Velez
Hi Eiger, Here a suggestion to get the output in the format you want: # Package, data and path require(combinat) x <- do.call(rbind,permn(c(23,46,70,71,89))) f <- "C:/permutations.txt" # Original output write.table(x, f, col.names = F, row.names = F) # Transposed output write.table(t(x), "C:/tra

[R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread romunov
Dear List, I'm having problem with an exercise from The R book (M.J. Crawley) on page 567. Here is the entire code upto the point where I get an error. data(UCBAdmissions) x <- aperm(UCBAdmissions, c(2, 1, 3)) names(dimnames(x)) <- c("Sex", "Admit?", "Department") ftable(x) fourfoldplot(x, margin

[R] DBI fetch argument ellipses?

2009-10-11 Thread Gerald I. Evenden
Sorry, this is an R newbie question: I have managed to sucessfully do some of the basic access of a MySQL data base with R but I have a question about the 'fetch' function. The documentation refers to "fetch(res, n, ...)" but never fully describes the ellipses ("...") nor provides examples of w

Re: [R] Display more than one plot

2009-10-11 Thread emkayenne
Hey Joris! Thanks, I can do that now, you've been a great help. JorisMeys wrote: > > Just saw I did something stupid. Both examples create a 2 by 2 grid in > your graph window, so you'll be able to plot 4 graphs in that window. > If you plot only 2 graphs, the lower half of the window will be e

[R] Plotting groupedData objects by levels of a factor

2009-10-11 Thread Auty, Dave
Hi, I'm trying to plot a grouped data object for modelling maximum branch size by distance from stem apex: >MAXBRD.group <- groupedData(MAXBRD ~ Dtop | Type/Site/Tree, inner=~Status, data=MAXBRD.data). The following code produces a plot of MAXBRD ~ Dtop for each site type: >plot(MAX

Re: [R] Creating a Clustered-Stacked Column Chart

2009-10-11 Thread zhijie zhang
Thanks. I think there may be no easy method to achive it. library(lattice) barchart(Titanic, scales = list(x = "free"),auto.key = list(title ="Survived"),layout=c(4,1),horizontal = FALSE) The above method generates four graphs, two graphs in the left are for children's male and female,respectiv

Re: [R] Ubuntu, Revolutions, R

2009-10-11 Thread AJ Rossini
Andrew Choens gmail.com> writes: > > I am interested in hearing from members of the community, REvolution Computing > employees/supporters (although please ID yourself as such) and most anyone > else. I can see what they say on their website, but I'm interested in getting > other opinions

[R] Active learning and logistic regression.

2009-10-11 Thread Łukasz Lew
Hi, I have binary file with a set of tunable real parameters. Upon execution the file returns 0 or 1 with some probability. (therefore (nonlinear) logistic regression) I need to find a set of parameters for which the probability of 1 is high. I would like to create program that would repeatably e

Re: [R] spectral analysis

2009-10-11 Thread David Winsemius
On Oct 11, 2009, at 8:38 AM, sdlywjl666 wrote: Dear all, I am searching the period of a time series usering R. Is there some lag window functions in R? ?lag Could you give me some books about spectral analysis usering R? best wishes, Wang You might try being more specific. The

Re: [R] How do I reverse the digits of a number

2009-10-11 Thread Gabor Grothendieck
On Sun, Oct 11, 2009 at 8:09 AM, Barry Rowlingson wrote: > On Sun, Oct 11, 2009 at 12:53 PM, Gabor Grothendieck > wrote: >> Try this: >> >>> library(tcltk) >>> as.numeric(tcl("string", "reverse", 123)) >> [1] 321 > > The bit where the original poster said 'unknown length' worried me: > >  > as.nu

[R] spectral analysis

2009-10-11 Thread sdlywjl666
Dear all, I am searching the period of a time series usering R. Is there some lag window functions in R? Could you give me some books about spectral analysis usering R? best wishes, Wang [[alternative HTML version deleted]] __ R-h

Re: [R] lattice auto.key drop unused levels

2009-10-11 Thread Peter Ehlers
Jacob Wegelin wrote: On Sat, Oct 10, 2009 at 8:51 PM, Peter Ehlers wrote: The key will show the levels of the 'groups' factor. So you will have to ensure that the factor fed to groups has the levels that you want displayed. ?xyplot explicitly states that drop.unused.levels will NOT do that for

Re: [R] Creating a Clustered-Stacked Column Chart

2009-10-11 Thread Peter Ehlers
zhijie zhang wrote: Thanks for your ideas and suggestions. I need to point out that most of us will create the Clustered-Stacked Column Chart in the matrix layout as David gave above, but here i hope to display the graph side by side as the example in the link http://peltiertech.com/Excel/Cha

Re: [R] How do I reverse the digits of a number

2009-10-11 Thread Barry Rowlingson
On Sun, Oct 11, 2009 at 12:53 PM, Gabor Grothendieck wrote: > Try this: > >> library(tcltk) >> as.numeric(tcl("string", "reverse", 123)) > [1] 321 The bit where the original poster said 'unknown length' worried me: > as.numeric(tcl("string", "reverse", 12377656534)) [1] 0.4356568 > as.numeric

Re: [R] How do I reverse the digits of a number

2009-10-11 Thread Gabor Grothendieck
Try this: > library(tcltk) > as.numeric(tcl("string", "reverse", 123)) [1] 321 On Sat, Oct 10, 2009 at 5:37 PM, tom_p wrote: > > Hi All, > > Thanks for your help.  I need to reverse the digits of a number (unknown > lenght).  Example 1234->4321 > > Tom > -- > View this message in context: > ht

[R] barchart

2009-10-11 Thread Veerappa Chetty
Hi,In Lattice graphs, can I use "reorder" function in a barchart as in the case of "dotchart"? Or it can be used only with dotcharts? Thanks Chetty Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails: chett...@gmail.com,vche...@bu.edu [[alternative H

Re: [R] permutations

2009-10-11 Thread Eiger
jholtman wrote: > > try this to get the column output: > > cat(x, sep='\n', file='/tempxx.txt') > > Thanks for your answer. I've tried the command "cat" , but give me this error: > x<-permn(c(2,3,5,7)) > cat(x, file="/my_path/filename.txt","\n") Error in cat(list(...), file, sep, fill, la

Re: [R] row selection

2009-10-11 Thread Bernardo Rangel Tura
On Thu, 2009-10-08 at 16:14 -0400, Ashta wrote: > Hi all, > I have a matrix named x with N by C > I want to select every 5 th rrow from matrix x > I used the following code > n<- nrow(x) > > for(i in 1: n){ > + b <- a[i+5,] > >b > } > Error: subscript out of bounds > > Can any body point out th

Re: [R] Manipulating Arrays

2009-10-11 Thread baptiste auguie
Hi, the abind package can help you with the first query, ## add values library(abind) arr <- abind(arr,arr[1,,,] * 2 + 1,along=1) dim(arr) as for the second, maybe you can use negative indexing, ## remove values arr <- arr[-2,,,] HTH, baptiste 2009/10/11 ampc : > > Manipulating Arrays > Usin

Re: [R] Decreasing Sort Error Message

2009-10-11 Thread Romain Francois
On 10/11/2009 10:55 AM, tom_p wrote: Can anybody tell me how to fix this error? Thanks, Tom 'decreasing' must be a length-1 logical vector. so either TRUE or FALSE > array_down = sort(sort_array,decreasing = TRUE ) array_down = sort(sort_array,decreasing = 1) Error in sort(sort_array, de

[R] Decreasing Sort Error Message

2009-10-11 Thread tom_p
Can anybody tell me how to fix this error? Thanks, Tom > array_down = sort(sort_array,decreasing = 1) Error in sort(sort_array, decreasing = 1) : 'decreasing' must be a length-1 logical vector. -- View this message in context: http://www.nabble.com/Decreasing-Sort-Error-Message-tp25841678p

Re: [R] Substituting the extracted coefficients into the formula, exctracted from the result of nls()

2009-10-11 Thread Primoz PETERLIN
Thank you. I guess using predict() is probably closest to the R philosophy. All the best, Primož 2009/10/9 Henrique Dallazuanna : > Try with predict: > > plot(x, y) > lines(0:10, predict(yfit, list(x = 0:10))) > > 2009/10/9 Primoz PETERLIN : >> Dear all, >> >> Here I come with another stupid ques

Re: [R] field names as function parameters

2009-10-11 Thread tdm
Thanks, just the clue I needed, worked a treat. baptiste auguie-5 wrote: > > Hi, > > I think this is a case where you should use the ?"[[" extraction > operator rather than "$", > > d = data.frame(a=1:3) > mytarget = "a" > d[[mytarget]] > > > HTH, > > baptiste > > 2009/10/11 tdm : >> >> H

Re: [R] How do you test if a number is in a list of numbers?

2009-10-11 Thread Bill.Venables
This is pretty standard. varList <- 1:4 subData <- subset(dataset, var %in% varList) Should do it. W. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of JustinNabble [justinmmcgr...@hotmail.com] Sent: 11 October 2009 16:13 To:

Re: [R] field names as function parameters

2009-10-11 Thread baptiste auguie
Hi, I think this is a case where you should use the ?"[[" extraction operator rather than "$", d = data.frame(a=1:3) mytarget = "a" d[[mytarget]] HTH, baptiste 2009/10/11 tdm : > > Hi, > > I am passing a data frame and field name to a function. I've figured out how > I can create the formula

[R] How do you test if a number is in a list of numbers?

2009-10-11 Thread JustinNabble
Hi, I want to subset a data frame if one of the variables matches any in a list. I could of course do something like this: subset(dataset, var == 1 | var == 2 | var ==3) but that's tedious. I tried varlist = c(1,2,3,4) subset(dataset, any(var == varlist)) but it doesn't work because 'any' doesn't