Re: [R] plot xaxp issue

2013-01-07 Thread PIKAL Petr
Hi I actually do not know what you are talking about. I believe that the code I provided works (if i did not make typing mistake), but you failed to provide data to test so I made my own data and subset inside lm works as expected. fake-data.frame(weight-rnorm(15), length=weight*3+rnorm(15),

Re: [R] Have problem to do loop to generate transformed chi-squared variates

2013-01-07 Thread Rolf Turner
Homework? We don't do people's homework for them. cheers, Rolf Turner On 01/08/2013 05:13 AM, Agnes Ayang wrote: Hello R-helpers, I need to generate standard variates normal to 'create' chi-squared variates. To make you more understand, (1) a-rnorm(3,0,1) *after do (1), I

[R] plot xaxp issue

2013-01-07 Thread Elaine Kuo
Hello, I have data of Body length and Body weight of 8 boys and 7 girls. I want to draw the plot of Body length (for X) and Body weight (for Y) based on sex. Then the two plots want to be overlapped for comparison. I used the code below but found the unit length of X axis of boy and girl plot

Re: [R] plot xaxp issue

2013-01-07 Thread PIKAL Petr
Hi Instead of two plots with par(new = TRUE) try to put boys and girls together (quite natural thing, they will be pleased 8-) together - rbind(boy, girl) together$sex - factor(rep(c(boy, girl), c(8,7))) plot(together$body_length, together$body_weight, ,

Re: [R] how to aggregate T-test result in an elegant way?

2013-01-07 Thread Yao He
Hi, arun I'm so sorry for that isn't helpful. One of question is that I don't know how to subset a small part as it is a 3-dimension array so I just show the structure of that. I tried dput() to a file , then what should I do for subsetting it? Another question is : My rawdata is a melt

[R] round 2.3 to 2.5 and 2.2 to 2.0

2013-01-07 Thread Mat
Hello together, i want to round some numbers in my data.frame. How can i round a number to values like 0.5; 1.0; 1.5; 2.0; etc. It should look like this one before 2.2 ; 2.3; 2.26; 1.11 after 2.0; 2.5; 2.5; 1.0 thanks. Mat -- View this message in context:

[R] plot x-axis DateTime NOT evenly spaced

2013-01-07 Thread ishi soichi
R-64 latest Hi. I am trying to plot a set of csv data, which looks like head(interval) date inteval 1 2012-07-01 00:57:54 +0900 156 2 2012-07-01 01:07:41 +0900 587 3 2012-07-01 01:09:31 +0900 110 4 2012-07-01 01:18:42 +0900 551 5 2012-07-01 01:39:01 +0900

Re: [R] package metafor: error when setting 'col' and 'at' for a forest plot

2013-01-07 Thread Viechtbauer Wolfgang (STAT)
Dear Brian, At the moment, the various forest() functions are not meant to accept 'col' as an argument. While it is indeed possible to specify a 'col' argument, it will be passed on via the ... argument to further functions within forest() and this is where things can go awry. To give a more

Re: [R] round 2.3 to 2.5 and 2.2 to 2.0

2013-01-07 Thread Uwe Ligges
On 07.01.2013 09:59, Mat wrote: Hello together, i want to round some numbers in my data.frame. How can i round a number to values like 0.5; 1.0; 1.5; 2.0; etc. It should look like this one before 2.2 ; 2.3; 2.26; 1.11 after 2.0; 2.5; 2.5; 1.0 round(2*x)/2 Uwe Ligges thanks. Mat

Re: [R] plot x-axis DateTime NOT evenly spaced

2013-01-07 Thread Uwe Ligges
On 07.01.2013 09:55, ishi soichi wrote: R-64 latest Hi. I am trying to plot a set of csv data, which looks like head(interval) date inteval 1 2012-07-01 00:57:54 +0900 156 2 2012-07-01 01:07:41 +0900 587 3 2012-07-01 01:09:31 +0900 110 4 2012-07-01

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread Uwe Ligges
On 07.01.2013 07:00, Michael Rennie wrote: Hi all, I have read through the archives, but can't find a solution to this problem. I need the text direction on dependent B, plotted in margin 4, to go top to bottom (opposite what it is now). Here's some sample code: #plot with mtext example

Re: [R] plot xaxp issue

2013-01-07 Thread Elaine Kuo
Thanks a lot. Please kindly indicate the meaning of the c(8,7). together - rbind(boy, girl) together$sex - factor(rep(c(boy, girl), c(8,7))) Elaine On Mon, Jan 7, 2013 at 4:55 PM, PIKAL Petr petr.pi...@precheza.cz wrote: Hi Instead of two plots with par(new = TRUE) try to put boys and

Re: [R] plot xaxp issue

2013-01-07 Thread Elaine Kuo
Thank you Petr, the code is wonderful. One more question, you used [as.numeric(together$sex)] to drawing plots many times (Par(new)). Please kindly advise if there is a similar method to replace drawing ablines many times. If not, I am afraid that the ablines will not follow the same Y and X-axis

Re: [R] package metafor: error when setting 'col' and 'at' for a forest plot

2013-01-07 Thread Brian Z Ring
Brilliant, this works very well. Thank you for explaining this so clearly, all your points are well taken. Sincerely, Brian Brian Z Ring PhD Professor, Director Institute of Personalized and Genomic Medicine College of Life Science Huazhong University of Science and Technology Wuhan,  China

Re: [R] plot xaxp issue

2013-01-07 Thread PIKAL Petr
Hi -Original Message- From: Elaine Kuo [mailto:elaine.kuo...@gmail.com] Sent: Monday, January 07, 2013 1:45 PM To: PIKAL Petr Cc: r-help@r-project.org Subject: Re: [R] plot xaxp issue Thank you Petr, the code is wonderful. One more question, you used

[R] Function to tabulate t-test (1) How can I get dependent variable name (2) How can I make data frame know to function

2013-01-07 Thread John Sorkin
Windows 7 R 2.12.1 I am trying to write a function (see sample code below) that will take the output of a t-test and produce results suitable for a table. I have two questions (1) You will note that the name of the outcome variable, which is value in the input is replaced by the string outcome

[R] checker/chequer board pattern as a colour

2013-01-07 Thread Federico Calboli
Hi All, is there a reasonably simple way of using a black and white chequer/checker board pattern as a colour: barplot(mydata, col = c('red', 'blue' 'checkerboard')) ? BW F -- Federico C. F. Calboli Neuroepidemiology and Ageing Research Imperial College, St. Mary's Campus Norfolk Place,

Re: [R] Function to tabulate t-test (1) How can I get dependent variable name (2) How can I make data frame know to function

2013-01-07 Thread Bert Gunter
John: R2.12 ??? Time to update. 1. ?t.test and note the last entry in the Value section. 2. ?with -- Bert On Mon, Jan 7, 2013 at 6:44 AM, John Sorkin jsor...@grecc.umaryland.edu wrote: Windows 7 R 2.12.1 I am trying to write a function (see sample code below) that will take the output

Re: [R] Function to tabulate t-test (1) How can I get dependent variable name (2) How can I make data frame know to function

2013-01-07 Thread Rui Barradas
Hello, A simple change to your function partly answers to both questions. Table2 - function(formula, data) { temp - t.test(formula, data) mydf - data.frame(dep=temp$data.name, female=temp$estimate[1],male=temp$estimate[2], p=temp$p.value,

Re: [R] Function to tabulate t-test (1) How can I get dependent variable name (2) How can I make data frame know to function

2013-01-07 Thread Rui Barradas
I've just realized that you're swapping female and male in the creation of the results data frame. It should be Table2 - function(formula, data) { dname - rownames(attr(terms(formula), factors))[1] temp - t.test(formula, data) mydf - data.frame(dep=temp$data.name,

Re: [R] how to aggregate T-test result in an elegant way?

2013-01-07 Thread Yao He
Hi,arun Yes , I just want to do the t.test I think maybe it is not necessary to generate a 3D array from the raw data.frame by acast() at first Thanks a lot 2013/1/7 arun smartpink...@yahoo.com: Hi Yao, It's okay. How did you generate the 3 D array? Using ?acast() I am not sure I

[R] list of lists to matrix

2013-01-07 Thread eliza botto
dear R family, [a text file has been attached for better understanding] i have a list of 16 and each of of that is further subdivided into variable number of lists. So, i have a kind of list into lists phenomenon. [[1]]$'1' 1 2 3 4 5 6 7 8 9 [[1]]$'2' 1

[R] Have problem to do loop to generate transformed chi-squared variates

2013-01-07 Thread Agnes Ayang
Hello R-helpers, I need to generate standard variates normal to 'create' chi-squared variates. To make you more understand, (1)   a-rnorm(3,0,1) *after do (1), I need to squared and summed the three values. My problem is, how am I going to continue the programming if I had to repeat the

Re: [R] Have problem to do loop to generate transformed chi-squared variates

2013-01-07 Thread R. Michael Weylandt
Hi Agnes, I think this is likely homework, right? If that's the case, we're really not supposed to give you help. If not, why not simply use rchisq to generate chi-sq variates exactly? MW On Mon, Jan 7, 2013 at 4:13 PM, Agnes Ayang agnes.ay...@yahoo.com wrote: Hello R-helpers, I need to

[R] renumber a list of numbers

2013-01-07 Thread Charles Determan Jr
Greetings R users, I am trying to renumber my groups within the file shown below. The groups are currently set as 8,9,10,etc. I would like to renumber this as 1,2,3,etc. I have searched the help files and only come across using the rownames to renumber the values but I need to match values.

Re: [R] list of lists to matrix

2013-01-07 Thread R. Michael Weylandt
Something like do.call(cbind, lists) ? MW On Mon, Jan 7, 2013 at 4:13 PM, eliza botto eliza_bo...@hotmail.com wrote: dear R family, [a text file has been attached for better understanding] i have a list of 16 and each of of that is further subdivided into variable number of lists. So, i

Re: [R] list of lists to matrix

2013-01-07 Thread eliza botto
Thanks arun and weylandt,it perfectly worked out.. elisa From: michael.weyla...@gmail.com Date: Mon, 7 Jan 2013 16:37:53 + Subject: Re: [R] list of lists to matrix To: eliza_bo...@hotmail.com CC: r-help@r-project.org Something like do.call(cbind, lists) ? MW On Mon, Jan

Re: [R] random effects model

2013-01-07 Thread rex2013
Hi A.K Below is the comment I get, not sure why. BP.sub3 is the stacked data without the missing values. BP.geese3 - geese(HiBP~time*MaternalAge,data=BP.sub3,id=CODEA, family=binomial, corstr=unstructured, na.action=na.omit)Error in `contrasts-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :

Re: [R] round 2.3 to 2.5 and 2.2 to 2.0

2013-01-07 Thread Mat
thx, works perfektly :-) -- View this message in context: http://r.789695.n4.nabble.com/round-2-3-to-2-5-and-2-2-to-2-0-tp4654813p4654829.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] Log scale on y axis of parallel coordinate plot (lattice)

2013-01-07 Thread Roland Seubert
Hello all, I would like to make a parallel coordinate plot with lattice. The plot should have vertical log scale axes, and should in principle look like this one (I put less chemical elements in my example below): http://www.geokem.com/images/scans/epr-and-N_Chile_Ridge.gif The data I am

Re: [R] Predicting New Data -

2013-01-07 Thread rydood
Uwe Ligges-3 wrote Hard to debug given we neither have the formula nor the data. All I can give is that the data is in the form y, x1, x2, x3,... and the formula is y ~ x1+x2+x3+... Maybe it's because I'm not explicitly specifying the base learners. -- View this message in context:

[R] Refer to previous row

2013-01-07 Thread Paolo Donatelli
Hi all, I have a very basic doubt -- but still, I am a newby! My question is about referring to the previous row: in a sample as the following... ID X1 X2 1 A 12 2 A 6 3 A 10 1 B 17 2 B 19 1 C 22 1 D 13 2 D 19 3 D 21 ... I would like to create a dummy

Re: [R] plot x-axis DateTime NOT evenly spaced

2013-01-07 Thread arun
Hi, Try this: dat1-read.table(text=1 2012-07-01 00:57:54 +0900    156 2 2012-07-01 01:07:41 +0900    587 3 2012-07-01 01:09:31 +0900    110 4 2012-07-01 01:18:42 +0900    551 5 2012-07-01 01:39:01 +0900    1219 6 2012-07-01 01:40:40 +0900  99,sep=,header=FALSE,stringsAsFactors=FALSE)

[R] posting a question in the R-help forum

2013-01-07 Thread Violet Swakman
Hello, I wanted to post this question below, on the R-help forum, but I'm not sure I succeeded because it said that I wasn't subscribed to the mailing list yet. Now I am subscribed, but will my question be accepted now automatically, or should I submit it again? Thanks in advance, Violet Swakman

Re: [R] how to aggregate T-test result in an elegant way?

2013-01-07 Thread arun
Hi Yao, It's okay. How did you generate the 3 D array? Using ?acast() I am not sure I understand your question if you meet a t-test task as I described  , is that generate a high-dimension array  a good way ? Do you want to do the t-test in the melt dataset? b- read.table(text= ID    O2   

Re: [R] Predicting New Data -

2013-01-07 Thread Benjamin Hofner
Sorry, but your current information doesn't help to solve your problem. Not having explicit base-learners is not the cause of your problem, especially as for glmboost() there are no explicit base-learners. You should definitely provide a minimal example that helps to reproduce your error/problem.

[R] R-help post Bayesian CART

2013-01-07 Thread Rachel Plewes
Hi, I have explored many of the R packages that construct Bayesian trees including the tgp, bart, BMA and maptree packages. I have also searched through some other packages but they do not seem to be suitable for the type of analysis I need to do. I need to construct Bayesian CART that have

[R] try()-function does not catch error in BATCH-job if Matrix is loaded

2013-01-07 Thread Sarah Brockhaus
Hello, In my simulation I use the try()-function to catch possible errors when fitting models. I run the simulationon a Linux-server using the command R CMD BATCH nameOfFile.R . When executing the code as batch-job I get the problem that the execution is halted without giving an error

Re: [R] how to aggregate T-test result in an elegant way?

2013-01-07 Thread arun
Hi Yao, You could also have the results in a wide format: res-do.call(rbind,lapply(lapply(split(b,b$variable),function(x) t.test(x$value[x$O2==13%],x$value[x$O2==21%])),function(x) data.frame(mean13=x$estimate[1],mean21=x$estimate[2],p.value=x$p.value,CILow=x$conf.int[1],CIHigh=x$conf.int[2])))

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread Michael Rennie
Any thoughts on what that dirty hack might be or any leads on where to start? Perhaps a whole new plot region in the margin or something? Is that even possible? I'm having a difficult time imagining how I can do this. Mike Uwe Ligges wrote: On 07.01.2013 07:00, Michael Rennie wrote: Hi

Re: [R] renumber a list of numbers

2013-01-07 Thread Charles Determan Jr
Thank you for your response, I didn't do the -7 because this is just a small part of the dataset and the number are not all consistent (ie skip some numbers occasionally). However, I did not think of the as.numeric(as.factor()) sequence. That did the trick, simple lapse in my thoughts that cost

Re: [R] renumber a list of numbers

2013-01-07 Thread Sarah Goslee
Hi, It isn't entirely clear what you want, because it seems too simple. And most of your sample data are irrelevant, aren't they? Why not just use: testdata$Event_name2 - testdata$Event_name - 7 Or you could try: testdata$Event_name3 - as.numeric(as.factor(testdata$Event_name)) which will

Re: [R] Refer to previous row

2013-01-07 Thread Rui Barradas
Hello, Try the following. dat$X3 - c(0L, dat$ID[-1] = dat$ID[-nrow(dat)]) Hope this helps, Rui Barradas Em 07-01-2013 13:33, Paolo Donatelli escreveu: Hi all, I have a very basic doubt -- but still, I am a newby! My question is about referring to the previous row: in a sample as the

Re: [R] During startup - Warning messages:

2013-01-07 Thread Prof Brian Ripley
On 07/01/2013 14:50, Yongjie wrote: Dear Sir/Madam, After installing R, I saw this warning message in red when I open the R... During startup - Warning messages: 1: Setting LC_CTYPE failed, using C 2: Setting LC_COLLATE failed, using C 3: Setting LC_TIME failed, using C 4: Setting LC_MESSAGES

Re: [R] Refer to previous row

2013-01-07 Thread jim holtman
try this x - read.table(text = 'ID X1 X2 + 1 A 12 + 2 A 6 + 3 A 10 + 1 B 17 + 2 B 19 + 1 C 22 + 1 D 13 + 2 D 19 + 3 D 21', header = TRUE, as.is = TRUE) x$X3 - c(0, diff(x$ID) = 0) x ID X1 X2 X3 1 1 A 12 0 2 2 A 6 0 3 3 A 10 0 4 1 B 17 1 5

Re: [R] During startup - Warning messages:

2013-01-07 Thread R. Michael Weylandt
I'd suggest you do as the following message suggests and follow the R-MAC-FAQ section 9 notes on locales and whatnot. If you need specific advice on following this, we'll need to know what version of OS X you're running and what your local settings are. That said, I don't think you'll actually

Re: [R] Refer to previous row

2013-01-07 Thread David Winsemius
On Jan 7, 2013, at 5:33 AM, Paolo Donatelli wrote: Hi all, I have a very basic doubt -- but still, I am a newby! My question is about referring to the previous row: in a sample as the following... ID X1 X2 1 A 12 2 A 6 3 A 10 1 B 17 2 B 19 1 C 22 1 D 13 2 D

Re: [R] Refer to previous row

2013-01-07 Thread Berend Hasselman
On 07-01-2013, at 14:33, Paolo Donatelli donatellipa...@gmail.com wrote: Hi all, I have a very basic doubt -- but still, I am a newby! My question is about referring to the previous row: in a sample as the following... ID X1 X2 1 A 12 2 A 6 3 A 10 1 B 17 2 B

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread Uwe Ligges
On 07.01.2013 17:06, Michael Rennie wrote: Any thoughts on what that dirty hack might be or any leads on where to start? Perhaps a whole new plot region in the margin or something? Is that even possible? I'm having a difficult time imagining how I can do this. Ideas fir ugly hacks: Either

Re: [R] renumber a list of numbers

2013-01-07 Thread Rui Barradas
Hello, I'm not sure I understand. Do you want to renumber column Event_name starting at 1? If so the following does the job. dat$Event_name - dat$Event_name - min(dat$Event_name) + 1 Hope this helps, Rui Barradas Em 07-01-2013 16:41, Charles Determan Jr escreveu: Greetings R users, I am

Re: [R] During startup - Warning messages:

2013-01-07 Thread David Winsemius
On Jan 7, 2013, at 6:50 AM, Yongjie wrote: Dear Sir/Madam, After installing R, I saw this warning message in red when I open the R... During startup - Warning messages: 1: Setting LC_CTYPE failed, using C 2: Setting LC_COLLATE failed, using C 3: Setting LC_TIME failed, using C 4: Setting

Re: [R] renumber a list of numbers

2013-01-07 Thread David Winsemius
On Jan 7, 2013, at 8:41 AM, Charles Determan Jr wrote: Greetings R users, I am trying to renumber my groups within the file shown below. The groups are currently set as 8,9,10,etc. I would like to renumber this as 1,2,3,etc. I have searched the help files and only come across using

Re: [R] Refer to previous row

2013-01-07 Thread Duncan Murdoch
On 07/01/2013 8:33 AM, Paolo Donatelli wrote: Hi all, I have a very basic doubt -- but still, I am a newby! My question is about referring to the previous row: in a sample as the following... ID X1 X2 1 A 12 2 A 6 3 A 10 1 B 17 2 B 19 1 C 22 1 D 13 2 D 19 3

Re: [R] renumber a list of numbers

2013-01-07 Thread David Winsemius
On Jan 7, 2013, at 10:13 AM, David Winsemius wrote: On Jan 7, 2013, at 8:41 AM, Charles Determan Jr wrote: Greetings R users, I am trying to renumber my groups within the file shown below. The groups are currently set as 8,9,10,etc. I would like to renumber this as 1,2,3,etc. I have

[R] R: Re: Refer to previous row

2013-01-07 Thread Paolo Donatelli
It works! The rationale, if I have understood well, is to take my vector of N elements, ask to remove the first/last element, and replace the blank space with a given value. Thank you all for the support! -Original Message- From: Duncan Murdoch murdoch.dun...@gmail.com Date: Mon, 07

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread David Winsemius
On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote: Any thoughts on what that dirty hack might be or any leads on where to start? Perhaps a whole new plot region in the margin or something? Is that even possible? I'm having a difficult time imagining how I can do this. The `text`

Re: [R] Refer to previous row

2013-01-07 Thread William Dunlap
I suppose it is just some basic matter of indexing language, something like X3- as.numeric ( ID[n] = ID[n-1]) but it is not so simple! If you first define 'n' as n - seq_along(ID)[-1] # 2:length(ID) then that code works. with(Data, { n - seq_along(ID)[-1] ; as.numeric ( ID[n] =

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread Michael Rennie
Right- I think the issue is getting a text() command (which does accept srt) to work outside the plot region, and in the margin where I need it to appear. This is easy to hack in a single plot, but not so clear how to do it in a multi-panel environment with an outer margin. I suspect going

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread David Winsemius
On Jan 7, 2013, at 10:45 AM, Michael Rennie wrote: Right- I think the issue is getting a text() command (which does accept srt) to work outside the plot region, and in the margin where I need it to appear. This is easy to hack in a single plot, but not so clear how to do it in a

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread ilai
On Mon, Jan 7, 2013 at 11:52 AM, David Winsemius dwinsem...@comcast.netwrote: If you are going that route you may want to look at the gridBase package. Yes for mixing base and grid graphics but IMHO overkill here. Replacing the last mtext line with grid::grid.text('dependent B', 0.985 , 0.5

[R] pattern matching

2013-01-07 Thread Data Analytics Corp.
Hi, I have a simple question. Suppose I have a string x$Expensive. I want to find the position of the $ in this string; i.e., I want a function that returns 2. I tried grep, regexpr, etc with no luck, unless I'm just using them incorrectly. Any suggestions? Thanks, Walt

Re: [R] try()-function does not catch error in BATCH-job if Matrix is loaded

2013-01-07 Thread luke-tierney
This is due to long-staning issue in methods internals, which are involved because loading Matrix shadows base::mean with Matrix::mean. A work-around has been in place in R_devel for some time; a proper fix may come at some point in the future. So if your real code doesn't need the moficied mean

Re: [R] random effects model

2013-01-07 Thread arun
HI, Regarding question:2) Have you checked summary(m1)? data(seizure) ## Diggle, Liang, and Zeger (1994) pp166-168, compare Table 8.10 seiz.l - reshape(seizure,    varying=list(c(base,y1, y2, y3, y4)),    v.names=y, times=0:4, direction=long)

Re: [R] random effects model

2013-01-07 Thread arun
HI, Just to add: fit3-geese(hibp~MaternalAge*time,id=CODEA,data=BP.stack5,family=binomial,corstr=exch,scale.fix=TRUE) #works  summary(fit3)$mean[p] # p #(Intercept) 0. #MaternalAge4    0.49099242 #MaternalAge5    0.04686295 #time21 

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread Michael Rennie
HA! Works perfectly!!! Thanks so much ilai. ilai wrote: On Mon, Jan 7, 2013 at 11:52 AM, David Winsemius dwinsem...@comcast.net mailto:dwinsem...@comcast.net wrote: If you are going that route you may want to look at the gridBase package. Yes for mixing base and grid graphics but

Re: [R] pattern matching

2013-01-07 Thread Marc Schwartz
On Jan 7, 2013, at 3:22 PM, Data Analytics Corp. w...@dataanalyticscorp.com wrote: Hi, I have a simple question. Suppose I have a string x$Expensive. I want to find the position of the $ in this string; i.e., I want a function that returns 2. I tried grep, regexpr, etc with no luck,

Re: [R] pattern matching

2013-01-07 Thread William Dunlap
$ has a special meaning (end-of-string) in regular expressions, so you can either escape it with \\ or not use regular expressions in regexpr(): regexpr(\\$, x$Expensive) [1] 2 attr(,match.length) [1] 1 attr(,useBytes) [1] TRUE regexpr($, x$Expensive, fixed=TRUE) [1] 2 attr(,match.length) [1]

Re: [R] pattern matching

2013-01-07 Thread arun
HI, str1-x$Expensive regexpr(\\$,str1)[1] #[1] 2  str2-x$Exp$Expression unlist(gregexpr(\\$,str2)) #[1] 2 6 A.K. - Original Message - From: Data Analytics Corp. w...@dataanalyticscorp.com To: r-help@R-project.org r-help@r-project.org Cc: Sent: Monday, January 7, 2013 4:22 PM

[R] Amelia algorithm

2013-01-07 Thread Martin
Dear all. First of all, my english isn't verry good, but I hope I can convey my concern. I've a general question about the Amelia algorithm. I'm no mathematician or statistician, but I had to use R and impute and analyse some data, and Amelia showed results that fitted my expectations. I'll have

Re: [R] checker/chequer board pattern as a colour

2013-01-07 Thread Greg Snow
Not as a simple color, but you can use the rasterImage function to add a rectangle with a checkerboard pattern to a an existing plot, the examples for the function use a simple checkerboard pattern. Be careful of overusing something like this, too many patterned areas in a plot can be more

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread Greg Snow
And look at the grconvertX and grconvertY functions for possibly ways to compute positioning information when using text with base graphics. On Mon, Jan 7, 2013 at 11:35 AM, David Winsemius dwinsem...@comcast.netwrote: On Jan 7, 2013, at 8:06 AM, Michael Rennie wrote: Any thoughts on what

Re: [R] checker/chequer board pattern as a colour

2013-01-07 Thread Federico Calboli
On 7 Jan 2013, at 21:53, Greg Snow 538...@gmail.com wrote: Not as a simple color, but you can use the rasterImage function to add a rectangle with a checkerboard pattern to a an existing plot, the examples for the function use a simple checkerboard pattern. Be careful of overusing

Re: [R] Changing mtext direction, or using text for the margin?

2013-01-07 Thread David L Carlson
Or use the ugly hack with a bit of locator() trial and error. Replace the last mtext() call with text(17.9, 31.9, dependent B, srt=-90, xpd=NA, cex=1.25) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX

Re: [R] how to aggregate T-test result in an elegant way?

2013-01-07 Thread Yao He
Yes, thanks a lot for your help! Regards 2013/1/8 arun smartpink...@yahoo.com: Hi Yao, You could also have the results in a wide format: res-do.call(rbind,lapply(lapply(split(b,b$variable),function(x) t.test(x$value[x$O2==13%],x$value[x$O2==21%])),function(x)

Re: [R] Amelia algorithm

2013-01-07 Thread zGreenfelder
On Mon, Jan 7, 2013 at 4:29 PM, Martin lh...@gmx.net wrote: Dear all. First of all, my english isn't verry good, but I hope I can convey my concern. I've a general question about the Amelia algorithm. I'm no mathematician or statistician, but I had to use R and impute and analyse some data,

Re: [R] random effects model

2013-01-07 Thread arun
HI, BP.stack5 is the one without missing values. na.omit().  Otherwise, I have to use the option na.action=.. in the ?geese() statement You need to read about the correlation structures.  IN unstructured option, more number of parameters needs to be estimated,  In repeated measures design,

[R] multiple versions of function

2013-01-07 Thread ivo welch
dear R experts: I want to define a function the calculates the black-scholes value. it takes 5 named parameters, BS - function(S,K,dt,rf,sigma) {} . let's presume I want to be able to call this not only with my 5 numeric vectors BS( sigma=0.3, S=100, K=100, dt=1, rf=0.1 ) and BS( 100, 100, 1,

Re: [R] multiple versions of function

2013-01-07 Thread David Winsemius
On Jan 7, 2013, at 3:57 PM, ivo welch wrote: dear R experts: I want to define a function the calculates the black-scholes value. it takes 5 named parameters, BS - function(S,K,dt,rf,sigma) {} . let's presume I want to be able to call this not only with my 5 numeric vectors BS( sigma=0.3,

Re: [R] plot xaxp issue

2013-01-07 Thread Elaine Kuo
Hello, Thanks again. But something wrong with the subset after lm It is not about drawing plot many times but coding points or graphic objects by some factor. In your case sex. Instead of boyline-lm(body_weight ~ body_length, boy) use collective data frame together and subset only one

Re: [R] plot xaxp issue

2013-01-07 Thread Elaine Kuo
Hello, I figured out that the code should be boyline-lm(body_weight ~ body_length, data=subset (together,,sex==boy)) However, the could be omitted if the field name happened to be numeric, such as 1, 2, or 3. Please kindly explain why the could be omitted for numbers. Thanks again. Elaine On

[R] error in a abline loop

2013-01-07 Thread Elaine Kuo
Hello I have data of body length and body weight of people of different skin colors. I tried to write a code to plot body length and body weight according to the skin colors. (Thanks for Petr's advice so far.) A loop is used but an error shows up in the following code. It says: unexpected '}'

Re: [R] error in a abline loop

2013-01-07 Thread Pascal Oettli
Hello, A ) is missing. I guess your code should be for (i in 1:7){ subs - data$skin_color==levels(data$skin_color)[i] line -lm(body_weight~body_length, data=subset(data, subset=subs)) abline(line,col=c(yellow,chocolate1,darkorange2,red3,saddlebrown,coral4,grey38)[i],lwd=2) } HTH, Pascal Le

Re: [R] error in a abline loop

2013-01-07 Thread Elaine Kuo
Hello Thanks. It is right a ) is missing for lm. With the modification, I ran the code but the command seems not closed, with + instead of . Please kindly help. The code modified for (i in 1:7) { subs - data$skin_color==levels(data$skin_color)[i] line-lm(body_weight~body_length,

Re: [R] error in a abline loop

2013-01-07 Thread Pascal Oettli
Hi, Now, you have too many ) in the code. The last line should be (as written in the code I sent you): abline(line,col=c(yellow,chocolate1,darkorange2, red3,saddlebrown,coral4,grey38)[i],lwd=2) HTH, Pascal Le 08/01/2013 11:24, Elaine Kuo a écrit : Hello Thanks. It is right a ) is

Re: [R] multiple versions of function

2013-01-07 Thread ivo welch
hi david---can you give just a little more of an example? the function should work with call by order, call by name, and data frame whose columns are the names. /iaw Ivo Welch (ivo.we...@gmail.com) On Mon, Jan 7, 2013 at 4:25 PM, David Winsemius dwinsem...@comcast.net wrote: On Jan 7,

Re: [R] error in a abline loop

2013-01-07 Thread arun
HI, A possible guess ( with no data): for (i in 1:7) {     subs - data$skin_color==levels(data$skin_color)[i]     line-lm(body_weight~body_length, data=subset(data, subset=subs)) #closing parentheses     abline(line,col=c(yellow,chocolate1,darkorange2, red3,saddlebrown,coral4,grey38)[i],lwd=2) 

[R] Conditional Statistics

2013-01-07 Thread Joseph Norman Thomson
Hello, I am a new user of R. I am coming from SAS and do statistics on stock market data, economic data, and social data. My question is this: How can you get the mean, standard dev, etc. of a variable based on a conditional statement on either the same variable or a different variable in the

Re: [R] Conditional Statistics

2013-01-07 Thread Simon Blomberg
You can use the tapply function to do this. You can't type a line into the mean statement. (See ?mean for what you can type in there). The general approach is to have a vector of data (stock prices) and a categorical variable (day of week). Then break up the data vector according to the levels