Re: [R] Sourcing functions

2010-05-02 Thread Sharpie
David Winsemius wrote: If you read the Installation and Administration document you should find material on that process. Look for the section that describes the care and feeding of .Rprofile or type ?Startup # in an R console session. And when you are ready, the Writing R

Re: [R] Resize Graphics Window

2010-05-02 Thread Tal Galili
Hi Sigal, could you give a simple example ? I can imagine in some cases that enlarging the windows would help, but on others there are other parameters you would like to play with instead. So having an example to solve, will help people help you. Tal Contact

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread Jim Lemon
On 05/02/2010 11:56 AM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each plot to have a unique title based on the inputted variable as well as a

[R] help with tapply or other apply

2010-05-02 Thread peterko
Hi, my data looks this: id forma program kod obor rocnik 1 10001 kombinovaná Matematika M1101 matematika 1 2 10002 prezenční Informatika N1801 teoretická informatika 1 3 10002 prezenční Informatika

Re: [R] ggplot2's geom_errorbar legend

2010-05-02 Thread Giovanni Azua
Hello Ista, On May 1, 2010, at 8:37 PM, Ista Zahn wrote: Hi Giovanni, A reproducible example would help. Also, since I think this will be tricky, it might be a good idea to post it to the ggplot2 mailing list (you can register at http://had.co.nz/ggplot2/ ). Best, Ista First, thank you

Re: [R] help with tapply or other apply

2010-05-02 Thread Patrick Burns
You don't show how you are doing it with a 'for' loop, but I suspect that you just need to eliminate the subscript you are using for rows. For example: for(i in 1:nrow(data)) { data$z[i] - data[i, 'x'] + data[i, 'y'] } can be written more simply and much more efficiently as: data$z -

Re: [R] help with tapply or other apply

2010-05-02 Thread Jim Lemon
On 05/02/2010 08:26 PM, peterko wrote: Hi, my data looks this: id forma program kod obor rocnik 1 10001 kombinovaná Matematika M1101 matematika 1 2 10002 prezenční Informatika N1801 teoretická informatika 1 3 10002

Re: [R] help with tapply or other apply

2010-05-02 Thread peterko
Thank you Jim, it works very well. I do not need do it using tapply, but i think that it is the way. And Patrick thank you too -- View this message in context: http://r.789695.n4.nabble.com/help-with-tapply-or-other-apply-tp2122683p2122728.html Sent from the R help mailing list archive at

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread Duncan Murdoch
On 02/05/2010 4:07 AM, Jim Lemon wrote: On 05/02/2010 11:56 AM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each plot to have a unique title based

[R] Where is the splines package

2010-05-02 Thread Shige Song
Dear All, I noticed that the splines package is no longer available on CRAN. Has it been replaced by something else? is it still available in some other locations? Thanks. Shige __ R-help@r-project.org mailing list

[R] Re :argument is not numeric or logical

2010-05-02 Thread Mohan L
Hi all, I have data size of : dim(sample) [1] 3594317 The first column is stdate - is date ( 01/11/2009 00:00:00,02/11/2009 00:00:00,02/11/2009 00:00:00 etc... ) Login is 13th column - is numbers (12,0,1 erc...) The below operation return the following error. sample1 -

Re: [R] Where is the splines package

2010-05-02 Thread David Winsemius
On May 2, 2010, at 9:32 AM, Shige Song wrote: Dear All, I noticed that the splines package is no longer available on CRAN. Has it been replaced by something else? is it still available in some other locations? I believe you will discover that splines is part of the standard install

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread David Winsemius
On May 2, 2010, at 9:39 AM, Mohan L wrote: Hi all, I have data size of : dim(sample) [1] 3594317 Your code has a different name for the sample object. And it would be more informative if you offered str on sample1. -- David. The first column is stdate - is date ( 01/11/2009

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread Nikhil Kaza
say x is the variable. plot(..., title=paste(x, whatever else), ...) should work as well. same should work with file names as well. Nikhil On May 1, 2010, at 9:56 PM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function

[R] how to plot forecast together with historical series in OLS or special ARIMA model

2010-05-02 Thread Olga
Dear R users, Please let me know how to plot the forecast in such a model: First I do it simple with ARIMA model that works ok with the codes provided to me at the lecture: arima-arima(HCPIlong, order=c(1,1,0)) arima.predict-predict(arima, n.ahead= 5 )

[R] Replace query

2010-05-02 Thread burgundy
Hi, I'm trying to replace all values equal to 1 in one file (a) with the value in the corresponding column in a separate file (b). Example below. Any help (and brief notes if poss) much appreciated. Thanks!! file a: 0,0,1,1,0 1,0,0,0,1 0,0,0,0,0 1,0,1,1,0 file b: 3,4,6,8,11 output request:

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread Mohan L
Your code has a different name for the sample object. And it would be more informative if you offered str on sample1. This is the result of str on sample1. str(sample1) 'data.frame':35943 obs. of 17 variables: $ stdate : Factor w/ 7 levels 01/11/09 00:00,..: 1 1 1 1 1 1 1 1 1 1 ...

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread David Winsemius
On May 2, 2010, at 10:10 AM, Nikhil Kaza wrote: say x is the variable. plot(..., title=paste(x, whatever else), ...) should work as well. same should work with file names as well. Perhaps in an alternate universe it might, ... but it doesn't in this one. title is not the correct

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread David Winsemius
On May 2, 2010, at 10:22 AM, Mohan L wrote: Your code has a different name for the sample object. And it would be more informative if you offered str on sample1. This is the result of str on sample1. str(sample1) 'data.frame':35943 obs. of 17 variables: $ stdate : Factor w/

Re: [R] Replace query

2010-05-02 Thread Tal Galili
The following code might work: a[a==1] - b[a==1] But it depends on what a and b are exactly (vector, matrix, list, data.frame). Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me:

Re: [R] Replace query

2010-05-02 Thread David Winsemius
On May 2, 2010, at 7:01 AM, burgundy wrote: Hi, I'm trying to replace all values equal to 1 in one file (a) with the value in the corresponding column in a separate file (b). Example below. Any help (and brief notes if poss) much appreciated. Thanks!! file a: 0,0,1,1,0 1,0,0,0,1

Re: [R] Scree diagram,

2010-05-02 Thread Ista Zahn
Hi Phillip, I've never heard of a scree _diagram_, I'm not even sure what that is. To get started with principal components analysis in R, I suggest the psych package. The package vignettes are quite detailed, I suggest starting there. Best, Ista On Sun, May 2, 2010 at 12:06 AM, Philip Wong

Re: [R] cbind and automatic type conversion

2010-05-02 Thread Uwe Ligges
On 01.05.2010 21:09, Giovanni Azua wrote: Hello, I have three method types and 100 generalization errors for each, all in the range [0.65,0.81]. I would like to make a stacked histogram plot using ggplot2 with this data ... Therefore I need a data frame of the form e.g. Method

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread Mohan L
Your code has a different name for the sample object. And it would be more informative if you offered str on sample1. This is the result of str on sample1. str(sample1) 'data.frame':35943 obs. of 17 variables: $ stdate : Factor w/ 7 levels 01/11/09 00:00,..: 1 1 1 1 1 1 1 1 1 1

Re: [R] Errors when trying to open odfWeave documents

2010-05-02 Thread Dieter Menne
Paul Hurley wrote: Is there a known problem with odfWeave on Windows? I've seen some messages on R-help from a year or two back where people couldn't install the XML package, but XML installed fine on my Windows box (it was more tricky on Kubuntu, but worked in the end). There was

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

2010-05-02 Thread Gustaf Rydevik
Hi all, I hope that there is someone that can help me out here. I am trying to load() a workspace on os x (R 2.11.0) that was saved in windows XP (R 2.9). In that workspace, there's a data.frame with names that contain swedish characters. These characters become garbled, which is a major problem.

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread David Winsemius
On May 2, 2010, at 11:22 AM, Mohan L wrote: Your code has a different name for the sample object. And it would be more informative if you offered str on sample1. This is the result of str on sample1. str(sample1) 'data.frame':35943 obs. of 17 variables: $ stdate : Factor w/

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

2010-05-02 Thread Duncan Murdoch
Gustaf Rydevik wrote: Hi all, I hope that there is someone that can help me out here. I am trying to load() a workspace on os x (R 2.11.0) that was saved in windows XP (R 2.9). In that workspace, there's a data.frame with names that contain swedish characters. These characters become garbled,

Re: [R] Scree diagram,

2010-05-02 Thread John Kane
Presumably, a scree plot? Philip may find something useful here http://www.statmethods.net/advstats/factor.html --- On Sun, 5/2/10, Ista Zahn istaz...@gmail.com wrote: From: Ista Zahn istaz...@gmail.com Subject: Re: [R] Scree diagram, To: Philip Wong tombfigh...@mysinamail.com Cc:

Re: [R] Scree diagram,

2010-05-02 Thread Muhammad Rahiz
1) I believe you wanted a scree plot which shows the percentage of variance explained (y-axis) versus the principal components (x-axis). To do that, all you needs a simple plot(x,y) function where x = pc and y = variance. It is called a scree plot because the plot looks like a scree on the

Re: [R] help with tapply or other apply

2010-05-02 Thread Henrique Dallazuanna
Another option could be: data$z - as.numeric(gsub((^\\d{4}).*, \\1, gsub(^$, 2009, data$ukrok))) - data$rocnik On Sun, May 2, 2010 at 8:25 AM, peterko lanikpe...@gmail.com wrote: Thank you Jim, it works very well. I do not need do it using tapply, but i think that it is the way. And

[R] GSA list to text file

2010-05-02 Thread Loren Engrav
Greetings and thank you Am using GSA and have the GSA.listsets object of class list which displays fine But how do I get the object written to a text file? I see to convert to data frame and then write.table but GSAwk1df - data.frame(GSAwk1list, row.names=NULL, check.rows=FALSE,

[R] percent by subset

2010-05-02 Thread Geoffrey Smith
Suppose my data looks like this: Obs, Male, Female, Height 1, T, F, 66 2, F, T, 64 3, T, F, 59 4, T, F, 55 5, F, T, 62

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread Mohan L
I have no way to determining _why_ it is not numeric, but it simply is ... not. Your input method turned it into a factor. Perhaps there was one missing delimiter, or there was a stray character in one of the entries in the file. Who knows. Why waste time arguing? Follow the directions for

Re: [R] percent by subset

2010-05-02 Thread Henrique Dallazuanna
Try this: prop.table(table(subset(x, Height 60, select = Male:Female))) On Sun, May 2, 2010 at 2:58 PM, Geoffrey Smith g...@asu.edu wrote: Suppose my data looks like this: Obs, Male, Female, Height 1, T, F, 66 2, F, T,

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread nikhil kaza
Thats right. serves me for not checking the code before posting. but paste should work in anycase with collapse or when x is a single parameter. Nikhil On Sun, May 2, 2010 at 10:24 AM, David Winsemius dwinsem...@comcast.netwrote: On May 2, 2010, at 10:10 AM, Nikhil Kaza wrote: say x is

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread David Winsemius
On May 2, 2010, at 2:10 PM, Mohan L wrote: I have no way to determining _why_ it is not numeric, but it simply is ... not. Your input method turned it into a factor. Perhaps there was one missing delimiter, or there was a stray character in one of the entries in the file. Who knows.

Re: [R] percent by subset

2010-05-02 Thread David Winsemius
On May 2, 2010, at 1:58 PM, Geoffrey Smith wrote: Suppose my data looks like this: Obs, Male, Female, Height 1, T, F, 66 2, F, T, 64 3, T, F, 59 4, T, F,

[R] adding year information to a scatter plot

2010-05-02 Thread Ozan Bakis
Hi R users, I would like to add year information to each point in a scatter plot. The following example shows what i mean: df=data.frame(year=c(2001,2002,2003),a=c(8,9,7),b=c(100,90,95)) df plot(b~a,data=df) Now, I would like to see which point belongs to 2001, 2002 and 2003 in the above

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread Mohan L
as.numeric(assame$Login) //convert to numerics Nooo. You did not do what what I suggested earlier. Do not reach for your keyboard in the R console until you have read the FAQ section regarding converting factors to numeric. If you don't want to read the FAQ Hi David, Now I

Re: [R] generating correlated random variables from different distributions

2010-05-02 Thread Richard and Barbara Males
Thank you for your reply. The application is a Monte Carlo simulation in environmental planning. Different possible remediation measures have different costs, and produce different results. For example, a $20,000 plan may add 10 acres of wetlands and 12 acres of bird habitat. The desire is to

[R] question about 2SLS

2010-05-02 Thread Dipankar Basu
Hi All, I am using R 2.11.0 on a Ubuntu machine. I estimated a model using tsls from the package sem. Is there a way to get Newey West standard errors for the parameter estimates? When estimating the model by OLS, I used NeweyWest from the package sandwich to get HAC standard errors. But, I am

Re: [R] question about 2SLS

2010-05-02 Thread Achim Zeileis
On Sun, 2 May 2010, Dipankar Basu wrote: Hi All, I am using R 2.11.0 on a Ubuntu machine. I estimated a model using tsls from the package sem. Is there a way to get Newey West standard errors for the parameter estimates? When estimating the model by OLS, I used NeweyWest from the package

Re: [R] 3-D response surface using wireframe()

2010-05-02 Thread Deepayan Sarkar
On Fri, Apr 9, 2010 at 1:46 PM, array chip arrayprof...@yahoo.com wrote: David, Thanks for the 2 previous posts from Sarkar. Actually, I am now one step closer. I am now able to remove the 3 outer lines of the bounding box using par.box argument, even Sarkar said in his 2008 post that

[R] Shell command help

2010-05-02 Thread galen kaufman
Dear R Community, I am trying to run a command line in R that will open an external program, have it import a specific input file, run the program, then close the program. The command line that I got from the developer of the model to do this looks like what you see below: c:\programx.exe

Re: [R] adding year information to a scatter plot

2010-05-02 Thread John Kane
I think that one of the packages, perhaps Hmisc or plotrix does this but you can also do it just using text() Example plot(b~a,data=df, xlim=c(min(df$a)-5,max(df$a)+5), ylim= c(min(df$b)-5,max(df$b)+5)) text( df$a+1,df$b, labels=df$year) Alternatively you can do this in ggplot

Re: [R] adding year information to a scatter plot

2010-05-02 Thread Muhammad Rahiz
Hi Ozan, The {calibrate} package allows you to do that. install.packages(calibrate) library(calibrate) df=data.frame(year=c(2001,2002,2003),a=c(8,9,7),b=c(100,90,95)) df plot(b~a,data=df) textxy(df$a,df$b,df$year) Muhammad On 05/02/2010 08:25 PM, Ozan Bakis wrote: Hi R users, I would like

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

2010-05-02 Thread Gustaf Rydevik
Many thanks Prof. and Duncan! Iconv worked like a charm together with CP1252 as the windows encoding, and now all the text shows up correctly Because the data frame also contained factors with levels that had swedish characters, i ended up writing a small function for converting the encoding of

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread David Winsemius
On May 2, 2010, at 3:27 PM, Mohan L wrote: as.numeric(assame$Login) //convert to numerics Nooo. You did not do what what I suggested earlier. Do not reach for your keyboard in the R console until you have read the FAQ section regarding converting factors to numeric. If you

Re: [R] Curve Fitting/Regression with Multiple Observations

2010-05-02 Thread Kyeong Soo (Joseph) Kim
Many thanks for the suggestion! That may reduce the computational time needed to find x value given the y one (for hundreds of pairs). Certainly, I will look into manuals for approx() and approxfun() in this regard. Again, thanks for your taking time to read my previous posts and make this

Re: [R] Scree diagram,

2010-05-02 Thread Corey Sparks
There is a screeplot() function that takes the output from prcomp. It plots the value of the eigenvalue vs. the eigenvalue's number. CS - Corey Sparks, PhD Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio 501 West Durango Blvd Monterey

Re: [R] question about 2SLS

2010-05-02 Thread Dipankar Basu
Please ignore my previous message about the difference between tsls and ivreg results; that was my mistake. Deepankar On Sun, May 2, 2010 at 5:10 PM, Dipankar Basu basu...@gmail.com wrote: Thanks. Estimation of the same model with the same dataset gives different results when tsls (from

Re: [R] Re :argument is not numeric or logical

2010-05-02 Thread David Winsemius
On May 2, 2010, at 4:25 PM, David Winsemius wrote: On May 2, 2010, at 3:27 PM, Mohan L wrote: as.numeric(assame$Login) //convert to numerics Nooo. You did not do what what I suggested earlier. Do not reach for your keyboard in the R console until you have read the FAQ

[R] Question re: interpolation

2010-05-02 Thread Jessica Schedlbauer
Hello, I have a matrix in which two variables, x and y, are used together to determine z. The variables x and y are sorted into classes. Specifically, values for variable x range from 0 to 2.7 and are sorted into class increments of 0.15 and variable y ranges from 0-2100 with class

Re: [R] Question re: interpolation

2010-05-02 Thread David Winsemius
On May 2, 2010, at 5:27 PM, Jessica Schedlbauer wrote: Hello, I have a matrix in which two variables, x and y, are used together to determine z. The variables x and y are sorted into classes. Specifically, values for variable x range from 0 to 2.7 and are sorted into class increments

Re: [R] Off Topic: teenie weenie numbers -- Was: Precision level

2010-05-02 Thread Liviu Andronic
On 3/26/10, Bert Gunter gunter.ber...@gene.com wrote: represented) is important for numerical calculations, what is the smallest number that anyone has actually seen describing physical phenomena in science? There was a recent article in The Economist (The force is weak with this one, Apr

Re: [R] Question re: interpolation

2010-05-02 Thread Felipe Carrillo
Are you looking for something like this? data - data.frame(first= c(1,2,3,4,5,6,7,8), zehn = c(15,NA,NA,NA,NA,18,NA,25), second = c(4,NA,7,9,NA,10.2,NA,12),     third= c(6,7,NA,NA,10,12,NA,16))   data     library(zoo)     data2 -na.approx(data,na.rm=F)     data2 ?na.approx   Felipe D.

[R] Retrieve regular expression groups

2010-05-02 Thread OKB (not okblacke)
I'm trying to figure out how to get the text captured by capturing groups out of a regex match. For instance, let's say I have the pattern foo ([^ ]+) and I match it against the string This is a foo sentence I am reading. The group in the pattern will match the word sentence in the

Re: [R] Retrieve regular expression groups

2010-05-02 Thread jim holtman
Is this what you want: x - This is a foo sentence I am reading. # only return the desired match sub(.*foo ([^ ]+).*, \\1 file://0.0.0.1/, x) [1] sentence On Sun, May 2, 2010 at 6:03 PM, OKB (not okblacke) brenb...@brenbarn.netwrote: I'm trying to figure out how to get the text

Re: [R] Retrieve regular expression groups

2010-05-02 Thread Gabor Grothendieck
The strapply function in gsubfn does that. See http://gsubfn.googlecode.com On Sun, May 2, 2010 at 6:03 PM, OKB (not okblacke) brenb...@brenbarn.net wrote:        I'm trying to figure out how to get the text captured by capturing groups out of a regex match.  For instance, let's say I have

[R] Calculation error

2010-05-02 Thread oscar linares
Dear Rxperts, Running the following code: === twlo=10; twhi=20; wt=154; vd=0.5; cl=0.046; tau=6; t=3; F=1; wtkg - wt/2.2 # convert lbs to kg vd.pt - wtkg * vd # compute weight-based vd (L) cl.pt - wtkg * cl #

Re: [R] Calculation error

2010-05-02 Thread Joshua Wiley
Dear Oscar, The problem has to do with rounding (because you set the global digits value to 2). Although what you see is 2.4*270=670; when R actually calculates it, it is using full precision. If you set options(digits=7) # the default you will see that AR=2.357362, not 2.4. HTH, Joshua

Re: [R] Calculation error

2010-05-02 Thread Ben Bolker
oscar linares winsaam at gmail.com writes: Dear Rxperts, Running the following code: === twlo=10; twhi=20; wt=154; vd=0.5; cl=0.046; tau=6; t=3; F=1; wtkg - wt/2.2 # convert lbs to kg vd.pt - wtkg * vd #

Re: [R] Retrieve regular expression groups

2010-05-02 Thread OKB (not okblacke)
Gabor Grothendieck wrote: The strapply function in gsubfn does that. See http://gsubfn.googlecode.com Ah, thanks. The documentation for that function is pretty difficult to grasp, but I think I figured it out. . . almost. However, for some reason I can't seem to make strapply

Re: [R] Question re: interpolation

2010-05-02 Thread Jessica Schedlbauer
Thanks to all for their answers so far - the following suggestion comes close to what I was looking for, but perhaps I was not clear enough in my initial message. Following the example below, I'd like to be able to interpolate in such a way that considers adjacent datapoints in both columns

Re: [R] Resize Graphics Window

2010-05-02 Thread Sigal Blay
Here's a simplified code example. library(grid) vp1 - viewport(height=0.8, width=0.8, default.unit=snpc) vp2 - viewport(y = 0.5, just=bottom, gp=gpar(col=red, lwd=2)) # draw triangle function1 - function(vp) { grid.polygon(x=c(0,0.5,1), y=c(0.5,0,0.5), name=triangle, vp=vp) } # draw n

Re: [R] Retrieve regular expression groups

2010-05-02 Thread Gabor Grothendieck
There are quite a few examples in (1) ?strapply, (2) on the home page and (3) in the vignette (4) on r-help back posts if you having problems with understanding the textual description. Note that X and FUN are also arguments to sapply args(sapply) function (X, FUN, ..., simplify = TRUE,

[R] rpart, cross-validation errors question

2010-05-02 Thread Claudia Penaloza
I ran this code (several times) from the Quick-R web page ( http://www.statmethods.net/advstats/cart.html) but my cross-validation errors increase instead of decrease (same thing happens with an unrelated data set). Why does this happen? Am I doing something wrong? # Classification Tree with

[R] Problem with vignette compilation during R CMD check

2010-05-02 Thread Sébastien Bihorel
Dear R-users, I am going through the last steps of package prep before submission to CRAN and I have the following problem. My package contains a single vignette written in optimbase.Rnw and that in stored in /inst/doc. optimbase.Rnw contains multiple \input{} statements that refer to .tex files

[R] Spam of an Adjacency Matrix

2010-05-02 Thread Francisco Silva
Hi folks, I have a matrix of 3 columns and 17 lines that represents a graph or a adjacency matrix. I have also a vector of 30 elements with some of the nodes of the graph repeated. seems like: 1. matrix that represents a graph: 1 2 1 1 3 1 1 4 1 2 1 1 2 4 1 3 1 1 4 1 1 4 2 1 2. vector of nodes