Re: [R] Percentages and lattice

2010-09-27 Thread Phil Spector
x27; both = merge(correct,all) both$Pct = both$Freq / both$Total * 100 - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Issues with Legend symbols

2010-09-27 Thread Phil Spector
21,22) [1] 19 15 21 22 and c(2,2,2,2) [1] 2 2 2 2 or rep(2,4) [1] 2 2 2 2 I would ignore any other advice you got from the source that advised you to use expressions like 19:15:21:22 in R. - Phil Spector Statis

Re: [R] Trying to avoid loop structure

2010-09-29 Thread Phil Spector
oef$a[i] * o, obs, cut(obs,c(coef$st,6),labels=FALSE) + 1) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Split data

2010-09-29 Thread Phil Spector
49 14 [5,]5 10 15 - Phil Spector Statistical Computing Facility Department of Statistics UC Ber

Re: [R] interactive session

2010-09-30 Thread Phil Spector
If you don't mind the prompt of 1:, I think scan will do what you want: a = scan(n=1,what='',quiet=TRUE);b = paste("t",a,sep=''); 1: ada b [1] "tada" - Phil Spector

Re: [R] second element of a list

2010-09-30 Thread Phil Spector
Gregory - I'm confused -- if the first element is the matrix you want, why would you use 2 as an index? Here's a way to get a list with the first elements of each member of a list: lapply(thelist,'[[',1)

Re: [R] add a new column to data frame

2010-10-01 Thread Phil Spector
er(x$mode)[which.max(x$y)]) merge(dat,data.frame(id=names(two),type=two)) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Suppressing printing in the function

2010-10-01 Thread Phil Spector
?invisible - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] element wise conditional assignment in r

2010-10-01 Thread Phil Spector
John - Is this what you're looking for? r = sample(c(0,1),10,replace=TRUE) r [1] 0 1 0 1 1 0 0 1 0 1 v = 1:10 ifelse(r == 1,v-1,v) [1] 1 1 3 3 4 6 7 7 9 9 - Phil Spector Statistical Computing Fac

Re: [R] Help with apply

2010-10-04 Thread Phil Spector
)mapply(function(n,w)doit1(x,n,w),qq$nodes,qq$weights)) Both seem to agree with your rr1. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Subset POSIXlt Field

2010-10-05 Thread Phil Spector
Jared - The value "2010-08-17" is a character value, and your dates are stored as POSIXlt values. So you'd need to use Date == as.POSIXlt("2010-08-17") in your subset statement.

Re: [R] problems installing R (Matteo)

2010-10-05 Thread Phil Spector
Even better, from inside R, type install.packages("GRASS") to install the package. - Phil Spector Statistical Computing Facility Departmen

Re: [R] reorder always returns "ordered"

2010-10-05 Thread Phil Spector
else factor)(x, levels = names(sort(scores))) attr(ans, "scores") <- scores ans } - Phil Spector Statistical Computing Facility

Re: [R] Logical operator fails to recognize vector element

2010-10-06 Thread Phil Spector
Here's a simple example that might be instructive: x = 9.790001 y = 9.79 x [1] 9.79 y [1] 9.79 x == y [1] FALSE abs(x - y) < 1e-8 [1] TRUE all.equal(x,y) [1] TRUE And as others have said, FAQ 7.31 . - Phil

Re: [R] tapply output

2010-10-06 Thread Phil Spector
a.group myData.name Freq 2 1AEnzo 66.5 7 0BJane 58.5 121BMary 70.5 130A Tom 62.5 - Phil Spector

Re: [R] aggregate text column by a few rows

2010-10-07 Thread Phil Spector
Richard - Yes, you certainly can use aggregate to acheive what you want: aggregate(a$hobby,a['name'],paste,collapse=' ') name x 1 Tom fishing reading 2 Mary reading running 3 John boating

Re: [R] Need help for loop code, thanks

2010-10-07 Thread Phil Spector
6 1 d 6.0 7 2 f 4.0 8 2 g 4.6 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] problem with colors

2010-10-07 Thread Phil Spector
colors in cols. - Phil On Thu, 7 Oct 2010, ANJAN PURKAYASTHA wrote: Hi, I have a data set of 47 columns. I would like to create a boxplot for each column, each boxplot of a different colour. So I created a vector "col1". This vector has a subset of the colors returned by color()- "

Re: [R] Forecasting with R/Need Help. Steps shown below with the imaginary data

2010-10-07 Thread Phil Spector
) summary(fcast) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Testing for existence of object within a function

2010-10-07 Thread Phil Spector
Eli - I think you're looking for missing(): tst = function(a,b=1) + if(missing(a))print("You must provide a") else print(a) tst() [1] "You must provide a" tst(7) [1] 7 - Phil Spector

Re: [R] dot plot by group

2010-10-11 Thread Phil Spector
Casper - I think you want dotplot(BATCH~RESPONSE,data=d,subset=Type=='SHORT') or dotplot(BATCH~RESPONSE,data=subset(d,Type=='SHORT')) - Phil Spector Statistica

Re: [R] aggregate with cumsum

2010-10-12 Thread Phil Spector
1, aggregate *would* fail.)) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu

Re: [R] repeating an analysis

2010-10-12 Thread Phil Spector
printcp(fit1); x[which.min(x[,'xerror']),'nsplit']}) will put the numbers you want into answer, but there was no reproducible example to test it on. Unfortunately, I don't know of any way to surpress the printing from printcp().

Re: [R] NA with lmList

2010-10-13 Thread Phil Spector
Please take a look at the documentation for lmList regarding the na.action= argument. It should be a *function*, not TRUE or FALSE. For example, try lmList(score ~ childid | spring, data=a, na.action=na.omit) - Phil Spector

Re: [R] loop

2010-10-13 Thread Phil Spector
. So when t reaches 22, there is no corresponding column in Mhb0 or Mhb1. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] feed cut() output into goodness-of-fit tests

2010-10-15 Thread Phil Spector
)'s break different than a simple call to seq(). - Phil Spector Statistical Computing Facility Department of Statistics UC

Re: [R] boxplot ranked x labels

2010-10-18 Thread Phil Spector
her words, you can have a factor's levels appear in whatever order you'd like by using the levels= argument to factor. Hope this helps. - Phil Spector Statistical Computing Facility

Re: [R] For-loop dummy variables?

2010-10-19 Thread Phil Spector
mmy[i] = 0} } When you write a loop, you need to use the loop index to select the individual value you're working with. - Phil Spector Statistical Computing

Re: [R] Chron object in time series plot

2010-10-19 Thread Phil Spector
x27;) [1] "07:00" "07:15" "07:30" "07:45" "08:00" "08:15" "08:30" "08:45" "09:00" [10] "09:15" "09:30" "09:45" "10:00" "10:15" "10:30" "1

Re: [R] How to read only ten rows from a SAS dataset (read.ssd)?

2010-10-19 Thread Phil Spector
your sas.get call will return only the first 10 observations. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Clustering with ordinal data

2010-10-19 Thread Phil Spector
Steve - Take a look at daisy() in the cluster package. - Phil Spector Statistical Computing Facility Department of Statistics UC

Re: [R] efficient test for missing values (NAs)

2010-10-20 Thread Phil Spector
Ali - If all you care about is if there are any missing values (not how many or where they are), I think it would be a bit faster to use if(any(is.na(x))){...} - Phil Spector Statistical Computing Facility

Re: [R] How do I read multiple rows of different lengths?

2010-10-27 Thread Phil Spector
) + } result = lapply(pats,getnums) names(result) = c('first','x','y','fit','res','parameters') So to reproduce your x, y, fit, and res: x = result$x[[1]] y = result$orig[[1]] fit = result$fit[[1]] r

Re: [R] Alter character attribute

2010-10-28 Thread Phil Spector
d_date,'%Y')) (I'm assuming you're using month/date/year.) I can pretty much guarantee it will run in less than 18 hours :-) - Phil Spector Statistical Computing Facility

Re: [R] Determining a basal correct count

2010-10-28 Thread Phil Spector
David - I *think* apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1]) gives you what you want, but without a reproducible example it's hard to say. It will fail if there are no 1s in a given row. - Phil Sp

Re: [R] Determining a basal correct count

2010-10-28 Thread Phil Spector
David - I think changing apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1]) to apply(x,1,function(x)if(!any(x==1)) 0 else rle(x[which(x==1)[1]:length(x)])$lengths[1]) solves the problem. - Phil On Thu, 28 Oct 2010, David

Re: [R] How to scan df from a specific word?

2010-10-29 Thread Phil Spector
.6540 544.6540 17.86 0 P The first loop reads up until the word "Source" appears in the line, and the second loop builds a text representation of what you want so that you can read it using textConnection. Hope this helps. - Phil Spector

Re: [R] date calculation

2010-10-29 Thread Phil Spector
er, you're certainly free to make it one: as.integer(difftime(strptime("24NOV2004", format="%d%b%Y"), + strptime("13MAY2004",format="%d%b%Y"), units="days")) [1] 195 - Phil Spect

Re: [R] spliting first 10 words in a string

2010-11-01 Thread Phil Spector
yet another sentence and it also has a - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] individual intercept and slope

2010-11-02 Thread Phil Spector
You didn't say what form you wanted the output in, but here's one way: sapply(split(dat,dat$individual),function(s)lm(height~time,data=s)$coef) 1 2 (Intercept) 8.47 19.87 time2.485714 -2.057143 - Ph

Re: [R] Strings from different locale

2010-11-02 Thread Phil Spector
Steven - Does typing Sys.setlocale('LC_ALL','C') before the offending command suppress the message? - Phil Spector Statistical Computing Facility

Re: [R] how to work with long vectors

2010-11-04 Thread Phil Spector
00*sapply(dat,function(x)sum(dat >= x))/length(dat)) user system elapsed 0.024 0.000 0.026 - Phil Spector Statistical Computing Facility

Re: [R] matlab code into R

2010-11-04 Thread Phil Spector
Well, there's the obvious: N = matrix(0,n-1,n-1) for(i in 2:(n-1)) N[1,i] = 1/(pi * (i-1)) for(i in 2:(n-2)) for(j in i:(n-1)) N[i,j] = N[i-1,j-1] for(i in 2:(n-1)) for(j in 1:i) N[i,j] = -N[j,i] - Phil Sp

Re: [R] lookup in R - possible to avoid loops?

2010-11-08 Thread Phil Spector
= categories[my.df$names] creates the category column. - Phil On Mon, 8 Nov 2010, Dimitri Liakhovitski wrote: Hello! Hope there is a nifty way to speed up my code by avoiding loops. My task is simple - analogous to the vlookup formula in Excel. Here is how I

Re: [R] Help with getting ?match to not sort

2010-11-08 Thread Phil Spector
A 1 6C 3 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu

Re: [R] help to add a new column filled with value 1

2010-11-09 Thread Phil Spector
Mohan - Suppose your data frame is named "df". Try this: data.frame(df[,1],1,df[,2:5]) - Phil Spector Statistical Computing Facility Department of

Re: [R] library(kernlab) --- unable to load shared library

2010-11-09 Thread Phil Spector
ary in some non-standard location. You didn't mention what Linux distribution you're using, or whether you built R and the kernlab library from source or not, so it's hard to give specific guidance to solve your problem.

Re: [R] Merging data frames one of which is NULL

2010-11-09 Thread Phil Spector
) a b c d f g 1 1 2 3 NA NA NA 2 9 10 NA NA NA 15 3 10 20 NA 30 NA NA 4 12 19 NA NA 25 NA Hope this helps. - Phil Spector Statistical Computing Facility

Re: [R] Question regarding to replace

2010-11-09 Thread Phil Spector
ot;1" If you want the variable to be treated as a numeric variable, you can use as.numeric: as.numeric(myvar) [1] 0 0 0 1 Hope this helps. - Phil Spector Statistical Computing Facility

Re: [R] plotting histograms/density plots in a triangular layout?

2010-11-10 Thread Phil Spector
2,6,1,7,0)) chk [1] FALSE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE TRUE TRUE TRUE [13] TRUE TRUE FALSE FALSE FALSE TRUE TRUE TRUE TRUE FALSE FALSE FALSE [25] FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE [37] FALSE FALSE FALSE FALSE FALSE TRUE FALSE F

Re: [R] maptools package

2010-11-10 Thread Phil Spector
Aleksandr - What happens when you use library(maptools) spb = readShapePoly('/home/sasha/Documents/maps/spb.shp') - Phil Spector Statistical Computing Facility

Re: [R] Format table help

2010-11-10 Thread Phil Spector
Cameron - Are you sure Mthticker is a table? It looks like a list containing named vectors. Are you trying to reformat the list (Mthticker), or to reformat one element in the list (MthTicker[[i]]). - Phil Spector

Re: [R] Summing functions of lists

2010-11-13 Thread Phil Spector
Does this version of y do what you want? y=function(j)sum(sapply(1:3,function(i)x(i,j))) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Error: invalid type(list) for variable when using lm()

2010-11-16 Thread Phil Spector
Tianchan - Your X is not a matrix -- it's a dataframe. Probably the simplest solution is to use lm(y~as.matrix(X)) but you should also learn the difference between a data frame and a matrix. - Phil Sp

Re: [R] Counting

2010-11-16 Thread Phil Spector
unction(x)!any(x == 100))) [1] 350 Hope this helps! - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Vectors out of lists?

2010-11-16 Thread Phil Spector
Eduardo - I'd guess that Ybar = function(u)mean(sapply(Y,function(fun)fun(u))) will do what you want, but without a reproducible example, it's hard to tell. - Phil Spector Statistical Computin

Re: [R] Vectors out of lists?

2010-11-16 Thread Phil Spector
x27;d need to use Vectorize() before trying to integrate: integrate(Vectorize(Ybar),0,1) 0.4587882 with absolute error < 5.6e-05 - Phil Spector Statistical Computing Facility

Re: [R] Vectors out of lists?

2010-11-17 Thread Phil Spector
th=1))) user system elapsed 1.324 0.000 1.323 system.time(two <- Ybar1(seq(0,1,length=1))) user system elapsed 0.004 0.000 0.002 - Phil Spector Statistical Computi

Re: [R] translate vector of numbers to indicies of 0/1 matrix

2010-11-17 Thread Phil Spector
,]0010 [3,]0010 [4,]0001 - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Set colour in tcl variable

2010-11-19 Thread Phil Spector
function(...)tkconfigure(lab,foreground='red',text='wrong') green = function(...)tkconfigure(lab,foreground='green',text='correct') tkpack(tkbutton(base,text='Red',command=red)) tkpack(tkbutton(base,text='

Re: [R] Check for is.object

2010-11-22 Thread Phil Spector
e efficient to overallocate the matrix and then truncate it at the end. I'd strongly recommend that you avoid building your matrix incrementally inside a loop! - Phil Spector

Re: [R] how to round only one column of a matrix ?

2010-11-22 Thread Phil Spector
1.0985411 1 -1.3981632 [5,] 0.5787438 0 0.2246174 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] I need a very specific unique like function and I don't know even how to properly call this

2010-11-22 Thread Phil Spector
],FALSE) dat[!(abv & blw),] [,1] [,2] [1,]37 [2,]65 [3,]55 [4,]84 [5,]74 [6,]06 - Phil Spector Statistical Computing Faci

Re: [R] scan function

2010-11-23 Thread Phil Spector
ssage. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On We

Re: [R] Cannot update R

2010-11-24 Thread Phil Spector
I believe R is complaining that it can't find the jags library. You can find out about it here: http://www-fis.iarc.fr/~martyn/software/jags/ There appear to be rpms available. - Phil Spector Statis

Re: [R] Cannot update R

2010-11-24 Thread Phil Spector
Alon - It says it couldn't find it in /usr/local/lib -- is it in some non-standard location? If so, you could modify the ~/.R/Makevars file to contain PKG_LIBS=/location/of/jagslibrary before trying to build the package. - Phil On Wed, 2

Re: [R] Create new string of same length as entry in dataframe

2010-11-24 Thread Phil Spector
d',5),collapse='') thestring [1] "badbadbadbadbad" t2$V3 = substring(thestring,1,t2$V2) t2$V3 [1] "bad""badb" "badbad" "b" "ba" Hope this helps. - Phil

Re: [R] Subset by using multiple values

2010-11-29 Thread Phil Spector
reproducible example). - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Mon, 29

Re: [R] List elements of NULL to value

2010-11-29 Thread Phil Spector
Does A = lapply(A,function(x)if is.null(x) 0 else x) or for(i in 1:length(A))if(is.null(A[[i]]))A[i] = 0 do what you want? - Phil Spector Statistical Computing Facility

Re: [R] Can't Destroy Dim Names

2010-11-30 Thread Phil Spector
dimnames. But remember that, other than when you're displaying the object, the names or dimnames should not affect anything you do with the object, and they do allow you to index elements by name instead of number. - Phil Spector

Re: [R] Sequence for repeated numbers

2010-12-01 Thread Phil Spector
3 1 2 3 4 5 1 2 3 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...

Re: [R] read a matrix to find a value

2010-12-01 Thread Phil Spector
Judit - Does this example provide any insight? pop <- matrix(0,7,7)# Population matrix when t==0 pop[sample(1:length(pop),1)] <-1 #Population matrix when t==1 which(pop!=0,arr.ind=TRUE) row col [1,] 3 4 - Phil S

Re: [R] The behaviour of read.csv().

2010-12-02 Thread Phil Spector
Rolf - I'd suggest using junk <- read.csv("junk.csv",header=TRUE,fill=FALSE) if you don't want the behaviour you're seeing. - Phil Spector St

Re: [R] recode letters to numbers

2010-12-03 Thread Phil Spector
Katharina - I think something like this may be helpful: z = data.frame(matrix(sample(c(LETTERS[1:4],'NR',NA),100,replace=TRUE),20,5)) codes = c(A=100,B=27,C=50,D=25,NR=0) newz = sapply(z,function(x)codes[x]) - Ph

Re: [R] How to change a numeric vector to a character value

2010-12-03 Thread Phil Spector
t <- c(4, 5, 3, 2) paste(test,collapse=' ') [1] "4 5 3 2" - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Add columns of dataset

2010-12-03 Thread Phil Spector
mydf[,sort(names(mydf))] mydf id var1 var2 var3 var4 var5 var6 var7 var8 1 1 0.0 0.10 0.300 0.9 0.0 2 2 0.4 0.60 0.000 0.0 0.2 3 3 0.0 0.00 0.000 0.8 0.7 - Phil Spector

Re: [R] Changing names of a string variable

2010-12-07 Thread Phil Spector
Jahan - Try dat$target = toupper(dat$target) I would not recommend a loop for something like this. (You might also want to brush up on your python, because what you're trying doesn't work in python either.) - Ph

Re: [R] More elegant magnitude method

2010-12-07 Thread Phil Spector
Jonathan - If I understand correctly, max(0,floor(log(x,10))) will return the value you want. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] sd() for numeric row entries

2010-12-08 Thread Phil Spector
roduce warnings. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Converting data.frame from long to wide format

2010-12-08 Thread Phil Spector
Another way, using just base R is reshape(df,idvar='y',timevar='x',v.names='z',direction='wide') y z.A z.B z.C 1 D a b c 4 E d e f 7 F g h i - Phil Spector

Re: [R] Delete observations with a frequency < x

2010-12-09 Thread Phil Spector
work properly if y is a factor or character variable. If y was numeric, you would need df[!table(df$y)[as.character(df$y)] - Phil Spector Statistical Computing Facility Depar

Re: [R] Could concurrent R sessions mix up variables?

2010-12-10 Thread Phil Spector
15.335847 25.291502 Using snowfall: library(snowfall) sim = function(mu)max(replicate(10,max(rnorm(100,mu sfInit(cpus=4,type='SOCK',parallel=TRUE) sfSapply(c(1,5,10,20),sim) [1] 6.200161 10.307807 15.271581 25.055950 Hope this helps. - Ph

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

2010-12-13 Thread Phil Spector
there may be more direct ways. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.ed

Re: [R] Complicated nls formula giving singular gradient message

2010-12-13 Thread Phil Spector
almost exactly with R. Hope this helps. - Phil On Mon, 13 Dec 2010, Jared Blashka wrote: Phil, This is great! I had no idea nls would accept functions in the formula position. My apologies for not including data to reproduce my issue.  da

Re: [R] binding data.frames with sequential names

2010-12-13 Thread Phil Spector
ate into a list as they are created, rather than giving each one an individual name. That way you could simply use do.call(rbind,list-of-dataframes) . - Phil Spector Statistical Computing Facility

Re: [R] How to left or right truncate a character string?

2010-12-14 Thread Phil Spector
f(lead)paste('^',dots,sep='') else paste(dots,'$',sep='') +sub(pat,'',str) + } str = "this is a test" delchars(str,4) [1] " is a test" delchars(str,4,lead=FALSE) [1] "this is a "

Re: [R] How to bind models into a list of models?

2010-12-14 Thread Phil Spector
Mark - I believe lapply(dd,function(m)eval(parse(text=m))) will do what you want. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] from table to matrix

2010-12-14 Thread Phil Spector
ers[1:3])) mat[as.matrix(df[,1:2])] = df[,3] mat a b c A 1 2 3 B 4 5 6 C 7 8 9 - Phil Spector Statistical Computing Facility Department of Stati

Re: [R] from table to matrix

2010-12-14 Thread Phil Spector
Jonathan - Same problem, same solution: Suppose your data frame is called df: thematrix = matrix(NA,max(df$x),max(df$y)) thematrix[as.matrix(df[,1:2])] = df[,3] - Phil Spector Statistical Computing Facility

Re: [R] subset

2010-12-15 Thread Phil Spector
) That would still assume there was at least one value for each of med1, med2, and med3 for each combination. - Phil Spector Statistical Computing Facility Department of

Re: [R] Cumulative percentage by unit of time

2010-12-15 Thread Phil Spector
7;re looking for, a reproducible example would be helpful. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] NA matrix operation

2010-12-15 Thread Phil Spector
Patrik - I don't know if it's the fastest, but, assuming your Matrix is called mat, this seems to work fairly quickly: wh = which(is.na(mat),arr.ind=TRUE) mat[wh] = apply(mat,2,mean,na.rm=TRUE)[wh[,2]] - Ph

Re: [R] Problems drawing a colored 'rug' in the Lattice 'densityplot'

2010-12-15 Thread Phil Spector
]) } Then I think you'll get the result you want if you use densityplot(~Value|Type, group=Category, data=d, panel=mypanel) - Phil Spector Statistical Computing Facility

Re: [R] find closest match between two vectors

2010-12-16 Thread Phil Spector
Jannis - One approach is as follows: one = c(1,2,6) two = c(0,0.5,1,2,3,8) findit = function(x,vec){ + y = vec - x + y[y<=0] = NA + if(all(is.na(y)))NA else which.min(y) + } > sapply(two,findit,one) [1] 1 1 1 2 3 NA - Phil S

Re: [R] Arguments in functions

2010-12-16 Thread Phil Spector
sample as the second argument. Hope this helps. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] installing package from source with Linux

2010-12-17 Thread Phil Spector
. - Phil On Fri, 17 Dec 2010, Jannis wrote: Dear list, this may not be related to R but rather to my OS, but I do not understand the issue of compiling R packages deeply enough to figure out the exact cause of the problem. I am trying to

Re: [R] Resource for learning C/R interface

2010-12-18 Thread Phil Spector
Julian - I've written a document you might find helpful. http://www.stat.berkeley.edu/classes/s243/calling.pdf It also includes the C/matlab interface. - Phil Spector Statistical Computing Fac

Re: [R] Turning a Variable into String

2010-12-19 Thread Phil Spector
quot;OK with %s and %s\n", deparse(substitute(var1)), deparse(substitute(var2 but since you're just printing the string returned by sprintf, I'd go with cat. - Phil Spector Statistical Computing Facility

Re: [R] matrix indexing in 'for' loop?

2010-12-21 Thread Phil Spector
e "Values" section in the help file for cor.test to get the names of other quantities of interest.) The main advantage to this approach is that if you add more matrices to the allmats list, the other steps automaticall take it into account. Hope this helps.

Re: [R] python-like dictionary for R

2010-12-22 Thread Phil Spector
as a regular R value: 20 + nvec['three'] three 60 If the names annoy you (as they seem to annoy many R users), you can unname the object: unname(20 + nvec['three']) [1] 60 - Phil

<    1   2   3   4   5   >