[R] help.search not working - returns "readRDS(file) : unknown input format"

2013-03-11 Thread Gustaf Rydevik
ages()),function(x)help.search('',package=X<-x,rebuild=T)) Now there is no error, but help.search cannot find anything - it seems as if the database is empty. Does anyone have experience with a similar error? Best regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +44(0)74 253 760 42 add

Re: [R] Remove space from string

2012-01-13 Thread Gustaf Rydevik
roject.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Gustaf Rydevik, M.Sci. tel: +44(0)74

Re: [R] Fwd: WHO Anthro growth curve macros and R

2011-10-11 Thread Gustaf Rydevik
On Tue, Oct 11, 2011 at 1:21 AM, David Winsemius wrote: > > On Oct 10, 2011, at 4:48 PM, Gustaf Rydevik wrote: > > Hi all, >> some years ago, I sent a question to the mailing list regarding the WHO >> anthro macros. Since I've now received three mails asking how I s

[R] Fwd: WHO Anthro growth curve macros and R

2011-10-10 Thread Gustaf Rydevik
s are original splus functions. Let me know if anyone gets problems in figuring out how to use the files. best regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +44(0)704 253 760 42 address:St John's hill 18/5 EH8 9UQ Edinburgh, UK skype:gustaf_rydevik __

Re: [R] [Rd] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())

2010-06-23 Thread Gustaf Rydevik
On Wed, Jun 23, 2010 at 7:13 AM, Peter Dalgaard wrote: > Gustaf Rydevik wrote: > >> Oh, I forgot to mention that the workaround of using as.double (or >> as.numeric) works fine, and I've done that. >> It's just that it can take quite a while (as in several hours

Re: [R] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())

2010-06-22 Thread Gustaf Rydevik
On Tue, Jun 22, 2010 at 7:50 PM, David Winsemius wrote: > > On Jun 22, 2010, at 1:33 PM, Gustaf Rydevik wrote: > Cannot help you there, but have you looked at the help page for difftime? > > "The as.double method returns the numeric value expressed in the specified > uni

[R] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())

2010-06-22 Thread Gustaf Rydevik
On Thu, Jun 10, 2010 at 3:39 PM, Gustaf Rydevik wrote: > Hi all, > > The recent change in 2.11 that made as.numeric() return false on > difftime-objects broke some of my code that calculated age classes of > individuals using cut(). While this was no big thing to fix for me, it

Re: [R] remove last char of a text string

2010-06-14 Thread Gustaf Rydevik
rig.text<-c("01asap05a","02ee04b") substr(orig.text,1,nchar(orig.text)-1) Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org

Re: [R] moving average on irregular time series

2010-06-04 Thread Gustaf Rydevik
Dear William and Gabor, Both solutions worked, and my problem is now solved. Many thanks to both of you! regards, Gustaf > > On Thu, Jun 3, 2010 at 10:23 AM, Gustaf Rydevik > wrote: >> Hi all, >> >> >> I wonder if there is any way to calculate a moving avera

[R] moving average on irregular time series

2010-06-03 Thread Gustaf Rydevik
8 is a date less than 14 days after an event and should be marked for removal. -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat.et

Re: [R] ISO 8601 Weeks/Years on Windows with strptime

2010-06-03 Thread Gustaf Rydevik
l Hope this is of help. I agree that it would be of interest to incorporate OS-independent date management in R, but not being part of the R development team, I'm not sure how to go about implementing it... Best regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essinget

Re: [R] R on the iPhone/iPad? Not so much....a GPL violation

2010-06-02 Thread Gustaf Rydevik
is now on sale in the app store. See http://blogs.mathworks.com/desktop/2010/05/24/introducing-matlab-mobile-%E2%80%93-an-iphone-app-to-connect-remotely-to-your-matlab/ If matlab can do it, then surely the R community can as well. Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 addr

[R] A revised function for getting ISO week

2010-05-19 Thread Gustaf Rydevik
ed version. Hopefully this will come in handy for someone searching the mailing list archives in the future. Best Regards, Gustaf # ## Inputs a date object, posix object, or 3 numbers and gives back the iso week. ## By Gustaf Rydevik, revised 2010 getweek<-function(Y,M=NULL,D=NULL){

Re: [R] p-values < 2.2e-16 not reported

2010-05-19 Thread Gustaf Rydevik
mply errors in your data - are you sure that there's not a better way of thinking about your problem? >From a practical standpoint, I would be sceptical about the ability of most R-algorithms to generate theoretically valid p-values of such a small order. Best regards, Gustaf -

[R] Set encoding when load()-ing workspaces?

2010-05-02 Thread Gustaf Rydevik
} Best regards, Gustaf On Sun, May 2, 2010 at 8:36 PM, Prof Brian Ripley wrote: > On Sun, 2 May 2010, Duncan Murdoch wrote: > >> Gustaf Rydevik wrote: >>> >>> Hi all, >>> >>> I hope that there is someone that can help me out here. >>>

[R] Set encoding when load()-ing workspaces?

2010-05-02 Thread Gustaf Rydevik
tips that unfortunately did not lead anywhere, and subsequently gave up. I hope third time's a charm! Many thanks in advance, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik _

Re: [R] Remove duplicated rows

2010-04-23 Thread Gustaf Rydevik
t; Any help would be greatly appreciated. > > Thanks in advance, > Chris > -- Hi, This code is a bit ugly, but it works. Hope it helps. /Gustaf library(zoo) test<-read.table("clipboard",header=T) test$code<-paste(test$Name,test$Value,sep="") drop.ndx<-rol

Re: [R] R loop.

2010-04-23 Thread Gustaf Rydevik
On Fri, Apr 23, 2010 at 11:14 AM, mhalsham wrote: > > Hi > Yes I have managed to read the file (Table2.txt) > The command I have used > a<- read.table("table3.txt", fill=TRUE, header=FALSE) > If I read the first row the result output will be like that. > a[1,] > > Result would be > >        V1   V

Re: [R] R loop.

2010-04-23 Thread Gustaf Rydevik
ncer V2 RAD54B #6 Colon_cancer V3 PTPN12 #9 Colon_cancer V4 BCL10 #12 Colon_cancer V5 #15 Colon_cancer V6 #18 Colon_cancer V7 #21 Colon_cancer V8 #24 Colon_cancer V9 #1 Deafness V2EYA4 #4 Deafness V3 MYO7A #7 Dea

Re: [R] Assigning week numbers

2010-04-22 Thread Gustaf Rydevik
tor(length=length(alldates)) for(i in seq_along(alldates)){ if(weekdays(alldates[i])=="Saturday"){ Week<-Week+1 } if(substr(as.character(alldates[i]),6,10)=="05-01"){ Week<-1 } allweeks[i]<-Week } SCHEDULE

Re: [R] Assigning Week Numbers

2010-04-21 Thread Gustaf Rydevik
On Tue, Apr 20, 2010 at 7:59 PM, Michael Hosack wrote: > > R experts, > > How could I extract the week number from a date vector (in Date class) > such that week numbering (week 1...2...) begins (May 01) and ends > (October 31) on the same specific dates each year? Week numbering > must conform to

Re: [R] RNG

2010-04-21 Thread Gustaf Rydevik
Hi tamas, I am not sure what you mean by "downloaded" There is a lot of random number generators built into R. To generate 10 random numbers between 0 and 1, try runif(10) Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,1

Re: [R] how can I plot the histogram like this using R?

2010-04-16 Thread Gustaf Rydevik
posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > Hi, Does this do what you want? temp<-read.table(url("http://n4.nabble.com/file/n1965378/y1.txt";)) hist(temp$V1,breaks=seq(0,5.1,by=0.1)) abline(v=2

Re: [R] raise a matrix to a power

2010-04-13 Thread Gustaf Rydevik
e you tried to enter "matrix power" in rseek.org, clicking on support list, and then clicking on the second link? Regards, Gustaf Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik

Re: [R] Simplifying particular piece of code

2010-03-31 Thread Gustaf Rydevik
b <- zoo(matrix(rep(2, 16000), ncol=16)) colnames(b) <- SDnames data <- merge(a, b) MyFunc <- function(x, ret, stdev){ if(any(is.na(c(x[ret], x[stdev]{ return(NA) }else{ return(x[ret]/x[stdev]) } } names.df<-data.frame(rbind(S

Re: [R] Simplifying particular piece of code

2010-03-31 Thread Gustaf Rydevik
1, MyFunc, > ret=AVnames[i], stdev=SDnames[i])) > } > > > Help much appreciated. > > Regards, > Sergey > > > -- > Simplicity is the last step of art./Bruce Lee > The more you know, the more you know you don't know. /Myself > > I'm not young e

Re: [R] Adding minutes to 24 hour time

2010-03-17 Thread Gustaf Rydevik
t)%/%60)%%24 end.time<-paste(end.hours,end.mins,sep=":") return(end.time) } addTime(c("15:23","7:00"),c(70,100)) or this: addTime2<-function(timeTxt,mins){ orig.date<-as.POSIXct(paste("2001-01-01",timeTxt)) new.Date<-orig.date+mins*60 new.D

Re: [R] two questions for R beginners

2010-03-01 Thread Gustaf Rydevik
atomic vectors > > -- > Karl Ove Hufthammer > As a technical excercise, I wrote the following function: '%W%'<-function(e1,e2)e1[,which(colnames(e1)%in%e2)] temp<-matrix(1:6,nrow=2,dimnames=list(a=1:2,b=c("a","b","c"))) temp%W%"b&qu

[R] WHO Anthro growth curve macros and R

2009-12-28 Thread Gustaf Rydevik
it? Alternatively, could some, very kind, person try and open the Splus files, and save them in a R-readable format? I would be extremely grateful for any help on this. Best regards, Gustaf Rydevik -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stoc

Re: [R] String question

2009-12-23 Thread Gustaf Rydevik
functions. > > Kind regards Knut > Just thought I'd show you a solution from the other direction, in addition to those that all other have posted: temp <- paste("m1","m2","m3",sep=",")##Generate string nchar(gsub("([^,])",&

Re: [R] Question About Repeat Random Sampling from a Data Frame

2009-12-21 Thread Gustaf Rydevik
I can apply other statistical tests would be > greatly appreciated. > > Thank you very much for taking the time to consider my questions. > > Adam > > > >        [[alternative HTML version deleted]] That's pretty much how I tend to do those things. what you seem to

Re: [R] What is the fastest way to see what are in an RData file?

2009-12-18 Thread Gustaf Rydevik
On Thu, Dec 17, 2009 at 4:33 PM, Peng Yu wrote: > On Thu, Dec 17, 2009 at 5:33 AM, Gustaf Rydevik > wrote: >> On Wed, Dec 16, 2009 at 10:13 PM, Peng Yu wrote: >>> >>> Currently, I load the RData file then ls() and str(). But loading the file >>> takes t

Re: [R] What is the fastest way to see what are in an RData file?

2009-12-17 Thread Gustaf Rydevik
On Wed, Dec 16, 2009 at 10:13 PM, Peng Yu wrote: > > Currently, I load the RData file then ls() and str(). But loading the file > takes too long if the file is big. Most of the time, I only interested what > the variables are in the the file and the attributes of the variables (like > if it is a d

Re: [R] How to find the significant digits of a number?

2009-12-16 Thread Gustaf Rydevik
i, x<-pi substr(as.character(x),6,6) Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik [[alternative HTML version deleted]] __ R-help@r-project.org mailing list h

Re: [R] write.csv and header

2009-12-15 Thread Gustaf Rydevik
\n") > cat("-") > cat("\n") > sink() > write.table(matrix(rnorm(100),nrow=10),file="test.csv",append=TRUE,sep=",") regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stock

Re: [R] Literature analysis

2009-12-11 Thread Gustaf Rydevik
he frame? > > > Can you give an example of a couple of text files? Are they in a standardised format (i.e. bibTEX or similar)? /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik

Re: [R] grep() exclude certain patterns?

2009-12-09 Thread Gustaf Rydevik
Hi, Just a quick note regarding google and R: I use www.rseek.org almost exclusively, and it tends to give me the results I need. It is based on google, but uses a number of smart tricks to ferret out R-relevant information. /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451

Re: [R] savePlot for Mac and / or Linux?

2009-12-08 Thread Gustaf Rydevik
easy changing of the output file type, I've written this small function. Perhaps it can be of help. Regards, Gustaf - ###Function by Gustaf Rydevik, 2009-12-03 gustaf.ryde...@gmail.com ## Created to facilitate easy changes in the file format of generated graph

Re: [R] R help - IGARCH estimation

2009-10-19 Thread Gustaf Rydevik
tps://stat.ethz.ch/mailman/listinfo/r-help and send questions there instead of directly to me (who is not much of an R expert...) best regards, and good luck Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik

Re: [R] Function to find prime numbers

2009-10-13 Thread Gustaf Rydevik
e posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik [[alternative HTML version deleted]

Re: [R] Matching in R

2009-04-27 Thread Gustaf Rydevik
atrix[3,3] <- 1/var(X[,3]) This code changes the weights implied by the inverse of the variances by multiplying the first variable by a 1000 so that it is highly weighted. In order to enforce exact matching see the exact and caliper options. " -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 a

[R] Margins in lattice and device resolution

2009-04-17 Thread Gustaf Rydevik
xlab = "treatment", key = list(lines = Rows(trellis.par.get("superpose.line"), c(1:7, 1)), text = list(lab = as.character(unique(OrchardSprays$rowpos))), columns = 4, title = &quo

Re: [R] "utils" lacking namespace?

2009-04-15 Thread Gustaf Rydevik
On Wed, Apr 15, 2009 at 12:20 PM, Duncan Murdoch wrote: > Gustaf Rydevik wrote: >> >> Hi all, >> A colleague of mine tried to install the package EMV, which had been >> removed from CRAN. >> she ran into some kind of trouble, R locked up, and she closed the >

[R] "utils" lacking namespace?

2009-04-15 Thread Gustaf Rydevik
7;ve copy-pasted the error message she gets when starting R. Any ideas on what went wrong, and more importantly, how to fix it? Many thanks in advance, Gustaf Rydevik Ps: She's running R on a WinXP box, if that might be of relevance... Error : package 'utils&

Re: [R] same value in column-->delete

2009-03-26 Thread Gustaf Rydevik
Another, perhaps slightly more intuitive solution than Jim's would be the following: x<-data.frame(id=c(1,2,3), snp1=c("A","G", "G"),snp2=c("G","G","G"),snp3=c("G","G","A")) is.monovalued<-function(df){

Re: [R] modifying a built in function from the stats package (fixing arima)

2009-03-05 Thread Gustaf Rydevik
to be productive again. > > Thank you all for your help, > > Best, > MarC > Just a quick note on your original question: if you use edit(arima), you have to remember that it returns the modified function, which then must be stored. I.e, use arima<-edit(

Re: [R] Have a function like the "_n_" in R ? (Automatic count function )

2009-02-25 Thread Gustaf Rydevik
On Wed, Feb 25, 2009 at 4:43 PM, Charles C. Berry wrote: > On Wed, 25 Feb 2009, Gustaf Rydevik wrote: > >> On Wed, Feb 25, 2009 at 3:30 PM, hadley wickham >> wrote: >>> >>> And for completeness here's a function that returns the next integer >>&

Re: [R] Have a function like the "_n_" in R ? (Automatic count function )

2009-02-25 Thread Gustaf Rydevik
gt; [1] 1 >> n() > [1] 2 >> n() > [1] 3 >> n() > [1] 4 >> n() > [1] 5 >> n() > [1] 6 > > > ;) > > Hadley > *headache*! I can't wrap my head around this one - too strange code! Could someone please give a hint on what's going on?

Re: [R] an S idiom for ordering matrix by columns?

2009-02-19 Thread Gustaf Rydevik
2 2 1 2 > 639221 2 1 2 > 756221 2 1 2 > > Thanks for any suggestions! > > -Aaron > You mean something like this: > test<-matrix(sample(1:4,100,replace=T),ncol=10) >

Re: [R] Alternate to for-loop

2009-02-16 Thread Gustaf Rydevik
trix(rnorm(1000),ncol=100)) ,and substitute another distribution for rnorm if you want. /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https:/

Re: [R] Beginner-how to down size a large sample

2009-02-11 Thread Gustaf Rydevik
et.1<-dataSet[dataSet$group==1,] dataSet.0<-dataSet[dataSet$group==0,] sampled.1<-dataSet.1[sample(1:nrow(dataSet.1),100),] sampled.0<-dataSet.0[sample(1:nrow(dataSet.0),100),] newdataSet<-rbind(sampled.1,sampled.0) /Gustaf (a "please", would have been nice.

Re: [R] Filter a big matrix

2009-02-11 Thread Gustaf Rydevik
unction - modify to suit your purpose filterFunction<-function(n,data){ filteredData<-data[rowSums(data>=199)==1&(data[,n]>=199),,drop=FALSE] if(nrow(filteredData)==0){ filteredData<-"NoMatchingRows" } return(filteredData) } names<-colnames(X) lapply(as.list(

Re: [R] How to comment in R

2009-02-11 Thread Gustaf Rydevik
alculation you just enclose it > in such tags that behave like an inverted block comment. > > Just a thought, > > baptiste > Isn't this almost exactly what ?Sweave does? (and odfWeave). Granted, you have to deal with latex code to get nice output, but latex is a GoodThing (t

Re: [R] Generating Numbers With Certain Distribution in R

2009-02-11 Thread Gustaf Rydevik
gt;> What you think? > > Yes. No. Bernardo misplaced the parenthesis around (x-min(x)) Correct version is: x <- rlnorm(1e6,meanlog=1,sdlog=1) ## pick any parameters you like y <- round((x-min(x))/diff(range(x))*19+1) /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46

Re: [R] R on Mobile Devices (Android)

2009-02-11 Thread Gustaf Rydevik
R, no? Otherwise, I might be interested in porting R, taking it as an excuse to learn objective C and C++ regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r

Re: [R] Counting session days

2009-02-09 Thread Gustaf Rydevik
tion(x) seq(from=as.Date(x["start"]), to=as.Date(x["stop"]),by=1 ) ) ActiveDays<-as.Date(unlist(activeDaysPerSession)) as.data.frame(table(ActiveDays)) Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_ry

Re: [R] Selectively Removing objects

2009-02-02 Thread Gustaf Rydevik
> Paulo Gustavo Grahl, CFA > [Note to Paulo:I changed the code slightly: defining Nonfunctions separately messed things up.] Hi Paulo, The following should do it. test<-function(x)x^2 test2<-5 test3<-77 ls() rm(list=ls()[ sapply(ls(), function(x){ class(get(x))!="

Re: [R] two-sample test of multinomial proportion

2009-01-20 Thread Gustaf Rydevik
On Tue, Jan 20, 2009 at 4:08 PM, Gustaf Rydevik wrote: > Hi all, > > This is perhaps more a statistics question than an R question, but I > hope it's OK anyhow. > > I have some data (see below) with the number of tests positive to > subtype H1 of a virus, the number of t

[R] two-sample test of multinomial proportion

2009-01-20 Thread Gustaf Rydevik
ation regarding variance of H1/H3 in the two groups, so I don't think it is correct. I've tried using a bootstrap approach on the ratio of the two proportions, but there must be a smarter way. Any help is much appreciated! Best regards, Gustaf Rydevik data and bootstrap attempt

Re: [R] ifelse help?

2009-01-20 Thread Gustaf Rydevik
t you expected, since ifelse recycles the second argument if necessary. Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat

[R] data frames with å, ä, and ö (=n on-ASCII-characters) from windows to mac os x

2009-01-16 Thread Gustaf Rydevik
;Kalmar län", "Kronobergs län", "Norrbottens län", "Skåne län", "Stockholms län", "Södermanlands län", "Uppsala län", "Värmlands län", "Västerbottens län", "Västernorrlands län", "Västmanland

Re: [R] reshape, direction=long: "multiple row names not allowed"

2009-01-14 Thread Gustaf Rydevik
On Wed, Jan 14, 2009 at 3:07 PM, hadley wickham wrote: > On Wed, Jan 14, 2009 at 5:51 AM, Gustaf Rydevik > wrote: >> Hi all, >> >> for some reason I always get stuck spending hours when trying to use >> reshape or the Reshape package. Heaven knows why. >>

[R] reshape, direction=long: "multiple row names not allowed"

2009-01-14 Thread Gustaf Rydevik
not. The only information on why is that "duplicate row names are not allowed". It took me a fair time before figuring out that it was the "id"-column that caused problems. Perhaps something to fix, or at least give a more informative error message? Best regards, Gustaf -- G

Re: [R] getting ISO week

2008-12-11 Thread Gustaf Rydevik
heavily in Sweden, have always been a major frustration. Would it be possible to implement something similar to my solution in base, and how should I go about making it fit in to the rest of the date functions? /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40

[R] getting ISO week

2008-12-11 Thread Gustaf Rydevik
date is in the beginning,middle or end of the year Wn<-ifelse( Yn==Y-1, ifelse((jan1.wday==5|(jan1.wday==6 &LY.prev)),53,52), ifelse(Yn==Y+1,1,(date.yday+(7-date.wday)+(jan1.wday-1))/7-(jan1.wday>4)) ) return(list(Year=Yn,ISOWeek=Wn)) } -- Gustaf Rydevik, M.S

Re: [R] question involving loops from intro level R programming class

2008-11-28 Thread Gustaf Rydevik
spent a lot of time > staring at it, and I'm still not sure where to start. Thanks! > >[[alternative HTML version deleted]] > Hi, Nice little brain teaser! Not too difficult, but requires a bit of creative thinking... You might wanna have a look at, for example, ?d

Re: [R] Finding Stopping time

2008-11-27 Thread Gustaf Rydevik
> > But I cannot get the stopping index after the first one. > > Tanks > -- > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help >

Re: [R] Simple rep() question duplicating times and dates.

2008-11-05 Thread Gustaf Rydevik
ates<-seq(as.Date("01012005",format="%d%m%Y"),as.Date("31122005",format="%d%m%Y"),by=1) TimeFrame<-data.frame(time) TimeFrame$dates<-rep(dates,each=24) Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 S

Re: [R] How to get the duplicated elements from a vector?

2008-10-29 Thread Gustaf Rydevik
On Wed, Oct 29, 2008 at 3:45 PM, Erik Iverson <[EMAIL PROTECTED]> wrote: > > > Leon Yee wrote: >> >> Gustaf Rydevik wrote: >>> Hi Leon, >>> >>> unique(x) >>> >>> or >>> >>> duplicated(x) >>> >>

Re: [R] How to get the duplicated elements from a vector?

2008-10-29 Thread Gustaf Rydevik
an I filter out > all the elements which occured >=2 times? > >Thanks for any help! > > Regards, > Leon > Hi Leon, unique(x) or duplicated(x) should work, depending on what you want. Best, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetor

[R] Automatically adjust text size in plot

2008-10-24 Thread Gustaf Rydevik
units. Same goes for cex. Many thanks in advance, Gustaf PS: As an alternative, if someone could come up with a better way do display this type of data, I'd be all ears. I'm not too happy with my current solution -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Ess

Re: [R] Combining all possible values of variables into a new...

2008-10-20 Thread Gustaf Rydevik
t;- 12, NA)))) > > Suggestions? How about the following? x<-c(1,0,0,1,0,0,1,0,0,1) y<-c(1,3,2,3,2,1,2,3,2,3) z<-c(1,2,1,2,1,2,1,2,1,2) d<-as.data.frame(cbind(x,y,z)) xyz.comb<-interaction(x,y,z,lex.order=T) d$myvar<-match(xyz.comb,levels(xyz.comb)) /Gustaf Gust

Re: [R] Reading Data

2008-10-07 Thread Gustaf Rydevik
eader=T) ## If you have headers 2) read.table("data.txt", header=T) ## If the date row is supposed to be variable names. 3) read.table("data.txt",skip=1) ## If there are no headers, and you want to ignore the date regards, Gustaf -- Gustaf Rydevik

Re: [R] Problem with Grep Under Loop

2008-10-06 Thread Gustaf Rydevik
296" V1 V2 V3 V4V5 V6 V7 1 AB002296 panTro2 chr6 - 162615884 162626270 Chimpanzee > -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-h

Re: [R] Problem with Grep Under Loop

2008-10-06 Thread Gustaf Rydevik
give us a small sample of the "source" data, so that your example is reproducible? >From looking at your code, it seems as if you copied something wrong. First you write: grep("XM_528056", source$V1) ,but when you print dat2 it seems as if your ID-code ("XM_528056&quo

Re: [R] function in R

2008-10-02 Thread Gustaf Rydevik
.data.frame, for which you can have a look at the code. An added complication is that these functions are calling C-code by using ".Internal". This C-code can be found in cran, but as I don't know C, I've never tried it out more than having a quick l

Re: [R] Question about multiple regression

2008-09-09 Thread Gustaf Rydevik
hs of running a computer. Perhaps an alternative approach would be to get access to stronger (super)computers, either at a university, or buying access. A quick googling turns up http://www.clusterondemand.com/ for example. Anyhow, good luck with your project! I'm sure the R

Re: [R] Coefficients of Logistic Regression from bootstrap - how to get them?

2008-07-31 Thread Gustaf Rydevik
unsure if you would be able to follow. In the end, it doesn't really matter. What you are doing amounts to doing a regression 50 times, when once would suffice. No big harm done, just a bit of unnecessary work. And proof to a statistically competent reviewer that you don't really unde

Re: [R] sequential sum of a vector...

2008-07-23 Thread Gustaf Rydevik
e required? Any other ways of > doing this? > > > > Thanks, Shubha > > How about x<-1:80 filter(x,rep(1,8),"convolution",sides=1)[seq(8,length(x),by=8)] ##or cumsum(x)[seq(8,length(x),by=8)] ? /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essi

Re: [R] Coefficients of Logistic Regression from bootstrap - how to get them?

2008-07-23 Thread Gustaf Rydevik
lection process*, Step1-4 in the methods section, and find that their approach gives better result What you are doing is only step4 in the article's method section,estimating the parameters of a model *when you already know which variables to include*.It is the way this step is conducted that

Re: [R] [Fwd: Re: Coefficients of Logistic Regression from bootstrap - how to get them?]

2008-07-23 Thread Gustaf Rydevik
and taking median most likely is no better than standard regression. best regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https:/

Re: [R] Simple... but...

2008-07-23 Thread Gustaf Rydevik
gt;> >> OK, >> >> Let x=c(4,2,2) >> y=c(1,5,3) >> >> My result should be c(4,1,2,5,2,3) >> >> Thanks, Shubha >> There should be nicer ways, but this does it: x<-c(4,2,2) y<-c(1,5,3) c(matrix(c(x,y),byrow=T,nrow

Re: [R] Coefficients of Logistic Regression from bootstrap - how to get them?

2008-07-23 Thread Gustaf Rydevik
df$num1) I've never tried using any of the prepackaged bootstrap functions since it's so easy to write your own. And I never really figured out why you wanted to split the data in two, unless you do it before bootstrapping to have a test set. Regar

Re: [R] Non-normal data issues in PhD software engineering experiment

2008-07-10 Thread Gustaf Rydevik
a fraction? - If this is measured on test persons, I assume that you used each person several times. Is that so? Answers to the above questions might be good to bring to your meeting with the statistics faculty. Good luck with your research, Gustaf -- Gustaf Rydevik, M.Sci. te

[R] Question: Beginner stuck in a R cycle

2008-07-08 Thread Gustaf Rydevik
value=rnorm(200)) by(myD$value,myD$code,mean) but that won't get you the the group means in the empty column without some more lines of code. Another way is to use ?lapply and ?unlist: myD$Pr_mean<-unlist(lapply(as.character(myD$code),function(x) mean(myD$value[myD$code==x])

Re: [R] Migrating from S-Plus to R - Exporting Tables

2008-07-03 Thread Gustaf Rydevik
=FALSE, col.names=FALSE, file=output, quote=FALSE) write.table(data.frame(RowNames=row.names(x[[i]]),x[[i]]), file=output, quote=FALSE,row.names=FALSE) ##excluding actual rownames, adding them as a column. } close(output) - It seems as if you can't get it to write "row.names",

Re: [R] tiff()-bug (was re:Preparing high quality figures with tiff as end result)

2008-06-25 Thread Gustaf Rydevik
TED]> wrote: > On Wed, 25 Jun 2008, Peng Jiang wrote: > >> Hi , Gustaf >> i don't know why but it works pretty well on a mac. > > with completely different code. > > Gustaf Rydevik has mentioned this before -- it never fails for me on Windows > and hence one wo

Re: [R] tiff()-bug (was re:Preparing high quality figures with tiff as end result)

2008-06-25 Thread Gustaf Rydevik
On Wed, Jun 25, 2008 at 10:16 AM, Uwe Ligges <[EMAIL PROTECTED]> wrote: > > > Gustaf Rydevik wrote: >> >> Hi all, >> >> A while back I sent a message concerning working with tiff-files, and >> mentioned that I encountered a bug in 2.7.0. >> This

[R] tiff()-bug (was re:Preparing high quality figures with tiff as end result)

2008-06-25 Thread Gustaf Rydevik
"R GUI has encountered a problem and needs to close". Can anyone else out there reproduce this, so I can file a bug report? Best, Gustaf Rydevik --- > sessionInfo() R version 2.7.1 (2008-06-23) i386-pc-mingw32 locale: LC_COLLATE=Swedis

Re: [R] R help

2008-06-24 Thread Gustaf Rydevik
dear Xu, does: >library(urca) >example(ur.ers) >ers.gnp >str(ers.gnp) >[EMAIL PROTECTED] ,do what you want? (this reminds me that I have to learn S4 sometime) best, Gustaf Rydevik On Tue, Jun 24, 2008 at 3:52 AM, Xu, Ke-Li <[EMAIL PROTECTED]> wrote: > Dear Sir/Madam

r-help@r-project.org

2008-06-18 Thread Gustaf Rydevik
& a$g [1] FALSE FALSE FALSE TRUE > a$r && a$g [1] FALSE ifelse takes a vector as argument. isince && only gives a single value, ifelse(r>0 && g> 0,log(r/g),NA) will only return NA, which then is recycled by transform. When using &, ifelse returns a vector,

Re: [R] Preparing high quality figures with tiff as end result

2008-05-23 Thread Gustaf Rydevik
On Fri, May 23, 2008 at 4:40 PM, Gustaf Rydevik <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm currently preparing some figures that will be submitted to PloS One. > In their guidelines they state that they will only accept figures in > tiff or eps format, with the warnin

[R] Preparing high quality figures with tiff as end result

2008-05-23 Thread Gustaf Rydevik
t text becomes low-res bitmaps, and I don't know how to solve this. So basically my question is: How should I go about generating graphics that will look as nice as possible given the above constraints? Many thanks in advance, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 addres

[R] Change the position of panel strips in a lattice plot.

2008-04-08 Thread Gustaf Rydevik
the subgraphs, instead of above? I've been looking through the lattice documentation and the list archive but have not found such a thing. Many thanks in advance, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE sk

Re: [R] Loop for in R to generate several variables

2008-04-07 Thread Gustaf Rydevik
t does not work: > > for (ind in 1:10) { > > Yind = L0 + L1*X1 + L2*X2 + L3*X3 + K*Cind + n > > > } > > Any suggestions? > > Thank you. > > look up ?assign and ?get, i.e: for (ind in 1:10) { assign(paste("Y",ind,sep=""),L0 + L1*

Re: [R] Make plots with GNUplot. Have anyone tried that?

2008-03-03 Thread Gustaf Rydevik
ke a look at demo(plotmath). I really don't think you have to go outside of R to do what you want. In addition, if you aim to end up with a latex report I strongly encourage you to try out ?Sweave. It has certainly helped to streamline my workflow. Regards, Gustaf -

Re: [R] Avoiding overplotting of text.

2008-02-26 Thread Gustaf Rydevik
f those tasks that is needed fairly frequently, but which is rarely bothered with. Would it be possible to add one of these algorithms as an option to the regular text()? Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_

[R] Avoiding overplotting of text.

2008-02-25 Thread Gustaf Rydevik
) text(x,y,x.labels) ###Most of the time some of the labels end up unreadable. --- -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org m

Re: [R] Cox model

2008-02-13 Thread Gustaf Rydevik
On Feb 13, 2008 3:06 PM, Gustaf Rydevik <[EMAIL PROTECTED]> wrote: > On Feb 13, 2008 2:37 PM, Matthias Gondan <[EMAIL PROTECTED]> wrote: > > Hi Eleni, > > > > The problem of this approach is easily explained: Under the Null > > hypothesis, the P value

Re: [R] Cox model

2008-02-13 Thread Gustaf Rydevik
are the "true" predictors, and the rest being false positives. this set of 20 genes can then be further analysed. A much smaller and easier problem to solve, no? /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __

  1   2   >