[R] Is there any performance difference between subset() and list comprehension?

2009-09-26 Thread You Hyun Jo
Hello, Suppose that you have a data frame 'df' with variables 'V1', 'V2', 'V3', etc. Is there any (performance) difference (except the difference of the return types) between the following two computations? subset(df, V1 0, V2) and df$V2[df$V1 0] Best Regards, hyunjo

Re: [R] grep or other complex string matching approach to capture necessary information...

2009-09-26 Thread David Winsemius
On Sep 26, 2009, at 11:40 AM, John Kane wrote: ?subset problems - c( Water damage, Water off, water pipes damaged, leaking water) damaged - subset(house_info, house_info[,1]==problems[1] | house_info[,1]==problems[2] | house_info[,1]==problems[3]

Re: [R] Nested select

2009-09-26 Thread premmad
Thanks.It works -- View this message in context: http://www.nabble.com/Nested-select-tp25608506p25622242.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] Conditional operation on data frame, shift/roll of vector

2009-09-26 Thread jiangrm
Conditionally, when Ind of a certain row is 1, want to get sum or delta of Val in that row and 1 row above. Val Ind Val Ind Del 10 010 0NA 11 011 0NA 13 1 --- 13 124 or 2 16 0

Re: [R] data frame's column names not the same as in CSV

2009-09-26 Thread Gabor Grothendieck
See the check.names argument in the help file for read.table. On Sat, Sep 26, 2009 at 1:58 AM, Derek Foo kc.de...@gmail.com wrote: Hello, I am trying to read in a csv file with column such as \\LS01\Processor(_Total)\% Processor Time with the command read.csv(file). However, the column name

Re: [R] synchronisation of time series data using interpolation

2009-09-26 Thread e-letter
I created separate text files for the 2 data sets. I enter the following comands: library(zoo) library(chron) z1-read.zoo(textConnection(/path/to/test1.txt),header=FALSE,sep=,,FUN=times) z2-read.zoo(textConnection(/path/to/test2.txt),header=FALSE,sep=,,FUN=times)

[R] Multiple comparisons for coxph survival analysis model

2009-09-26 Thread Pavel Kúr
Hello, all R-users! I am working on fitting a survival analysis model using the coxph function for Cox proportional hazards regression model. Data look like usual: == group blockdeathcensor Group1 1 4 1 Group1 1 12 1

Re: [R] Is there any performance difference between subset() and list comprehension?

2009-09-26 Thread Stefan Grosse
On Sat, 26 Sep 2009 15:26:12 +0900 You Hyun Jo youhyu...@gmail.com wrote: YHJ Is there any (performance) difference (except the difference of YHJ the return types) YHJ between the following two computations? Try it yourself. ?system.time is useful for that purpose. Stefan

[R] Problem with downloading workspace file from a web address

2009-09-26 Thread Paul Smith
Dear All, To load a previously saved workspace, one can do the following: load(/path/to/the/saved/workspace/file) However, if the path to the saved workspace file is a web address, one gets the following error: «Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection In

Re: [R] data frame's column names not the same as in CSV

2009-09-26 Thread Stefan Grosse
On Sat, 26 Sep 2009 01:58:38 -0400 Derek Foo kc.de...@gmail.com wrote: DF I am trying to read in a csv file with column such as DF \\LS01\Processor(_Total)\% Processor Time with the command DF read.csv(file). However, the column name in the resulted data DF frame is changed to

[R] Adding variables

2009-09-26 Thread tzygmund mcfarlane
Hi, For very large matrices, is this the most efficient way to add two variables together? # attach(attenu) new-rowSums(cbind(mag, station)) # Also, could I be directed to some resources for working with very large datasets? Thanks

Re: [R] simulating a model

2009-09-26 Thread Thomas Petzoldt
Dear Rafael, first of all, your simulation works, at least in a technical sense, so I don't understand what you mean with can't simulate it properly. Second, your SIR-based model is a quite different from the SIR models I know (e.g. http://en.wikipedia.org/wiki/SIR_Model). The R code,

[R] Mixed font in lattice xyplot lables

2009-09-26 Thread Andrewjohnclose
Hi all, can anyone suggest a reason as mto why my xlab is plotting this text at oposite ends of axis. I would like to represent my lable like this: Moran's I ...but with the I in italics. For some reason they seperate and position at oposite ends of the axis?? Thank you library(lattice) dat -

Re: [R] Conditional operation on data frame, shift/roll of vector

2009-09-26 Thread David Winsemius
On Sep 26, 2009, at 11:46 AM, jiangrm wrote: Conditionally, when Ind of a certain row is 1, want to get sum or delta of Val in that row and 1 row above. Val Ind Val Ind Del 10 010 0NA 11 011 0NA 13 1

Re: [R] synchronisation of time series data using interpolation

2009-09-26 Thread Gabor Grothendieck
Your files do not have data appropriate to your commands. Since you did not provide the data (see last line of every message to r-help) there is not much more that can be said. On Sat, Sep 26, 2009 at 4:24 AM, e-letter inp...@gmail.com wrote: I created separate text files for the 2 data sets. I

[R] R as a web service

2009-09-26 Thread Carlos J. Gil Bellosta
Dear R-helpers, I have been inquired about the possibility of developing a web distributed scoring system: a model is created in a central location, users fill a form in their browsers, and the central server calls this model and returns a YES/NO answer to them. I am tempted into using R for

[R] multiple lattice, xyplot levelplot on same page

2009-09-26 Thread Ky Mathews
Dear R-users, I'd like to place an xyplot() at the top of a page and a levelplot() at the bottom of the same page, and have the x-axes be the same. I've come close to finding a solution through Rarchive, and can produce an upside-down version of what I'd like (levelplot() on the top - see code

Re: [R] synchronisation of time series data using interpolation

2009-09-26 Thread e-letter
Test1 file contained data set 1, test2 contained data set 2 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal,

[R] merging columns from a large data set

2009-09-26 Thread Amit Kumar
Hi! All I am trying to merge very large data sets. Here fullset1 contains 13 data sets. Each data set has columns which I need to merge. Here I am trying to merge columns 2,6,10,14till end for all 13 data sets in fullset1. But I am only getting 2nd column here. Rchan1 =

Re: [R] packGrob and dynamic resizing

2009-09-26 Thread baptiste auguie
Hi, I just tried a fourth variant, closer to what ggplot2 uses (I think): to each grob is assigned a viewport with row and column positions (in my example during their construction, with ggplot2 upon editing), and they're all plotted in a given grid.layout. The timing is poor compared to pushing

Re: [R] synchronisation of time series data using interpolation

2009-09-26 Thread Gabor Grothendieck
On Sat, Sep 26, 2009 at 9:08 AM, e-letter inp...@gmail.com wrote: Test1 file contained data set 1, test2 contained data set 2 Its not clear to me what you are referring to. The data in your initial post do not exhibit this problem and there is no data in any of your subsequent posts in this

Re: [R] Spliting columns, strings or reg exp returning substrings

2009-09-26 Thread Ista Zahn
the colsplit function in the reshape package does this really easily. --ista -- Forwarded message -- From: Dry, Jonathan R jonathan@astrazeneca.com To: r-help@R-project.org Date: Fri, 25 Sep 2009 15:01:46 +0100 Subject: [R] Spliting columns, strings or reg exp returning

Re: [R] Adding variables

2009-09-26 Thread tzygmund mcfarlane
Hi Jim, I might be missing something but your command gives the error: Error in rowSums(mag) : 'x' must be an array of at least two dimensions # data(attenu) attach(attenu) rowSums(mag) + rowSums(station) attenu$new-rowSums(cbind(mag, station))

[R] Function source: desired characteristics

2009-09-26 Thread Jose Claudio Faria
Hi, We've been calling the function source (package base) from Tinn-R editor to send files, marked blocks and selections to R interpreter because it avoids a lot of problems related with input/output synchronization in the Rgui output. The new RGedit plugin is also using this function in this

Re: [R] Conditional operation on data frame, shift/roll of vector

2009-09-26 Thread David Winsemius
On Sep 26, 2009, at 12:52 PM, David Winsemius wrote: On Sep 26, 2009, at 11:46 AM, jiangrm wrote: Conditionally, when Ind of a certain row is 1, want to get sum or delta of Val in that row and 1 row above. Val Ind Val Ind Del 10 010 0NA

Re: [R] Looking for a textbook that is more concise than Applied Linear Statistical Models (2004 version)

2009-09-26 Thread Gabor Grothendieck
Check out Simon Wood's Generalized Additive Models: An Introduction with R. Its actually a lot more than its title suggests with linear model theory and related use of R in chapter 1 (and GLMs, GAMs, mixed models and GAMMs in subsequent chapters plus an appendix on matrix algebra). Google for

Re: [R] grep or other complex string matching approach to capture necessary information...

2009-09-26 Thread John Kane
?subset problems - c( Water damage, Water off, water pipes damaged, leaking water) damaged - subset(house_info, house_info[,1]==problems[1] | house_info[,1]==problems[2] | house_info[,1]==problems[3] |

Re: [R] Mixed font in lattice xyplot lables

2009-09-26 Thread baptiste auguie
Hi, I think you are feeding two expressions to xlab instead of one. Try this instead, xyplot(y ~ x, dat,xlab=expression(Moran's * italic(I))) HTH, baptiste 2009/9/26 Andrewjohnclose a.j.cl...@ncl.ac.uk: Hi all, can anyone suggest a reason as mto why my xlab is plotting this text at

Re: [R] Re tain current graphs in figure

2009-09-26 Thread John Kane
Depends on the graphing system. For basic graphics have a look at ?points ?line ?par(new) for varous options ggplot2 is designed pretty much to do this so you might want to have a look at its documentation. Not sure about lattice as don't use it. --- On Thu, 9/24/09, Natalie Wong

Re: [R] panel.text question

2009-09-26 Thread Osman Al-Radi
Hello, Thanks for your suggestion. It works in my simplified example. However, it didn't work in my real code. It is probably because I neglected to include the group argument in the example. I apologize for that. Below is the real code, if you need the actual data I can include it too. # this

[R] Lattice, stripplot (xyplot), plotting data with median line, numeric x-axis

2009-09-26 Thread Afshartous, David
All, On p.52 of Deepayan Sarkar's Lattice book there is a nice plot of showing residuals with median lines superimposed or various groups: library(lattice) stripplot(sqrt(abs(residuals(lm(yield~variety+year+site ~ site, data = barley, groups = year, jitter.data = TRUE, type = c(p, a),

Re: [R] Downloading data from from internet

2009-09-26 Thread Duncan Temple Lang
Bogaso wrote: Thanks Duncan for your input. However I could not install the package RHTMLForms, it is saying as not not available : install.packages(RHTMLForms, repos = http://www.omegahat.org/R;) Warning in install.packages(RHTMLForms, repos = http://www.omegahat.org/R;) : argument

Re: [R] Downloading data from from internet

2009-09-26 Thread cls59
Duncan Temple Lang wrote: However, you can use the source form of the package as a Windows user; you just have to install it. That involves finding out how to do this (either with Uwe's Windows package building service or by installing the tools that Brian Ripley and Duncan Murdoch

[R] Looking for a textbook that is more concise than Applied Linear Statistical Models (2004 version)

2009-09-26 Thread Peng Yu
Hi, I know this is a little bit offtopic on this list. But I can't find a more appropriate forum that I can ask. If there is a high quality forum on statistics textbook discussion, please let me know. I am reading Applied Linear Statistical Models. One drawback that I feel about this book is

Re: [R] Is there any performance difference between subset() and list comprehension?

2009-09-26 Thread You Hyun Jo
Thanks, Stefan. I tested the expressions over a set of various size of data frames. The result shows 2) and 3) are faster than 1) especially over a data frame with a large number of columns. The third one is probably the best. 1) subset(df, V1 0, V2) or subset(df, V1 0, V2)$V2 2) df[df$V1

[R] questions on csv reading

2009-09-26 Thread Jens Oehlschlägel
Hi, Is there any official way to determine the colClasses of a data.frame? Why has POSIXct such a strange class structure? Why is colClasses ordered not allowed (and doesn't work)? Background == I am writing a chunked csv reader that provides the functionality of read.table for large

Re: [R] Adding variables

2009-09-26 Thread jim holtman
I assumed (since you did not provide reproducible code) that 'mag' was a matrix. If 'station' is a matrix, then mag + rowSums(station) will work. If that does not work, then you need to tell us what your data objects are. On Sat, Sep 26, 2009 at 11:39 AM, tzygmund mcfarlane

[R] multiclass SVM (e1071 package): number of estimated models

2009-09-26 Thread john.gelburg
Hi, I run multiclass SVM for iris data, which contains 3 classes (manual page 52). Based on manual, the implementation uses one-against-one approach: k*(k-1)/2 binary classifiers trained. However, I am getting only two models instead of three (only two columns of support vectors and

Re: [R] Downloading data from from internet

2009-09-26 Thread Gabor Grothendieck
Here are three different approaches: 1. Using the first link as an example, on Windows you can copy the data and headers from IE (won't work in Firefox) to Excel and from there to clipboard again and then in R: library(zoo) DF - read.delim(clipboard) z - zooreg(c(t(DF[5:1, 2:13])), start =

Re: [R] questions on csv reading

2009-09-26 Thread Gabor Grothendieck
2009/9/26 Jens Oehlschlägel oehl_l...@gmx.de: Hi, Is there any official way to determine the colClasses of a data.frame? Why has POSIXct such a strange class structure? Why is colClasses ordered not allowed (and doesn't work)? Background == I am writing a chunked csv reader that

Re: [R] R as a web service

2009-09-26 Thread Martin Morgan
Carlos J. Gil Bellosta wrote: Dear R-helpers, I have been inquired about the possibility of developing a web distributed scoring system: a model is created in a central location, users fill a form in their browsers, and the central server calls this model and returns a YES/NO answer to

[R] implementation of matrix logarithm (inverse of matrix exponential)

2009-09-26 Thread Mimosa Zeus
Dear R users, Does anyone has implemented the inverse of the matrix exponential (expm in the package Matrix)? In Matlab, there're logm and expm, there's only expm in R. Cheers Mimosa [[alternative HTML version deleted]] __

Re: [R] data frame's column names not the same as in CSV

2009-09-26 Thread Don MacQueen
At 1:58 AM -0400 9/26/09, Derek Foo wrote: Hello, I am trying to read in a csv file with column such as \\LS01\Processor(_Total)\% Processor Time with the command read.csv(file). However, the column name in the resulted data frame is changed to X..LS01.Processor._TotalProcessor.Time.

Re: [R] evaluate a set of symbols within an IF statement

2009-09-26 Thread Greg Snow
?any -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of zubin Sent: Friday, September 25, 2009 6:00 PM To:

Re: [R] implementation of matrix logarithm (inverse of matrix exponential)

2009-09-26 Thread Gabor Grothendieck
Try: expm( - M) On Sat, Sep 26, 2009 at 5:06 PM, Mimosa Zeus mimosa1...@yahoo.fr wrote: Dear R users, Does anyone has implemented the inverse of the matrix exponential (expm in the package Matrix)? In Matlab, there're logm and expm, there's only expm in R. Cheers Mimosa        

Re: [R] evaluate a set of symbols within an IF statement

2009-09-26 Thread Jorge Ivan Velez
Hi zubin, Try also tname = VIX checkticker = c(VIX, TYX, TNX, IRX) is.element(tname, checkticker) # [1] TRUE HTH, Jorge On Fri, Sep 25, 2009 at 8:00 PM, zubin binab...@bellsouth.net wrote: Hello, writing some R code to cleanse a data set, if the following set of symbols are identified then

Re: [R] implementation of matrix logarithm (inverse of matrix exponential)

2009-09-26 Thread Charles C. Berry
On Sat, 26 Sep 2009, Gabor Grothendieck wrote: Try: expm( - M) Mimosa probably meant say 'the inverse function'. I do not see one in R. Chuck On Sat, Sep 26, 2009 at 5:06 PM, Mimosa Zeus mimosa1...@yahoo.fr wrote: Dear R users, Does anyone has implemented the inverse of the matrix

Re: [R] implementation of matrix logarithm (inverse of matrix exponential)

2009-09-26 Thread Gabor Grothendieck
OK. Try this: library(Matrix) M - matrix(c(2, 1, 1, 2), 2); M [,1] [,2] [1,]21 [2,]12 # log of expm(M) is original matrix M with(eigen(expm(M)), vectors %*% diag(log(values)) %*% t(vectors)) [,1] [,2] [1,]21 [2,]12 On Sat, Sep 26, 2009 at 6:24 PM,

Re: [R] implementation of matrix logarithm (inverse of matrix exponential)

2009-09-26 Thread Charles C. Berry
On Sat, 26 Sep 2009, Gabor Grothendieck wrote: OK. Try this: library(Matrix) M - matrix(c(2, 1, 1, 2), 2); M [,1] [,2] [1,]21 [2,]12 Right. expm( M ) is diagonalizable. But for M - matrix( c(0,1,0,0), 2 ) you get the wrong result. Maybe I should have added that I

Re: [R] implementation of matrix logarithm (inverse of matrix exponential)

2009-09-26 Thread Gabor Grothendieck
Often one uses matrix logarithms on symmetric positive definite matrices so the assumption of being symmetric is sufficient in many cases. On Sat, Sep 26, 2009 at 7:28 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Sat, 26 Sep 2009, Gabor Grothendieck wrote: OK. Try this:

Re: [R] implementation of matrix logarithm (inverse of matrix exponential)

2009-09-26 Thread spencerg
Sylvester's formula (http://en.wikipedia.org/wiki/Sylvester%27s_formula) applies to a square matrix A = S L solve(S), where L = a diagonal matrix and S = matrix of eigenvectors. Let f be an analytic function [for which f(A) is well defined]. Then f(A) = S f(L) solve(S). We can

[R] 3D to 2D projection

2009-09-26 Thread Nair, Murlidharan T
Is there a method that I can use to convert 3D coordinates into 2D? I was looking at persp and trans3d. Are those the ones I should be looking at ? Thanks ../Murli __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] 3D to 2D projection

2009-09-26 Thread David Winsemius
On Sep 26, 2009, at 10:07 PM, Nair, Murlidharan T wrote: Is there a method that I can use to convert 3D coordinates into 2D? Yes. I was looking at persp and trans3d. Are those the ones I should be looking at ? Yes. Thanks ../Murli -- David Winsemius, MD Heritage Laboratories West

[R] Summary/Bootstrap for Design library's lrm function

2009-09-26 Thread kkruse
Can anyone tell me what I might be doing incorrectly for an ordinal logistic regression for lrm? I cannot get R(2.9.1)to run either summary nor will it let me bootstrp to validate. ### Y is a 5 value measure with a range from 1-5, the independent variables are the same. N=75 but when we knock

[R] Re ad in multiple datasets

2009-09-26 Thread legen
Hello, all: I have twenty datasets named as: data1.csv, data2.csv, …, data20.csv. I am trying to read all of them into R by using loop and function read.table(), but I don't know how to handle the name of datasets. Has anybody have encountered a similar problem? Or do you have any suggestions?

Re: [R] Re ad in multiple datasets

2009-09-26 Thread jim holtman
input - lapply(1:20, function(.file) read.csv(paste('data', .file, '.csv', sep=''))) This will create a list of 20 with the dataframe from each file in the list. On Sat, Sep 26, 2009 at 11:47 PM, legen lege...@gmail.com wrote: Hello, all: I have twenty datasets named as: data1.csv,

[R] Converting SAS Data code to R.

2009-09-26 Thread David Winsemius
I am contemplating bringing in and merging three NHANES-III datasets from the National Center for Health Statistics that are fixed format with record length=3348, line counts around 20,000 and described by SAS DATA steps. I have downloaded and linked similar datasets from the Continuous

Re: [R] Summary/Bootstrap for Design library's lrm function

2009-09-26 Thread David Winsemius
On Sep 26, 2009, at 5:11 PM, kkr...@uci.edu wrote: Can anyone tell me what I might be doing incorrectly for an ordinal logistic regression for lrm? I cannot get R(2.9.1)to run either summary nor will it let me bootstrp to validate. ### Y is a 5 value measure with a range from 1-5, the

Re: [R] Teach me how to transpose in R

2009-09-26 Thread milton ruser
*Hum* bbb=t(as.matrix(data2)) ? good luck milton On Sun, Sep 27, 2009 at 12:39 AM, Hyo Lee totem...@gmail.com wrote: Hi guys, I need your help!! My goal is to make a csv file from ncdf file. This is the code i've used : hyo=open.ncdf(C:/CRUTEM3.nc) hyo [1] file C:/CRUTEM3.nc has