Re: [R] Notation for previous observation in a data frame

2012-07-08 Thread Joshua Wiley
Hi Ernie, I'll use the built in mtcars dataset for demonstrative purposes. You have some condition, which can be used to create an index ## show data frame mtcars ## create index based on your condition i - which(mtcars$carb == 1) ## set those rows of mtcars in your index ## to the index - 1

Re: [R] Tables extraction in R ?

2012-07-08 Thread Jim Lemon
On 07/07/2012 03:23 AM, Greeknovice wrote: Hi, I 'm a novice user of R statistics and my hands-on experience with it is minimal. I want to create a table for my MBA course assignment that looks like the ones that SPSS and MS Excel produces ,the data that the table has to include are the

Re: [R] Notation for previous observation in a data frame

2012-07-08 Thread arun
Hi, Try this:   dat1-data.frame(var1=15:25) dat1$var2-NA  dat1$var2[2:11]-dat1$var1[1:10]  dat1    var1 var2 1    15   NA 2    16   15 3    17   16 4    18   17 5    19   18 6    20   19 7    21   20 8    22   21 9    23   22 10   24   23 11   25   24 You can also do the same within the

[R] Grouped regression

2012-07-08 Thread Suresh Krishna
Hi, I am a very occasional user of R, and will be grateful for some help in constructing a regression across groups. Here is an example: library(MASS) attach(cats) Sex[120:144]-factor(TG) #Renaming some males to transgender, to create 3 groups, male, female and transgender

[R] Help in Optimization of a function

2012-07-08 Thread Raghuraman Ramachandran
guRus! I have a function f = exp(x^2-y+(1/z)) Also, x can take values from 1 to 37, y from 2 to 20 and Z from -13 to 51. How can I find the maximum of f using any of the optimization functions please? Is there a way to store the possible values of x, y and Z in a single variable like in a List

Re: [R] Specify model with polynomial interaction terms up to degree n

2012-07-08 Thread Rui Barradas
Hello, Em 08-07-2012 03:00, Peter Ehlers escreveu: On 2012-07-07 14:56, YTP wrote: Hi Rui, Thanks for responding. I did not write raw=raw, and I'm not sure why R would return such a misleading error message. Indeed, the same error message comes up when I run the 2nd part of your code: m -

Re: [R] Help in Optimization of a function

2012-07-08 Thread Rui Barradas
Hello, You don't need an optimzation routine to know that the maximum of this function is +Inf. It's attained at z = 0+ (when z converges to zero by positive values). This breaks the R function optim(), by the way. It needs finite values of 'fn' Hope this helps, Rui Barradas Em

Re: [R] Help in Optimization of a function

2012-07-08 Thread Rui Barradas
Hello, There are several optimization functions in R. There's even a group dedicated to the field. See the CRAN Task View: Optimization and Mathematical Programming. To use optim(), you could do something like f - function(x, y, z) (x^2 - y - z^2/2) # I've changed the function negf -

[R] Concerning the reparametrization of the (ARDL)

2012-07-08 Thread Amatoallah Ouchen
Good day R list I want to transform an autoregressive distributed lag (ARDL) to a long-run equation (reparametrization of the (ARDL). How could i do that? This equation is displayed in this link https://docs.google.com/file/d/0B4dAkTAHpGBDSjA4RmlnbkxoLVU/edit Many thanks in advance

Re: [R] Grouped regression

2012-07-08 Thread David Winsemius
On Jul 8, 2012, at 4:11 AM, Suresh Krishna wrote: Hi, I am a very occasional user of R, and will be grateful for some help in constructing a regression across groups. Here is an example: library(MASS) attach(cats) Sex[120:144]-factor(TG) #Renaming some males to transgender, to create

[R] list.files() find files beginning with a .

2012-07-08 Thread syrvn
Hello, when I use list.files with recursive = TRUE and all.files = TRUE, R returns a list of strings/paths. From all those strings I want to keep only the ones starting with a . I tried using grep to achieve that. However, the problem is that because of the recursive list.files parameter, for

Re: [R] list.files() find files beginning with a .

2012-07-08 Thread Uwe Ligges
On 08.07.2012 14:47, syrvn wrote: Hello, when I use list.files with recursive = TRUE and all.files = TRUE, R returns a list of strings/paths. From all those strings I want to keep only the ones starting with a . I tried using grep to achieve that. However, the problem is that because of the

Re: [R] list.files() find files beginning with a .

2012-07-08 Thread Prof Brian Ripley
On 08/07/2012 14:35, Uwe Ligges wrote: On 08.07.2012 14:47, syrvn wrote: Hello, when I use list.files with recursive = TRUE and all.files = TRUE, R returns a list of strings/paths. From all those strings I want to keep only the ones starting with a . I tried using grep to achieve that.

Re: [R] Splitting a character vector.

2012-07-08 Thread John Kane
Works perfectly. Thank you very much indeed. John Kane Kingston ON Canada -Original Message- From: dwinsem...@comcast.net Sent: Sat, 7 Jul 2012 21:45:58 -0400 To: jrkrid...@inbox.com Subject: Re: [R] Splitting a character vector. On Jul 7, 2012, at 5:37 PM, John Kane wrote:

Re: [R] list.files() find files beginning with a .

2012-07-08 Thread Bert Gunter
It's all documented in ?regexp. . is a regex metacharacter. Metacharacters have to be escaped via \\. In particular, note: The fundamental building blocks are the regular expressions that match a single character. Most characters, including all letters and digits, are regular expressions that

Re: [R] Tables extraction in R ?

2012-07-08 Thread Greeknovice
I would like to thank all of you for spending your precious time in ordrer to help me out. I really appreciate the fact that experienced R users replied to my newbie post. Regards, Spiros Gkolfinopoulos -- View this message in context:

[R] Error during working with wgcna and R

2012-07-08 Thread deeksha.malhan
Hi I am working on co-expression analysis of rice dataset with the help of wgcna and R but now I am at one point which is showing error as shown below : dissTOM = 1-TOMsimilarityFromExpr(datExpr, power = 8); Error: cannot allocate vector of size 2.8 Gb In addition: Warning messages: 1: In

Re: [R] Grouped regression

2012-07-08 Thread SKrishna
Hi, Thanks for the reply. Sex[120:144]-factor(TG) #Renaming some males to transgender, to create 3 groups, male, female and transgender Sorry, that should have been Sex[120:144]-factor('TG') The original line did not have the quotes. I'm getting the sense that this is homework. You

[R] separation occuring in clustered data

2012-07-08 Thread Yue
hi all, Prior to this post I asked a question how to deal with binary clustered data when the crosstab by variables shows an empty cell. I figured out later that such an empty cell corresponds to what is called separation. Fortunately, R package logistf is developed to handle such a problem

[R] Upgrade to 2.14

2012-07-08 Thread hanansela
Hello I am an Ubuntu 11.04 and R version 2.12 user. I am using Rkward as a GUI for R . Some of the packages I need were build on 2.14. Therefore i need to upgrade to 2.14. Rkward needs version 2.14 or less. but the version name cant be with suffix like natty (as far as I understand). Is there

[R] Reading multiple line from a JSON formatted file

2012-07-08 Thread Shelby McIntyre
Below is R code that successfully reads the first line of a JSON file (attached). However, it is supposed to read 5 lines of the file, not just one. What is the wrong? library(rjson) json_file - /Users/smcintyremobile/Google Drive/AAShelby/CORRESP/Services

Re: [R] replacement has length zero

2012-07-08 Thread fabiano
Thanks Peter. We had a look at both Hab and habitat. These are integers representing habitat types. habitat - read.csv(Ungulate_vegetation.csv) habitat - habitat[,3] habitat [1] 3 3 4 3 3 3 4 4 3 3 3 3 3 4 2 3 2 3 2 3 Hab - cbind(seq(1,20),habitat) Hab habitat [1,] 1 3 [2,]

[R] problem with library()

2012-07-08 Thread R Heberto Ghezzo, Dr
Hello, I am running Win XP in a notebook IEEE, I have R-2-15.0 and R-2.15.1. In a subdirectory Cran I have the packages I downloaded from CRAN (all), after last update when I type library() Error in .readRDS(pfile) : unknown input format a very old R-2.4.0 sitting in a corner and not used for a

[R] Help in Optimization of a function

2012-07-08 Thread John C Nash
This looks like a homework trap set up to catch those trying to use facilities like Rhelp. f = exp(x^2-y+z^(-1))= exp(x^2) * exp(1/z)/exp(y) To maximize clearly needs biggest x (37), smallest y (2) and a z that makes exp(1/z) big -- 0. Except that you'll get Inf etc. Actually, several of the

Re: [R] Upgrade to 2.14

2012-07-08 Thread Uwe Ligges
On 08.07.2012 14:08, hanansela wrote: Hello I am an Ubuntu 11.04 and R version 2.12 user. I am using Rkward as a GUI for R . Some of the packages I need were build on 2.14. Therefore i need to upgrade to 2.14. Rkward needs version 2.14 or less. but the version name cant be with suffix like

Re: [R] Error during working with wgcna and R

2012-07-08 Thread Uwe Ligges
On 08.07.2012 13:02, deeksha.malhan wrote: Hi I am working on co-expression analysis of rice dataset with the help of wgcna and R but now I am at one point which is showing error as shown below : dissTOM = 1-TOMsimilarityFromExpr(datExpr, power = 8); Error: cannot allocate vector of size

Re: [R] problem with library()

2012-07-08 Thread Uwe Ligges
On 08.07.2012 16:51, R Heberto Ghezzo, Dr wrote: Hello, I am running Win XP in a notebook IEEE, I have R-2-15.0 and R-2.15.1. In a subdirectory Cran I have the packages I downloaded from CRAN (all), after last update when I type library() Error in .readRDS(pfile) : unknown input format

Re: [R] Grouped regression

2012-07-08 Thread David Winsemius
On Jul 8, 2012, at 7:55 AM, SKrishna wrote: Hi, Thanks for the reply. Sex[120:144]-factor(TG) #Renaming some males to transgender, to create 3 groups, male, female and transgender Sorry, that should have been Sex[120:144]-factor('TG') The original line did not have the quotes. I

Re: [R] Upgrade to 2.14

2012-07-08 Thread Jeff Newmiller
In general, you should try to keep your version of R current rather than lagging behind. If you would just search the Web yourself for keywords like install R Ubuntu 11.04 you would find many discussions of this topic. A key file to read is [1] [1]

[R] How to replace a column in a data frame with another one with a different size

2012-07-08 Thread Stathis Kamperis
Hello everyone, I have a dataframe with 1 column and I'd like to replace that column with a moving average. Example: library('zoo') mydat - seq_len(10) mydat [1] 1 2 3 4 5 6 7 8 9 10 df - data.frame(V1 = mydat) df V1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10

Re: [R] How to replace a column in a data frame with another one with a different size

2012-07-08 Thread Michael Weylandt
On Jul 8, 2012, at 9:31 AM, Stathis Kamperis ekamp...@gmail.com wrote: Hello everyone, I have a dataframe with 1 column and I'd like to replace that column with a moving average. Example: library('zoo') mydat - seq_len(10) mydat [1] 1 2 3 4 5 6 7 8 9 10 df - data.frame(V1

Re: [R] Help in Optimization of a function

2012-07-08 Thread peter dalgaard
On Jul 8, 2012, at 16:52 , John C Nash wrote: This looks like a homework trap set up to catch those trying to use facilities like Rhelp. f = exp(x^2-y+z^(-1))= exp(x^2) * exp(1/z)/exp(y) To maximize clearly needs biggest x (37), smallest y (2) and a z that makes exp(1/z) big -- 0.

Re: [R] replacement has length zero

2012-07-08 Thread Peter Ehlers
On 2012-07-08 06:57, fabiano wrote: Thanks Peter. We had a look at both Hab and habitat. These are integers representing habitat types. habitat - read.csv(Ungulate_vegetation.csv) habitat - habitat[,3] habitat [1] 3 3 4 3 3 3 4 4 3 3 3 3 3 4 2 3 2 3 2 3 Hab - cbind(seq(1,20),habitat) Hab

Re: [R] How to replace a column in a data frame with another one with a different size

2012-07-08 Thread R. Michael Weylandt
Your On Sun, Jul 8, 2012 at 12:22 PM, Stathis Kamperis ekamp...@gmail.com wrote: 2012/7/8 Michael Weylandt michael.weyla...@gmail.com: On Jul 8, 2012, at 9:31 AM, Stathis Kamperis ekamp...@gmail.com wrote: Hello everyone, I have a dataframe with 1 column and I'd like to replace that

[R] a fortune?

2012-07-08 Thread Spencer Graves
Hello, All: I think therefore I R, according to the header on several R-Tutorials by William B. King, PhD, Coastal Carolina University (http://ww2.coastal.edu/kingw/statistics/R-tutorials). Might this be appropriate for fortunes? Spencer -- Spencer Graves, PE, PhD

Re: [R] number of decimal places in a number?

2012-07-08 Thread Petr Savicky
On Sat, Jul 07, 2012 at 01:12:34PM +0100, Ted Harding wrote: I had thought of also (as well as my numerical routing) suggesting a gsub() type solution like Joshua's below, but held back because the result could depend on how the number arose (keyboard input, file input, or from computation

Re: [R] a fortune?

2012-07-08 Thread Achim Zeileis
On Sun, 8 Jul 2012, Spencer Graves wrote: Hello, All: I think therefore I R, according to the header on several R-Tutorials by William B. King, PhD, Coastal Carolina University (http://ww2.coastal.edu/kingw/statistics/R-tutorials). Might this be appropriate for fortunes?

[R] yet another windows installation from source issue

2012-07-08 Thread Erin Hodgess
Dear R People: I'm starting to think that I should just install from the binary, but here is my latest effort to install from source on a Windows 7 64 bit: c:\R64\R-patchedcd src cd src c:\R64\R-patched\srccd gnuwin32/ cd gnuwin32/ c:\R64\R-patched\src\gnuwin32set TMPDIR=c:\temp set

Re: [R] number of decimal places in a number?

2012-07-08 Thread Petr Savicky
On Sun, Jul 08, 2012 at 11:39:22AM -0700, arun wrote: Hi Petr, I think sprintf and formatC are identical as it can round 22 decimal places as opposed to print and signif print(pi,digits=35) Hi Arun: Thank you for pointing this out. Funtion formatC() is easier to use and uses the same C

Re: [R] number of decimal places in a number?

2012-07-08 Thread Petr Savicky
On Sat, Jul 07, 2012 at 11:52:35AM +0300, Martin Ivanov wrote: Dear R users, I need a function that gets a number and returns its number of actual decimal places. For example f(3.14) should return 2, f(3.142) should return 3, f(3.1400) should also return 2 and so on. Is such function

Re: [R] test parallel slopes with svyolr

2012-07-08 Thread Thomas Lumley
On Sun, Jul 8, 2012 at 2:32 AM, Diana Marcela Martinez Ruiz dianamm...@hotmail.com wrote: Hello, I would like to know how to test the assumption of proportional odds or parallel lines or slopes for an ordinal logistic regression with svyolr I wouldn't, but if someone finds a clear reference

Re: [R] a fortune?

2012-07-08 Thread Ted Harding
Should this not be attributed to DescaRtes? Ted. On 08-Jul-2012 18:41:17 Achim Zeileis wrote: On Sun, 8 Jul 2012, Spencer Graves wrote: Hello, All: I think therefore I R, according to the header on several R-Tutorials by William B. King, PhD, Coastal Carolina University

Re: [R] yet another windows installation from source issue

2012-07-08 Thread Duncan Murdoch
On 12-07-08 3:23 PM, Erin Hodgess wrote: Dear R People: I'm starting to think that I should just install from the binary, but here is my latest effort to install from source on a Windows 7 64 bit: It looks as though your path is messed up. You shouldn't have mingw32 tools on it. The

Re: [R] RedHat Linux intall R failed

2012-07-08 Thread John
The message concerning readline is common in compiling console mode programs. If you search on readline, you'll learn what it does. Since you are compiling source, the header files for the appropriate libraries need to available in the path. You need to install the readline and readline.h files

Re: [R] Poisson Ridge Regression

2012-07-08 Thread John
On Fri, 6 Jul 2012 21:13:32 +0530 umesh khatri khatriumes...@gmail.com wrote: Dear everyone I'm dealing with a problem related to Poisson Ridge Regression. If anyone can help me in this regard by telling if any changes in the source code of glm.fit may help You've posted this problem

Re: [R] How to replace a column in a data frame with another one with a different size

2012-07-08 Thread arun
Hi, As the error says, the replacements should have equal number of rows. You can either do it adding NAs, df$V1-c(NA,rollapply(df$V1,3,mean),NA) df    V1 1  NA 2   2 3   3 4   4 5   5 6   6 7   7 8   8 9   9 10 NA #or, #use any of these #as Michael suggested df2-rollapply(df,3,mean,fill=NA)

Re: [R] number of decimal places in a number?

2012-07-08 Thread arun
Hi Petr, I think sprintf and formatC are identical as it can round 22 decimal places as opposed to print and signif print(pi,digits=35) Error in print.default(pi, digits = 35) : invalid 'digits' argument  signif(pi,digits=22) [1] 3.141593 a-sprintf(%.35f,pi) a [1]

Re: [R] Declaring a density function with for loop

2012-07-08 Thread chamilka
Thank you very much Professor. David L Carlson .. This method saves my time!! -- View this message in context: http://r.789695.n4.nabble.com/Declaring-a-density-function-with-for-loop-tp4635699p4635795.html Sent from the R help mailing list archive at Nabble.com.

[R] Data Simulation

2012-07-08 Thread ycyi121
Hi, I have great difficulty in simulation the a dataset based in a loading matrix [c(1,1,1,2,3,3,3,4,4,3,2,2,1,1), 7, 2) and an error covariance matrix is 2*I. I have to simulate a dataset with 7 variables and 50 rows. I search a lot and did find some information on this, for example, using

[R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-08 Thread vimmster
Hello, I'm coming straight to the point: I have 65 .txt-Files named XYZ_1.txt to XYZ_65.txt (each number represents a test subject). I have to open them in Microsoft Excel to see the exact structure. In each of those .txt-files there are reaction time values (in milliseconds) from line 15,

Re: [R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-08 Thread jim holtman
Since you did not provide an example of the file, I will take a guess at the content and show to to extract the values and take the mean of all of them since you did not say if you want the mean of each file, or a single means. myData - do.call(c, lapply(1:65, function(.file){ x -

[R] axis.Date language

2012-07-08 Thread Mikkel Grum
Dear useRs I need to do graphs with dates in different languages on Ubuntu. In Windows the following will plot the date axis labels in Spanish: random.dates - as.Date(2001/1/1) + 70*sort(stats::runif(100)) language - Spanish Sys.setlocale(LC_TIME, language) plot(random.dates, 1:100, xaxt=n)

[R] classification using zero-inflated negative binomial mixture model

2012-07-08 Thread Kai Ying
Hi, I want using zero-inflated negative binomial regression model to classify data(a vector of data), that is I want know each observed value is more likely belong to the zero or count distribution(better with relative probability). My data is some like: count site samp 1290911

[R] c(a, b) for POSIXct objects with tzone attributes?

2012-07-08 Thread Spencer Graves
Hello: What is the recommended method for retaining the tzone attributes when concatonating POSIXct objects? (d1 - ISOdate(1970,1,1)) # Sets the tzone attribute = GMT [1] 1970-01-01 12:00:00 GMT (d1.2 - c(d1, d1)) # c(..) strips the tzone attribute, displays in the time zone of