[R] Converting dollar value (factors) to numeric

2010-05-05 Thread Wang, Kevin (SYD)
Hi, I'm trying to read in a bunch of CSV files into R where many columns are coded like $111.11. When reading them in they are treated as factors. I'm wondering if there is an easy way to convert them into numeric in R (as I don't want to modify the source data)? I've done some searches and can

Re: [R] Lazy evaluation in function call

2010-05-05 Thread Thorn
Bert Gunter gene.com> writes: > > Inline below. > > -- No. > f <- function(x, y = x)x+y ## lazy evaluation enables this > > f(2) > [1] 4 > > f(2,3) > [1] 5 Ok, obviously I was not very precise about what I'd like to do. Sorry. I'm aware of this functionality. But I'd like to use the same i

Re: [R] Converting dollar value (factors) to numeric

2010-05-05 Thread Ruihong Huang
If you use Linux, we can simply use "sed" (in Linux terminal, NOT R) to delete all leading '$' from the file "test.dat" by $ sed -e 's/\$//g' test.dat > newdata.dat And now R will read all this dollar as numeric. Bests, Ruihong On 05/05/2010 09:16 AM, Wang, Kevin (SYD) wrote: Hi, I'm tryin

Re: [R] Two Questions on R (call by reference and pre-compilation)

2010-05-05 Thread Ruihong Huang
Thank all of you! On 05/05/2010 12:08 AM, Steve Lianoglou wrote: Hi, On Tue, May 4, 2010 at 5:05 PM, Ruihong Huang wrote: Hi All, I have two questions on R. Could you please explain them to me? Thank you! 1) When call a function, R typically copys the values to formal arguments (call

Re: [R] installing a package in linux

2010-05-05 Thread Ruihong Huang
On 05/05/2010 02:44 AM, Tengfei Yin wrote: Hi R basic packages always works fine in my laptop (also ubuntu), you don't need to reinstall anything once you installed the package, did you do that in your terminal like $R (enter R session) install.packages('package name') q() then every

Re: [R] Converting dollar value (factors) to numeric

2010-05-05 Thread Fredrik Karlsson
Hi, Something similar to this maybe? > test <- as.factor("$111.11") > test [1] $111.11 Levels: $111.11 > as.numeric(substring(as.character(test),2)) [1] 111.11 To be applied to your data.frame columns. /Fredrik On Wed, May 5, 2010 at 9:16 AM, Wang, Kevin (SYD) wrote: > Hi, > > I'm trying to r

[R] A question regarding the loess function

2010-05-05 Thread Scott MacDonald
Hello, I was hoping that someone familiar with the implementation details of the loess algorithm might be able to help me resolve some difficulties I am having. I am attempting to reproduce some of the functionality of the loess() function in C++. My primary motivation is that I would like to un

Re: [R] Converting dollar value (factors) to numeric

2010-05-05 Thread Phil Spector
Kev- The most reliable way to do the conversion is as follows: x = factor(c('$112.11','$119.15','$121.32')) as.numeric(sub('\\$','',as.character(x))) [1] 112.11 119.15 121.32 This way negative quantities and numbers without dollar signs are handled correctly. There's certainly no need to

[R] help with restart

2010-05-05 Thread Wincent
Dear all, I want to download webpage from a large number of webpage. For example, link <- c("http://gzbbs.soufun.com/board/2811006802/";, "http://gzbbs.soufun.com/board/2811328226/";, "http://gzbbs.soufun.com/board/2811720258/";, "http://gzbbs.soufun.com/board/2811495702/";, "http://gzbbs

Re: [R] Two Questions on R (call by reference and pre-compilation)

2010-05-05 Thread Seth
As far as large data sets, I've just discovered readLines and writeLines functions. I'm using it now to read in single rows, calculate things on them, and then write a single row to a file. -- View this message in context: http://r.789695.n4.nabble.com/Two-Questions-on-R-call-by-reference-and-p

Re: [R] converting an objects list

2010-05-05 Thread Jim Lemon
On 05/05/2010 08:45 AM, Anthony Fristachi wrote: Hello, I would like to convert an objects list such as objects() or ls() that outputs"a101""a102" "a104""a107""a109" to read within a list statement as follows : list(a101,a102,a104,a107,a109) Hi Tony, Try this: x<-1:3

Re: [R] fit printed output onto a single page

2010-05-05 Thread Jim Lemon
On 05/05/2010 12:12 AM, Abiel X Reinhart wrote: Is there a way to force a certain block of captured output to fit onto a single printed page, where one can specify the properties of the page (dimensions, margins, etc)? For example, I might want to generate 10 different cuts of a data table and

[R] concatenate values of two columns

2010-05-05 Thread n.via...@libero.it
Dear list, I'm trying to concatenate the values of two columns but im not able to do it: i have a dataframe with the following two columns: X VAR1 VAR2 1 2 2 1 3 2 4

[R] Memory issue

2010-05-05 Thread Alex van der Spek
Reading a flat text file 138 Mbyte large into R with a combination of scan (to get the header) and read.table. After conversion of text time stamps to POSIXct and conversion of integer codes to factors I convert everything into one data frame and release the old structures containing the data b

[R] puzzles with assign()

2010-05-05 Thread David.Epstein
I'm trying to get code along the following lines to work: temp.name <- paste(TimePt,'df',sep='.') # invent a relevant name/symbol as a character string. assign(temp.name,IGF.df[IGF.df$TPt==TimePt,]) # this works. The relevant variable is now a data frame lm(b ~ Strain+BWt+PWt+PanPix, data=temp.nam

[R] Odp: concatenate values of two columns

2010-05-05 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 05.05.2010 11:46:33: > > Dear list, > I'm trying to concatenate the values of two columns but im not able to do it: > > i have a dataframe with the following two columns: > > X VAR1 VAR2 > 1 2 > 2

[R] Predict when regressors are passed through a data matrix

2010-05-05 Thread Paolo Agnolucci
Hi everyone, this should be pretty basic but I need asking for help as I got stuck. I am running simple linear regression models on R with k regressors where k > 1. In order to automate my code I packed all the regressors in a matrix X so that lm(y~X) will always produce the results I want regard

[R] rcorr p-values for pearson's correlation coefficients

2010-05-05 Thread Amit
Hi! All, To find co-expressed genes from a expression matrix of dimension (9275 X 569), I used rcorr function from library(Hmisc) to calculate pearson correlation coefficient (PCC) and their corresponding p-values. From the correlation matrix (9275 X 9275) and pvalue matrix (9275 X 9275) obtained

Re: [R] Odp: better way to trick data frame structure?

2010-05-05 Thread Jim Lemon
On 05/05/2010 04:02 PM, Petr PIKAL wrote: ... Not at all lying. That is why hated factors are useful. Lust add all desired levels. Hey, isn't this a family mailing list? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/

[R] OLS Regression diagnostic measures check list - what to consider?

2010-05-05 Thread Tal Galili
Hello dear R help list, I wish to compile a check-list for diagnostic measures for OLS regression. My question: Can you offer more (or newer) tests/measures for the validity of a linear model then what is given here: http://www.statmethods.net/stats/rdiagnostics.html This resource gives a list o

Re: [R] Lazy evaluation in function call

2010-05-05 Thread Duncan Murdoch
Thorn wrote: Bert Gunter gene.com> writes: Inline below. -- No. f <- function(x, y = x)x+y ## lazy evaluation enables this f(2) [1] 4 f(2,3) [1] 5 Ok, obviously I was not very precise about what I'd like to do. Sorry. I'm aware of this f

Re: [R] readLines with space-delimiter?

2010-05-05 Thread Duncan Murdoch
Seth wrote: Thanks. I wasn't aware that scan or read.table allowed you to read in a single line, process it, output results, and then read in the next line. This is what I need to do because the data set is too large to hold in RAM. I did manage to do this with readLines and overcome the space

Re: [R] Visualizing binary response data?

2010-05-05 Thread Antony Unwin
You could also try using interactive graphics in iplots. Linking from a barchart of your binary response variable to your eight continuous predictors in a parallel coordinate plot and to your four categorical predictors in some form of mosaicplot could be very informative. Graphics are not nec

Re: [R] puzzles with assign()

2010-05-05 Thread Duncan Murdoch
David.Epstein wrote: I'm trying to get code along the following lines to work: temp.name <- paste(TimePt,'df',sep='.') # invent a relevant name/symbol as a character string. assign(temp.name,IGF.df[IGF.df$TPt==TimePt,]) # this works. The relevant variable is now a data frame lm(b ~ Strain+BWt+PWt

Re: [R] Memory issue

2010-05-05 Thread Prof Brian Ripley
On Wed, 5 May 2010, Alex van der Spek wrote: Reading a flat text file 138 Mbyte large into R with a combination of scan (to get the header) and read.table. After conversion of text time stamps to POSIXct and conversion of integer codes to factors I convert everything into one data frame and re

Re: [R] question about 'write.table'

2010-05-05 Thread jim holtman
for (i in 1:100){ write.table(get(paste('loci', i, sep='')), file=paste('loci', i, sep='')) } On Tue, May 4, 2010 at 5:02 PM, karena wrote: > > I have a question about the "write.table" > > I have 100 data.frames, loci1, loci2, loci3.,loci100. > now, I want to print these data.fra

Re: [R] question about 'write.table'

2010-05-05 Thread Muhammad Rahiz
This could work out <- c() for (a in 1:10){ out[a] <- paste("loci",a,sep="") write.table(out[a],file=out[a],row.names=FALSE,col.names=FALSE)} Muhammad karena wrote: I have a question about the "write.table" I have 100 data.frames, loci1, loci2, loci3.,loci100. now, I want

Re: [R] Re : Re : aregImpute (Hmisc package) : error in matxv(X, xcof)...

2010-05-05 Thread Frank E Harrell Jr
Marc, In this particular case the code alone would have been sufficient. To isolate the problem try the following: require(Hmisc) v <- varclus(~ variable1 + variable2 + ... all other variables given to aregImpute, data=...) plot(v) redun(~variable1 + variable2 + ... all others, data=...) Fr

[R] Latex and Stangle()

2010-05-05 Thread Silvano
Hi, I'm using the Sweave and I would like include codes of the R in my LaTeX file. I extracts the R code with Stangle (), whose name is Relatorio.R but I can't include it in the Latex file as an appendix. Suggests? Thanks, -- Silvano Cesar da Costa Depa

Re: [R] Latex and Stangle()

2010-05-05 Thread Frank E Harrell Jr
On 05/05/2010 07:21 AM, Silvano wrote: Hi, I'm using the Sweave and I would like include codes of the R in my LaTeX file. I extracts the R code with Stangle (), whose name is Relatorio.R but I can't include it in the Latex file as an appendix. Suggests? Thanks, Silvano, If you don't want t

Re: [R] puzzles with assign()

2010-05-05 Thread David.Epstein
Duncan Murdoch-2 wrote: > > .. > That's because constructing names like this is generally a bad idea. > But you can do it; you use get() to get the object whose name is in > temp.name. So put data=get(temp.name) into your lm() call. > I had another useful answer (sent privately) from

Re: [R] Memory issue

2010-05-05 Thread Alex van der Spek
Thank you all, No offense meant. I like R tremendously but I admit I am only a beginner. I did not know about gc(), but it explains my confusion about rm() not doing what I expected it to do. I suspected that .RData was a compressed file. Thanks for the confirmation. As for Windows, unfortun

[R] convert 32bit numbers to 64bit (or float to double)

2010-05-05 Thread Sebastian Gibb
Hello, a long time ago I had to use a foreign C++ application to generate some numbers. This application saves the numbers as 32bit (float) values in a file. I had to use an open source application to read the files. It imports the values as 64bit (double) and generates some pseudo numbers at po

Re: [R] Creating Crosstabs using a sparse table

2010-05-05 Thread David Winsemius
On May 4, 2010, at 7:57 PM, merrittr wrote: Hi all I am trying to read in a table from a survey and get the error below gr12 <- read.table("gr12.csv", header=TRUE) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 249 elements You need to

Re: [R] Predict when regressors are passed through a data matrix

2010-05-05 Thread Dennis Murphy
Hi: The problem arises because the variable names of the explanatory variables in the newdata = data frame used in predict() have to match those in the fitted model object. Interestingly, using a matrix for the right hand side of the model formula in lm() creates problems for predict(). Using you

Re: [R] installing a package in linux

2010-05-05 Thread Tengfei Yin
Hi The weird part in this case is that, if you didn't run sudo R, and install the package, it will create a library in your home directory, you should also be able to use the package next time. Regards Tengfei On Wed, May 5, 2010 at 1:53 AM, Ruihong Huang < ruihong.busin...@googlemail.com> wrot

Re: [R] Predict when regressors are passed through a data matrix

2010-05-05 Thread Paolo Agnolucci
Hi Dennis, very thorough reply - I am amazed. I had realised that the problem was related to colnames in the data.frame and had understood that putting both regressand and regressors in the same data.frame was part of the solution. I had figured it out that I could have solved that by adjusting

Re: [R] Latex and Stangle()

2010-05-05 Thread Ruihong Huang
Hi, I suggest you use the listings package ... \usepackage{listings} \appendix \lstinputlisting[language=R]{Relatorio.R} Best, Ruihong On 05/05/2010 02:21 PM, Silvano wrote: Hi, I'm using the Sweave and I would like include codes of the R in my LaTeX file. I extracts the R c

[R] t.test per line

2010-05-05 Thread Mohamed Lajnef
Dear All, I apologize for this trivial question, I can not find the solution I try to use t.test function per line in the data.frame, But i dont'understand the error message my program is as follows group1<-gl(2,20) fun<-function(x){ m<-data.frame(group1,x) #anova(aov(x ~ group1, m)) t.est

[R] Memory warning (Reached total allocation of ...) - but no error

2010-05-05 Thread Magnus Torfason
Hi all, I'm getting the following warnings inside a loop: Warning messages: 1: In calc.measures(g, 1, i) : Reached total allocation of 1535Mb: see help(memory.size) 2: In calc.measures(g, 1, i) : Reached total allocation of 1535Mb: see help(memory.size) Usually, when I see these warnings, t

Re: [R] t.test per line

2010-05-05 Thread Erik Iverson
Mohamed Lajnef wrote: Dear All, I apologize for this trivial question, I can not find the solution I try to use t.test function per line in the data.frame, But i dont'understand the error message my program is as follows group1<-gl(2,20) fun<-function(x){ m<-data.frame(group1,x) #anova(

Re: [R] t.test per line

2010-05-05 Thread David Winsemius
On May 5, 2010, at 12:15 PM, Mohamed Lajnef wrote: Dear All, I apologize for this trivial question, I can not find the solution I try to use t.test function per line in the data.frame, But i dont'understand the error message my program is as follows group1<-gl(2,20) fun<-function(x){ m

[R] sort the data set by one variable

2010-05-05 Thread Changbin Du
> #sort the data by predicted probability > b.order<-bo.id.pred[(order(-predict)),] > b.order[1:20,] gene_idpredict 43 637882902 0.07823997 53 638101634 0.66256490 61 639084581 0.08587504 41 637832824 0.02461066 25 637261662 0.11613879 22 637240022 0.06350477 62 639084582 0.02238538 63 639

Re: [R] sort the data set by one variable

2010-05-05 Thread David Winsemius
On May 5, 2010, at 12:31 PM, Changbin Du wrote: #sort the data by predicted probability b.order<-bo.id.pred[(order(-predict)),] b.order[1:20,] gene_idpredict 43 637882902 0.07823997 53 638101634 0.66256490 61 639084581 0.08587504 41 637832824 0.02461066 25 637261662 0.11613879 22 63724

Re: [R] sort the data set by one variable

2010-05-05 Thread jim holtman
Works fine for me: > x gene_idpredict 43 637882902 0.07823997 53 638101634 0.66256490 61 639084581 0.08587504 41 637832824 0.02461066 25 637261662 0.11613879 22 637240022 0.06350477 62 639084582 0.02238538 63 639097718 0.06792841 44 637943079 0.04532625 80 640158389 0.06582658 3 63700651

Re: [R] sort the data set by one variable

2010-05-05 Thread Changbin Du
Thanks Jim! I forgot the data$predict. Now it works for me too. Thanks so much! On Wed, May 5, 2010 at 9:36 AM, jim holtman wrote: > Works fine for me: > > > x > gene_idpredict > 43 637882902 0.07823997 > 53 638101634 0.66256490 > 61 639084581 0.08587504 > 41 637832824 0.02461066 > 25

Re: [R] sort the data set by one variable

2010-05-05 Thread Changbin Du
Yes, Phil! You are right, I forgot put the bo.id.pred$ ahead of predict. Thanks! On Wed, May 5, 2010 at 9:48 AM, Phil Spector wrote: > Changbin - > Perhaps you meant > > b.order = bo.id.pred[order(bo.id.pred$predict,decreasing=TRUE),] > >- Phil Spector

[R] Statistical questions - good mailing lists

2010-05-05 Thread Ralf B
What mailing lists do you guys use for general statistical questions (e.g. what statistical test to pick). I am looking for a list that has enough manpower to get problems solved and discussions going. Any suggestions? Ralf __ R-help@r-project.org maili

[R] handling nulls while reading mainframe file

2010-05-05 Thread Michael Steven Rooney
Hi, I am trying to read in records from an old main frame file. Each record is 640 bytes. I had some success using the following statement: iconv(readChar(con, nchars=640, useBytes = TRUE),from="IBM037",to="",sub="#") What I have found, however, is that ocassionally a record will contain a Null

[R] [R-pkgs] Hmisc version 3.8-0 now available on CRAN

2010-05-05 Thread Charles Dupont
Hmisc version 3.8-0 has been released and is now available on CRAN. Primary improvement is compatibility with R 2.11.0. Linux packages, Windows 32bit and 64bit binary packages, and Mac binary packages are built and are currently available on the http://cran.r-project.org/ repository. Charles

[R] custom metric for dist for use with hclust/kmeans

2010-05-05 Thread Vivek Ayer
Hi guys, I've been using the kmeans and hclust functions for some time now and was wondering if I could specify a custom metric when passing my data frame into hclust as a distance matrix. Actually, kmeans doesn't even take a distance matrix; it takes the data frame directly. I was wondering if th

[R] Using statistical test to distinguish two groups

2010-05-05 Thread Ralf B
Hi R friends, I am posting this question even though I know that the nature of it is closer to general stats than R. Please let me know if you are aware of a list for general statistical questions: I am looking for a simple method to distinguish two groups of data in a long vector of numbers: li

Re: [R] Using statistical test to distinguish two groups

2010-05-05 Thread Erik Iverson
One of many possible approaches is called k-means clustering. my.data <- c(1,2,3,2,3,2,3,4,3,2,3,4,3,2,400,340,3,2,4,5,6,4,3,6,4,5,3) split(my.data, kmeans(my.data, 2)$cluster) $`1` [1] 400 340 $`2` [1] 1 2 3 2 3 2 3 4 3 2 3 4 3 2 3 2 4 5 6 4 3 6 4 5 3 Ralf B wrote: Hi R friends, I am posti

Re: [R] Using statistical test to distinguish two groups

2010-05-05 Thread Achim Zeileis
On Wed, 5 May 2010, Ralf B wrote: Hi R friends, I am posting this question even though I know that the nature of it is closer to general stats than R. Please let me know if you are aware of a list for general statistical questions: I am looking for a simple method to distinguish two groups of

Re: [R] OLS Regression diagnostic measures check list - what to consider?

2010-05-05 Thread Greg Snow
First a note, while that is a nice list, I think it needs a disclaimer about only running tests that answer a meaningful question for the data/problem being studied. If all those tests are run on datasets, I would be most suspicious of those datasets which passed all the tests. Also, failing s

[R] 'matplot' for matrix with NAs: broken lines

2010-05-05 Thread Tao Shi
Hi list, I know that points involving NAs are not plotted in 'matplot', but when I plot them as lines, I still want the lines to connect all the points (i.e. not broken where there are NAs).  Please see the example below.  How can I achieve this in 'matplot'?  If I can't, any good alternatives

[R] Unexpected call to "require"

2010-05-05 Thread Dennis Fisher
Colleagues I am executing a length script in R (20K lines). At one point, it returns: > Loading required package: tcltk > Loading Tcl/Tk interface ... done > Loading required package: Hmisc > Loading required package: survival > Loading required package: stats > Loading required package: graphics

Re: [R] concatenate values of two columns

2010-05-05 Thread Marshall Feldman
On 5/5/2010 6:00 AM, n.via...@libero.it wrote: Dear list, I'm trying to concatenate the values of two columns but im not able to do it: i have a dataframe with the following two columns: X VAR1 VAR2 1 2 2 1 3

Re: [R] Unexpected call to "require"

2010-05-05 Thread Gabor Grothendieck
Its coming from the Hmisc startup. For example, in a clean session (R --vanilla) try this: library(survival) library(Hmisc) Replacing the above call with this will suppress it: suppressPackageStartupMessages(library(Hmisc)) To track it down: debug(message) and then run your scrip

[R] Re : Re: Re: aregImpute (Hmisc package) : error in matxv(X, xcof)...

2010-05-05 Thread Marc Carpentier
Very useful code to investigate not only my problem ! I'll use it and keep it in mind for future works. Thank you very much for your help. And of course for the rest : packages, open-courses... among others ! Very helpful too. (Sorry for the wide dataset. I thought it would be attached and maybe

[R] Confidence interval around a mean count (poisson based?)

2010-05-05 Thread JiHO
Hello all, I am observing animals in a behavioural arena and recording their distance from a specific point at regular time intervals (large enough so that I can assume two successive positions are independent from each other). Each animal provides a complete histogram of distances which reflects

Re: [R] read.table or read.csv without row index?

2010-05-05 Thread vincent.deluard
Hi, I have the same problem as Wong. I have a csv file that contains weather observation (rows) by days (in columns). I open using: > temp = read.csv("Weather.csv", sep=",") and read: X X1.Jan X2.Jan X3.Jan X4.Jan 1 Min 2 3 4 1 2 Max 6

[R] Read data from .csv file as a matrix

2010-05-05 Thread vincent.deluard
Hi R-users, I have a csv file that contains weather observation (rows) by days (in columns). I open using: > temp = read.csv("Weather.csv", sep=",") and read: X X1.Jan X2.Jan X3.Jan X4.Jan 1 Min 2 3 4 1 2 Max 6 10 8

Re: [R] Read data from .csv file as a matrix

2010-05-05 Thread Erik Iverson
Hello, I have a csv file that contains weather observation (rows) by days (in columns). I open using: temp = read.csv("Weather.csv", sep=",") and read: X X1.Jan X2.Jan X3.Jan X4.Jan 1 Min 2 3 4 1 2 Max 6 10 8 6 3 F

Re: [R] 'matplot' for matrix with NAs: broken lines

2010-05-05 Thread Gabor Grothendieck
Try this: library(zoo) matplot(na.approx(b), type = "l") On Wed, May 5, 2010 at 2:30 PM, Tao Shi wrote: > > Hi list, > > I know that points involving NAs are not plotted in 'matplot', but when I > plot them as lines, I still want the lines to connect all the points (i.e. > not broken where the

Re: [R] read.table or read.csv without row index?

2010-05-05 Thread JiHO
> I tried as.matrix but it did not help. as.matrix() won't work because a matrix requires everything in it to be of the same type (number, character, logical etc.). You do not have only numbers in your data.frame, so it will convert everything to character strings. If you try as.matrix(temp[,-1])

Re: [R] help overlay scatterplot to effects plot

2010-05-05 Thread Greg Snow
We cannot reproduce your example, don't have the data (or don't know where it is if we do) and where did the allEffects function come from? If this just makes a regular plot using base graphics and not messing with the user coordinates, then you can just use the points function to add additional

Re: [R] Read data from .csv file as a matrix

2010-05-05 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of vincent.deluard > Sent: Wednesday, May 05, 2010 12:34 PM > To: r-help@r-project.org > Subject: [R] Read data from .csv file as a matrix > > > Hi R-users, > > > I have a csv fi

Re: [R] OLS Regression diagnostic measures check list - what to consider?

2010-05-05 Thread Liviu Andronic
On 5/5/10, Tal Galili wrote: > Although this is a great list, I am wondering if there is any newer methods > that are overlooked, or important consideration to take into account that > are not described in that page. > Two on-line resources would be "REGRESSION DIAGNOSTICS" by John Fox [1] and

Re: [R] read.table or read.csv without row index?

2010-05-05 Thread David Winsemius
On May 5, 2010, at 3:49 PM, JiHO wrote: I tried as.matrix but it did not help. as.matrix() won't work because a matrix requires everything in it to be of the same type (number, character, logical etc.). You do not have only numbers in your data.frame, so it will convert everything to characte

Re: [R] Avoiding for-loop for splitting vector into subvectorsbased on positions

2010-05-05 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Joris Meys > Sent: Tuesday, May 04, 2010 2:02 PM > To: jim holtman > Cc: R mailing list > Subject: Re: [R] Avoiding for-loop for splitting vector into > subvectorsbased on positi

Re: [R] ggplot2's geom_errorbar legend

2010-05-05 Thread hadley wickham
Hi Giovanni, The basic idea is: classiclimits <- aes(x=x[1:100],ymax = classiccis[1:100,e,p, ymin=classiccis[1:100,e,p,2], colour = "classic") ownlimits <- aes(x=x[1:100]+0.4,ymax = owncis[1:100,e,p,1], ymin=owncis[1:100,e,p,2], colour = "own") rbootlimits <- aes(x=x[1:100]+0.8,ymax = rbootcis

Re: [R] read.table or read.csv without row index?

2010-05-05 Thread vincent.deluard
YES IT WORKED!!! Many thanks JiHO Vincent Deluard vincent.delu...@trimtabs.com Global Equity Strategist, CFA Charter Award Pending TrimTabs Investment Research 40 Wall Street, 28th Floor New York, NY 100

Re: [R] Jonckheere-Terpstra test using coin package?

2010-05-05 Thread Dale Steele
Using coin ... answer provided by Prof. Hothorn. control <- c(40, 35, 38, 43, 44, 41) rough <- c(38, 40, 47, 44, 40, 42) accurate <- c(48, 40, 45, 43, 46, 44) pieces <- list(control, rough, accurate) n <- c(6, 6, 6) grp <- as.ordered(factor(rep(1:length(n),n))) library("coin") library("multcomp"

Re: [R] Using statistical test to distinguish two groups

2010-05-05 Thread Ralf B
Thank you for both your help saving me a a lot of time searching for the right technique. I have another question regarding clustering: My data set occasionally has only one cluster, meaning that clustering is not required in these occasional cases. Example: list <- c(767, 773, 766, 772, 778, 77

Re: [R] Read data from .csv file as a matrix

2010-05-05 Thread Tao Shi
Vincent, The root of this problem seems to be that you don't fully understand the differences between matrix and data.frame.  Read up on them and you'll know how to solve this problem. For now: as.matrix(temp[,-1]) or temp = read.csv("Weather.csv", sep=",", row.names=1) temp1 <- as.matrix(t

[R] Has Anyone created any good R wallpapers ?

2010-05-05 Thread Paul
I was googling around today to see if anyone had created any R wallpapers, given some of the amazing graphics that can be created with R I'd like to display the capabilities for others. I didn't come up with much. Anyone else come up with anything. Paul.

[R] ordering data frame

2010-05-05 Thread phoebe kong
Hi all, I have problem in ordering data frame. Could anyone help me? > x [,1] [,2] [,3] [1,] "A" "1" "2" [2,] "G" "3" "2" [3,] "E" "2" "3" > y [,1] [,2] [,3] [1,] "G" "3" "3" [2,] "A" "3" "3" [3,] "E" "3" "3" I would like to order data frame x by the order of column 1 of d

[R] extracting a matched string using regexpr

2010-05-05 Thread steven mosher
Given a text like I want to be able to extract a matched regular expression from a piece of text. this apparently works, but is pretty ugly # some html test<-"88958Abcdsef67.8S68.9\nW26m" # a pattern to extract 5 digits > pattern<-"[0-9]{5}" # regexpr returns a start point[1] and an attribute "ma

[R] Dynamic clustering?

2010-05-05 Thread Ralf B
Are there R packages that allow for dynamic clustering, i.e. where the number of clusters are not predefined? I have a list of numbers that falls in either 2 or just 1 cluster. Here an example of one that should be clustered into two clusters: two <- c(1,2,3,2,3,1,2,3,400,300,400) and here one th

Re: [R] ordering data frame

2010-05-05 Thread Erik Iverson
phoebe kong wrote: Hi all, I have problem in ordering data frame. Could anyone help me? x [,1] [,2] [,3] [1,] "A" "1" "2" [2,] "G" "3" "2" [3,] "E" "2" "3" y [,1] [,2] [,3] [1,] "G" "3" "3" [2,] "A" "3" "3" [3,] "E" "3" "3" Are these really data.frames? They looks

[R] Limitations on R code file

2010-05-05 Thread guox
I would like to run R code from a file that is generated from other source. The file consists of some variables and formulas/equations such as Variables = log(100) ##Other variable definitions VariablesWithLongNames = 2*3*log(12345678)+10^4 + Variables Equations=log(VariablesWithLongNames)+Variabl

Re: [R] Latex and Stangle()

2010-05-05 Thread Ruihong Huang
Hi Silvano, I think you can enable automatic line breaking of long lines by \lstinputlisting[language=R, breaklines=true]{Relatorio.R} Best, Ruihong On 05/05/2010 11:12 PM, Silvano wrote: Ruihong it very interesting, but the lines was very long. Thanks, --

Re: [R] FUN argument to return a vector in aggregate function

2010-05-05 Thread utkarshsinghal
Extending my question further, I want to apply different FUN arguments on three fields and the "by" argument also contains more than one field. For example: set.seed(100) d = data.frame(a=sample(letters[1:2],20,replace=T),b=sample(3,20,replace=T),c=rpois(20,1),d=rbinom(20,1,0.5),e=rep(c("X","Y")

Re: [R] Avoiding for-loop for splitting vector into subvectorsbasedon positions

2010-05-05 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap > Sent: Wednesday, May 05, 2010 12:59 PM > To: Joris Meys; jim holtman > Cc: R mailing list > Subject: Re: [R] Avoiding for-loop for splitting vector into > subvec

Re: [R] Dynamic clustering?

2010-05-05 Thread Erik Iverson
Hello, Ralf B wrote: Are there R packages that allow for dynamic clustering, i.e. where the number of clusters are not predefined? I have a list of numbers that falls in either 2 or just 1 cluster. Here an example of one that should be clustered into two clusters: two <- c(1,2,3,2,3,1,2,3,400,3

Re: [R] extracting a matched string using regexpr

2010-05-05 Thread Gabor Grothendieck
Here are two ways to extract 5 digits. In the first one \\1 refers to the portion matched between the parentheses in the regular expression. In the second one strapply is like apply where the object to be worked on is the first argument (array for apply, string for strapply) the second modifies i

Re: [R] extracting a matched string using regexpr

2010-05-05 Thread steven mosher
Thanks I was looking at that package and reading your mails in the archive. I think my tiny mind got twisted in the regexp.. On Wed, May 5, 2010 at 2:35 PM, Gabor Grothendieck wrote: > Here are two ways to extract 5 digits. > > In the first one \\1 refers to the portion matched between the > pare

Re: [R] Has Anyone created any good R wallpapers ?

2010-05-05 Thread Erik Iverson
Paul wrote: I was googling around today to see if anyone had created any R wallpapers, given some of the amazing graphics that can be created with R I'd like to display the capabilities for others. I didn't come up with much. Don't know what you mean by 'wallpaper'. This site has a bunch

Re: [R] FUN argument to return a vector in aggregate function

2010-05-05 Thread Gabor Grothendieck
Try this: do.call("rbind", by(d, d[1:2], function(x) with(x, data.frame(x[1, 1:2], `mean c` = mean(c), `sum d` = sum(d), `has X` = "X" %in% e, check.names = FALSE or this (which uses 1 or 0 to mean TRUE or FALSE in the last column): > library(sqldf) # see http://sqldf.googlecode.com > sqldf

Re: [R] Dynamic clustering?

2010-05-05 Thread Achim Zeileis
On Wed, 5 May 2010, Ralf B wrote: Are there R packages that allow for dynamic clustering, i.e. where the number of clusters are not predefined? Yes. I have a list of numbers that falls in either 2 or just 1 cluster. Here an example of one that should be clustered into two clusters: two <- c

Re: [R] installing a package in linux

2010-05-05 Thread Vojtěch Zeisek
There are a lot of R packages available in Ubuntu's repositories. Just search for R-* or r-cran-* within Your favorite package manager. It it the easiest way. :-) Best regards, Vojtěch Zeisek Dne St 5. května 2010 17:03:22 Tengfei Yin napsal(a): > Hi > > The weird part in this case is that, if

Re: [R] Dynamic clustering?

2010-05-05 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Erik Iverson > Sent: Wednesday, May 05, 2010 2:33 PM > To: Ralf B > Cc: r-help@r-project.org > Subject: Re: [R] Dynamic clustering? > > Hello, > > Ralf B wrote: > > Are there R

Re: [R] extracting a matched string using regexpr

2010-05-05 Thread steven mosher
test [1] "88958Abcdsef67.8S68.9\nW26m" > sub(".*(\\d{5}).*", "\\1", test) [1] "" > sub(".*([0-9]{5}).*","\\1",test) [1] "88958" > I think the "wrote: > Here are two ways to extract 5 digits. > > In the first one \\1 refers to the portion matched between the > parentheses in the regular expressi

Re: [R] FUN argument to return a vector in aggregate function

2010-05-05 Thread David Winsemius
On May 5, 2010, at 5:32 PM, utkarshsinghal wrote: Extending my question further, I want to apply different FUN arguments on three fields and the "by" argument also contains more than one field. For example: set.seed(100) d = data.frame(a=sample(letters[1:2], 20 ,replace = T ),b = sam

Re: [R] extracting a matched string using regexpr

2010-05-05 Thread Gabor Grothendieck
That's not what I get: > test<-"88958Abcdsef67.8S68.9\nW26m" > sub(".*(\\d{5}).*", "\\1", test) [1] "88958" > R.version.string [1] "R version 2.10.1 (2009-12-14)" I also got the above in R 2.11.0 patched as well. On Wed, May 5, 2010 at 5:55 PM, steven mosher wrote: >  test > [1] > "88958Abcdse

[R] melt, remove rows with common id if NA encountered in value

2010-05-05 Thread emorway
forum, After melting a data.frame I get some 18,000+ rows (some rows below). I want to filter/remove all rows that have an "SP" & "variable" value in common with a row containing "NA" in the value column. So in the example rows below, all rows with SP=425 & variable=CoolidgeLoad would be remove

Re: [R] Limitations on R code file

2010-05-05 Thread Steve Lianoglou
Hi James, On Wed, May 5, 2010 at 5:28 PM, wrote: > I would like to run R code from a file that is generated from other source. > The file consists of some variables and formulas/equations such as > > Variables = log(100) > ##Other variable definitions > VariablesWithLongNames = 2*3*log(12345678)

Re: [R] extracting a matched string using regexpr

2010-05-05 Thread David Winsemius
On May 5, 2010, at 5:35 PM, Gabor Grothendieck wrote: Here are two ways to extract 5 digits. In the first one \\1 refers to the portion matched between the parentheses in the regular expression. In the second one strapply is like apply where the object to be worked on is the first argument (a

Re: [R] extracting a matched string using regexpr

2010-05-05 Thread steven mosher
Hmm. I have R11 just downloaded fresh. I'll reload a new session..and revert. I will note that I've had trouble with \\d which is why I was using [0-9] MAC here. On Wed, May 5, 2010 at 3:00 PM, Gabor Grothendieck wrote: > That's not what I get: > > > > test<-"88958Abcdsef67.8S68.9\nW26m" > > s

  1   2   >