Re: [R] Data Manipulation

2010-09-10 Thread Erik Iverson
Hello, This is definitely possible with R, there a lots of package to make good graphics. However, the easiest way for us to help you is if you give us a small reproducible example, as you started to with your initial post. If you have an object in your R session that you'd like help with you

Re: [R] Data Manipulations and SQL

2010-08-26 Thread stephenb
Greetings Gabor, is it possible to open a channel to a data frame in the default environment? there are cases when using a sql update statement is the simplest alternative, so instead of dumping the df and then updating and then reimporting it I would like to update the df directly in R. Thank

Re: [R] Data Manipulations and SQL

2010-08-26 Thread Gabor Grothendieck
On Thu, Aug 26, 2010 at 1:18 PM, stephenb stephen.b...@cibc.com wrote: is it possible to open a channel to a data frame in the default environment? there are cases when using a sql update statement is the simplest alternative, so instead of dumping the df and then updating and then reimporting

[R] data frame handling

2010-08-16 Thread Lily_stats
Dear all, I have an xts object , t.xts with 4 columns: v1 DD1 v2 DD2 and created a data frame : t - as.data.frame(t.xts) I would like to extract data and create a new data frame for when the values in column DD1 falls between 0 and 30 and extract the corresponding v1 value. How can I do

Re: [R] data frame handling

2010-08-16 Thread David Winsemius
On Aug 16, 2010, at 5:53 AM, Lily_stats wrote: Dear all, I have an xts object , t.xts with 4 columns: v1 DD1 v2 DD2 and created a data frame : t - as.data.frame(t.xts) t is not the best choice of names for an object because it is the name of a commonly used function Let's instead

[R] Data manipulation search

2010-08-11 Thread Mestat
Hi listers, I made some search, but i didn`t find in the forum. I have a data set. I would like to make a search (conditon) on my data set. x-c(1,2,3,4,5,6,7,8,9,10) count-0 if (CONDITON){count-1}else{count-0} My CONDITION would be: is there number 5 in my data set? Thanks in advance, Marcio

Re: [R] Data manipulation search

2010-08-11 Thread Erik Iverson
?match, look at the %in% operator. Mestat wrote: Hi listers, I made some search, but i didn`t find in the forum. I have a data set. I would like to make a search (conditon) on my data set. x-c(1,2,3,4,5,6,7,8,9,10) count-0 if (CONDITON){count-1}else{count-0} My CONDITION would be: is there

Re: [R] Data frame reordering to time series

2010-08-08 Thread steven mosher
In the real data the months are all complete, but the years can be missing. So years can be missing up front, in the middle, at the end. but if a year is present than every month has a value or NA. To create regular R ts I had to plow through the data frame, collect a year caluculate an index to

Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 2:01 AM, steven mosher mosherste...@gmail.com wrote: In the real data the months are all complete, but the years can be missing. So years can be missing up front, in the middle, at the end. but if a year is present than every month has a value or NA. To create regular R

Re: [R] Data frame reordering to time series

2010-08-08 Thread steven mosher
Ok, I'm a bit confused by what you mean by regularly spaced After I do the do.call I do get a data structure with all the times present and every time has a NA or a data value. Steve On Sun, Aug 8, 2010 at 2:46 AM, Gabor Grothendieck ggrothendi...@gmail.comwrote: On Sun, Aug 8, 2010 at 2:01

Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 11:21 AM, steven mosher mosherste...@gmail.com wrote: Ok, I'm a bit confused by what you mean by regularly spaced After I do the  do.call I do get a data structure with all the times present and every time has a NA or a data value. Steve regularly spaced means that

Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 11:55 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Aug 8, 2010 at 11:21 AM, steven mosher mosherste...@gmail.com wrote: Ok, I'm a bit confused by what you mean by regularly spaced After I do the  do.call I do get a data structure with all the times

Re: [R] Data frame reordering to time series

2010-08-08 Thread steven mosher
Thanks again, They worked for me as well. I did a simpler example with fewer years just to show that it worked...( shorted here for display) f - function(x) { +dat - x[-(1:2)] +tim - as.yearmon(outer(x$Year, seq(0, length = ncol(dat))/12, +)) +zoo(c(as.matrix(dat)), tim)

Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 5:54 PM, steven mosher mosherste...@gmail.com wrote: z-as.zooreg(as.ts(g)) z          X12345 X34567 X56789 1989(1)      NA      3      6 1989(2)      NA      3      6 1989(3)      NA      3      6 1989(4)      NA      3      6 1989(5)      NA      3      6 1989(6)  

[R] Data frame reordering to time series

2010-08-07 Thread steven mosher
Given a data frame, or it could be a matrix if I choose to. The data consists of an ID, a year, and data for all 12 months. Missing values are a factor AND missing years. Id-c(rep(67543,4),rep(12345,3),rep(89765,5)) Years-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1))

Re: [R] Data frame reordering to time series

2010-08-07 Thread Gabor Grothendieck
On Sat, Aug 7, 2010 at 4:49 PM, steven mosher mosherste...@gmail.com wrote: Given a data frame, or it could be a matrix if I choose to. The data consists of an ID, a year, and data for all 12 months. Missing values are a factor AND missing years. Id-c(rep(67543,4),rep(12345,3),rep(89765,5))  

Re: [R] Data frame reordering to time series

2010-08-07 Thread steven mosher
Thanks Gabor, I probably should have done an example with fewer columns. i will rework the example and post it up so the next guys who has this issue can have a clear example with a solution. On Sat, Aug 7, 2010 at 5:04 PM, Gabor Grothendieck ggrothendi...@gmail.comwrote: On Sat, Aug 7, 2010

Re: [R] Data frame reordering to time series

2010-08-07 Thread steven mosher
Very Slick. Gabor this is a Huge speed up for me. Thanks. ha, Now I want to rewrite a bunch of working code. Id-c(rep(67543,4),rep(12345,3),rep(89765,5)) Years-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1)) Values2-c(12,NA,34,21,NA,65,23,NA,13,NA,13,14)

Re: [R] Data frame reordering to time series

2010-08-07 Thread Gabor Grothendieck
On Sat, Aug 7, 2010 at 9:18 PM, steven mosher mosherste...@gmail.com wrote: Very Slick. Gabor this is a Huge speed up for me. Thanks. ha, Now I want to rewrite a bunch of working code. Id-c(rep(67543,4),rep(12345,3),rep(89765,5))  Years-c(seq(1989,1992,by

Re: [R] Data Handling

2010-08-02 Thread Lily_stats
Hi, I have managed to convert my data frames into xts such as : str(z) An ‘xts’ object from 1983-01-03 19:00:00 to 2006-01-01 22:00:00 containing: Data: num [1:182959, 1:2] 12.6 11.3 12.7 12.8 10.9 ... - attr(*, dimnames)=List of 2 ..$ : NULL ..$ : chr [1:2] v DD Indexed by

Re: [R] Data Handling

2010-07-30 Thread Lily_stats
Hi, I am trying to convert my dataset into xts. I have tried the following : data1-read.table(data1.txt,header=F) data2-read.table(data2.txt,header=F) data1.xtsas.xts(data1,descr=my new xts object) However, I get an error : Error in as.POSIXlt.character(x, tz, ...) : character string is

Re: [R] Data Handling

2010-07-30 Thread Gabor Grothendieck
On Fri, Jul 30, 2010 at 9:02 AM, Lily_stats sund...@gmail.com wrote: Hi, I am trying to convert my dataset into xts. I have tried the following : data1-read.table(data1.txt,header=F) data2-read.table(data2.txt,header=F) data1.xtsas.xts(data1,descr=my new xts object) However, I get an

[R] Data Handling

2010-07-30 Thread Lily_stats
Hi, I am very new to R so these questions may seem simple! I have a huge 2 sets of data(matrix 5x2++) in the following formats , for example data.txt and data2.txt: Date Time X Y 03/03/1983 20:00 0.1 990 I would like to recreate

Re: [R] Data Handling

2010-07-30 Thread raghu
Convert your datasets into xts objects and then do a cbind ordering by the column you want. Do a ?cbind. HTH Raghu On Fri, Jul 30, 2010 at 10:33 AM, Lily_stats [via R] ml-node+2307770-1033893256-309...@n4.nabble.comml-node%2b2307770-1033893256-309...@n4.nabble.com wrote: Hi, I am very new

Re: [R] Data Handling

2010-07-30 Thread raghu
Please try: data - xts(data[,2:n], order.by=as.POSIXct(strptime(data[,1], %d/%m/%Y))) Use similar strptime for hours also.n=number of columns. Good Luck Raghu On Fri, Jul 30, 2010 at 2:02 PM, Lily_stats [via R]

[R] Data frame modification

2010-07-28 Thread siddharth . garg85
Hi I am trying to modify a data frame D with lists x and y in such a way that if a value in x==0 then it should replace that value with the last not zero value in x. I.e. for loop over i{ if(D$x[i]==0) D$x[i]=D$x[i-1] } The data frame is quite large in size ~ 43000 rows. This operation

Re: [R] data arranged by p-values

2010-07-26 Thread ONKELINX, Thierry
-Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens jd6688 Verzonden: maandag 26 juli 2010 7:07 Aan: r-help@r-project.org Onderwerp: [R] data arranged by p-values Idcat1locationitem_values p-values sequence

[R] data arranged by p-values

2010-07-25 Thread jd6688
Id cat1locationitem_values p-valuessequence a1111 3002737 0.196504377 0.011 a1121 3017821 0.196504377 0.052 a1131 3027730 0.196504377 0.023 a1141 3036220 0.196504377 0.04

[R] data from SpatialGridDataFrame

2010-07-20 Thread kfleis
Dear All, I have a raster map of the class 'SpatialPointsDataFrame' and coordinates of the class 'SpatialPoints'. I would like to retrieve the values that are contained in the raster map at the specific locations given by the coordinates. Can anyone help me out? Kind regards, Katrin Fleischer

Re: [R] data from SpatialGridDataFrame

2010-07-20 Thread chris howden
-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of kfl...@falw.vu.nl Sent: Tuesday, 20 July 2010 9:42 PM To: r-help@r-project.org Subject: [R] data from SpatialGridDataFrame Dear All, I have a raster map of the class 'SpatialPointsDataFrame' and coordinates of the class 'SpatialPoints'. I

Re: [R] data from SpatialGridDataFrame

2010-07-20 Thread Kingsford Jones
see ?sp::overlay and section 5.2 of Applied Spatial Data Analysis with R I see there is now also raster::overlay, but I can't claim experience with that funciton (however my impression is that the raster package is a powerful tool for working with potentially very large rasters in R). hth,

[R] data export HELP!

2010-07-11 Thread adriana1986
Hello! So, this is going to seem like a very simple question - I am quite new to R and am having some trouble figuring out little nuances: I am running a loop that goes through my data and performs a nls parameter estimation on each data set. At the end of the loop, I would like to collect the

Re: [R] data export HELP!

2010-07-11 Thread jim holtman
Not necessarily the best way if your dataframe will get large, but it should work: parameters - NULL # where you will collect the result for(j in 1:dim(r)[2]){ indiv=r[,j][which(r[,j]-1)] #removes -1 growth data age.1=age[1:length(indiv)] length.ind=data.frame(age.1,indiv,

[R] Data format question for triangle.plot package ade4

2010-07-09 Thread Steve_Friedman
hello, I am trying to develop a triangle plot but am having difficultly assigning the row.names to the 3 columns in the data.frame Here is what I've done, attach(SoilVegHydro) dim(SoilVegHydro) 129239 # now take 3 variables from main data.frame for plotting dat - cbind.data.frame(TP,

Re: [R] Data format question for triangle.plot package ade4

2010-07-09 Thread David Winsemius
On Jul 8, 2010, at 4:41 PM, steve_fried...@nps.gov wrote: hello, I am trying to develop a triangle plot but am having difficultly assigning the row.names to the 3 columns in the data.frame Here is what I've done, attach(SoilVegHydro) dim(SoilVegHydro) 129239 # now take 3

Re: [R] Data Frame Manipulation using function

2010-07-09 Thread harsh yadav
Hi, Thanks a lot. The Vectorize method worked and its much faster than looping through the data frame. Regards, Harsh Yadav On Thu, Jul 8, 2010 at 11:06 PM, David Winsemius dwinsem...@comcast.netwrote: On Jul 8, 2010, at 10:33 PM, Erik Iverson wrote: I have a data frame: id url

Re: [R] Data Frame Manipulation using function

2010-07-09 Thread David Winsemius
Really? I don't usually think of Vectorize as a performance enhancement, probably because my use of with a complex function then gets applied to 4.5 million records. I need to go out, get a cup of coffee, and leave it alone for about half an hour. I tried recently to figure out how I can

[R] Data Frame Manipulation using function

2010-07-08 Thread harsh yadav
Hi all, I have a data frame for which I want to limit the output by checking whether row values for specific column meets particular conditions. Here are the more specific details: I have a function that checks whether an input string exists in a defined list:- checkBaseLine - function(s){

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread Erik Iverson
It will be a lot easier to help you if you follow the posting guide and PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. You gave your function definition, which is good. Use ?dput to give us a small data.frame that can accurately show what

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread harsh yadav
Hi, Here is a somewhat detailed explanation of what I want to achieve: I have a data frame: id url urlType 1 1 www.yahoo.com1 2 2 www.google.com/?search= 2 3 3 www.google.com

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread David Winsemius
On Jul 8, 2010, at 10:09 PM, harsh yadav wrote: Hi, Here is a somewhat detailed explanation of what I want to achieve: I have a data frame: id url urlType 1 1 www.yahoo.com1 2 2 www.google.com/?search= 2 3

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread Erik Iverson
I have a data frame: id url urlType 1 1 www.yahoo.com http://www.yahoo.com 1 2 2 www.google.com/?search= http://www.google.com/?search= 2 3 3

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread David Winsemius
On Jul 8, 2010, at 10:33 PM, Erik Iverson wrote: I have a data frame: id url urlType 1 1 www.yahoo.com http:// www.yahoo.com1 2 2 www.google.com/?search=

Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-07 Thread Greg Snow
, 2010 9:44 PM To: r-help@r-project.org Subject: [R] Data Labels in a barchart (Lattice or otherwise) Hi, Can anyone please help me with how I could add labels with the value for each bar in a barchart? (similar to how data labels can be added in Excel) I have done a lot of searching

[R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread RaoulD
Hi, Can anyone please help me with how I could add labels with the value for each bar in a barchart? (similar to how data labels can be added in Excel) I have done a lot of searching but havent been lucky. Thanks, Raoul -- View this message in context:

Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread David Winsemius
On Jul 4, 2010, at 11:43 PM, RaoulD wrote: Hi, Can anyone please help me with how I could add labels with the value for each bar in a barchart? (similar to how data labels can be added in Excel) I have done a lot of searching but havent been lucky. This is generally pretty easy with

Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread RaoulD
Thank You David. Yes, I am using the lattice barchart and have managed to add data labels, however, they tend to be on the tip of each bar and are difficult to read as they are partially on the bar. Any help would be greatly appreciated. This is the code I am using:

Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread David Winsemius
On Jul 5, 2010, at 1:14 PM, RaoulD wrote: Thank You David. Yes, I am using the lattice barchart and have managed to add data labels, however, they tend to be on the tip of each bar and are difficult to read as they are partially on the bar. Any help would be greatly appreciated. This is

[R] data frame row statistics (mean)?

2010-06-28 Thread Douglas M. Hultstrand
Hello, I am trying to calculate the mean value of each row in a data frame (d), I am having troubles and getting errors using the code I have written. Below is a brief example of the code, any thought or suggestions would be great. Thank you for your time, Doug # Example Code: d -

Re: [R] data frame row statistics (mean)?

2010-06-28 Thread Phil Spector
Doug - Try d$avg = apply(d,1,mean,na.rm=TRUE) d st1 st2 st3 st4 avg 1 1 2 5 6 3.50 2 2 5 5 5 4.25 3 3 6 NA 7 5.33 4 4 7 7 8 6.50 (If you must use a loop, calculate mean(as.numeric(d[i,1:4])) Take a look at mean(d[1,1:4]) to

Re: [R] data frame row statistics (mean)?

2010-06-28 Thread Erik Iverson
Douglas M. Hultstrand wrote: Hello, I am trying to calculate the mean value of each row in a data frame (d), I am having troubles and getting errors using the code I have written. Below is a brief example of the code, any thought or suggestions would be great. Thank you for your time,

Re: [R] data frame row statistics (mean)?

2010-06-28 Thread Joshua Wiley
Hello Doug, I just wanted to add that a faster way to initialize a vector is: avg - vector(numeric, nrow(d)) Also you might like nrow(d) over length(d[ , 1]) if the number of rows is what you are after. Its sister function is ncol() . Best regards, Josh On Mon, Jun 28, 2010 at 11:37 AM,

[R] data frame

2010-06-17 Thread n.via...@libero.it
Dear list, I have the following problem. I have a data frame like this CLUSTERYEAR variableDelta R_pivot M1 2005 EC01 NA NA M1 2006 EC012

Re: [R] data frame

2010-06-17 Thread Sarah Goslee
You've posted this repeatedly, and yet received no answer. Perhaps that is because you haven't read the posting guide! You didn't provide a reproducible example, you didn't tell us where ddply came from, you didn't tell us what was wrong with the code you suggested. It would also be rather easier

[R] data frame

2010-06-16 Thread n.via...@libero.it
Dear list, I have the following problem. I have a data frame like this CLUSTERYEAR variableDelta R_pivot M1 2005 EC01 NA NA M1 2006 EC012

[R] data frame

2010-06-16 Thread n.via...@libero.it
Dear list, I have the following problem. I have a data frame like this CLUSTERYEAR variableDelta R_pivot M1 2005 EC01 NA NA M1 2006 EC012

[R] data-management: Rowwise NA

2010-06-03 Thread moleps
Dear R´ers.. In this mock dataset how can I generate a logical variable based on whether just tes or tes3 are NA in each row?? test-sample(c(A,NA,B),100,replace=T) test2-sample(c(A,NA,B),100,replace=T) test3-sample(c(A,NA,B),100,replace=T) tes-cbind(test,test2,test3) sam-c(test,test3)

Re: [R] data-management: Rowwise NA

2010-06-03 Thread Phil Spector
?any Not really a reproducible answer, but I think you're looking for apply(tes[,sam],1,function(x)any(is.na(x))) - Phil Spector Statistical Computing Facility Department

Re: [R] data-management: Rowwise NA

2010-06-03 Thread Jorge Ivan Velez
Hi there, One option would be apply(tes, 1, function(.row) any(is.na(.row[c(1,3)]))) See ?any, ?is.na and ?apply for more information. HTH, Jorge On Thu, Jun 3, 2010 at 3:20 PM, moleps wrote: Dear R´ers.. In this mock dataset how can I generate a logical variable based on whether just

Re: [R] data-management: Rowwise NA

2010-06-03 Thread Marc Schwartz
On Jun 3, 2010, at 2:20 PM, moleps wrote: Dear R´ers.. In this mock dataset how can I generate a logical variable based on whether just tes or tes3 are NA in each row?? test-sample(c(A,NA,B),100,replace=T) test2-sample(c(A,NA,B),100,replace=T) test3-sample(c(A,NA,B),100,replace=T)

Re: [R] data-management: Rowwise NA

2010-06-03 Thread David S Freedman
you probably want to use the apply function: d=sample(1000,500); d[sample(500,50)]-NA; #put 50 NAs into the data d=data.frame(matrix(d,ncol=50)); names(d)=paste('var',1:50,sep='.') d apply(d,1,sum) #are any of the row values NA ? apply(d,2,function(x)sum(is.na(x))) #how many values for each of

Re: [R] data-management: Rowwise NA

2010-06-03 Thread moleps
-Any- was my fix... Appreciate it. //M On 3. juni 2010, at 21.33, Phil Spector wrote: ?any Not really a reproducible answer, but I think you're looking for apply(tes[,sam],1,function(x)any(is.na(x))) - Phil Spector

Re: [R] data frame manipulation with zero rows

2010-06-02 Thread Hadley Wickham
!! if (nrow(futures)==0) futures-data.frame(...) -Original Message- From: Peter Ehlers [mailto:ehl...@ucalgary.ca] Sent: Tuesday, June 01, 2010 12:07 PM To: arnaud Gaboury Cc: 'Prof Brian Ripley'; r-help@r-project.org Subject: Re: [R] data frame manipulation with zero rows On 2010

Re: [R] data frame manipulation with zero rows

2010-06-02 Thread arnaud Gaboury
Subject: Re: [R] data frame manipulation with zero rows On 2010-06-01 1:53, arnaud Gaboury wrote: Brian, If I do understand correctly, I must use in my function something else than ddply() if I want to avoid any error each time my df has zero rows? Am I correct? You could

[R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
Dear group, Here is the kind of data.frame I obtain every day with my function : futures - structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10, LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
To: arnaud Gaboury Subject: Re: [R] data frame manipulation with zero rows On Tue, 1 Jun 2010, arnaud Gaboury wrote: Dear group, Here is the kind of data.frame I obtain every day with my function : futures - structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, CORN Jul/10

[R] data frame manipulation ddply

2010-06-01 Thread arnaud Gaboury
Dear group, Here is my data frame: futures - structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10, LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10 ),

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread Peter Ehlers
01, 2010 9:47 AM To: arnaud Gaboury Subject: Re: [R] data frame manipulation with zero rows On Tue, 1 Jun 2010, arnaud Gaboury wrote: Dear group, Here is the kind of data.frame I obtain every day with my function : futures- structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, CORN Jul/10

Re: [R] data frame manipulation ddply

2010-06-01 Thread arnaud Gaboury
...@uni-bremen.de] Sent: Tuesday, June 01, 2010 11:38 AM To: arnaud Gaboury Subject: Re: [R] data frame manipulation ddply Hi Arnaud, maybe aggregate can help: PosFut - aggregate(futures$QUANTITY, list(DESCRIPTION = futures$DESCRIPTION, SETTLEMENT

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread Prof Brian Ripley
of zero rows: it may or may not be the one in package plyr. -Peter Ehlers -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Tuesday, June 01, 2010 9:47 AM To: arnaud Gaboury Subject: Re: [R] data frame manipulation with zero rows On Tue, 1 Jun 2010

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
It is indeed ddply() from package plyr. -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Tuesday, June 01, 2010 12:24 PM To: Peter Ehlers Cc: arnaud Gaboury; r-help@r-project.org Subject: Re: [R] data frame manipulation with zero rows On Tue, 1

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
Brian Ripley'; r-help@r-project.org Subject: Re: [R] data frame manipulation with zero rows On 2010-06-01 1:53, arnaud Gaboury wrote: Brian, If I do understand correctly, I must use in my function something else than ddply() if I want to avoid any error each time my df has zero rows? Am

[R] Data Frame as Hash Table

2010-05-30 Thread Alan Lue
I'm interested in using a data frame as if it were a hash table. For instance if I had the following, (d - data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6))) keyvalue 1 0.5 -1.118665122 2 1.0 0.465122921 3 1.5 -0.529239211 4 2.0 -0.147324638 5 2.5 -1.531503795 6 3.0 -0.002720434 Then

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Barry Rowlingson
On Sun, May 30, 2010 at 9:03 AM, Alan Lue alan@gmail.com wrote: I'm interested in using a data frame as if it were a hash table.  For instance if I had the following, (d - data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))  key        value 1 0.5 -1.118665122 2 1.0  0.465122921 3 1.5

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Patrick Burns
You might want to investigate the 'data.table' package. On 30/05/2010 09:03, Alan Lue wrote: I'm interested in using a data frame as if it were a hash table. For instance if I had the following, (d- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6))) keyvalue 1 0.5 -1.118665122 2

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Marshall Feldman
To:r-help@r-project.org,alan@gmail.com Subject: Re: [R] Data Frame as Hash Table Message-ID:4c0220b6.7090...@pburns.seanet.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed You might want to investigate the 'data.table' package. On 30/05/2010 09:03, Alan Lue wrote: I'm

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Alan Lue
: Message: 40 Date: Sun, 30 May 2010 09:24:22 +0100 From: Patrick Burnspbu...@pburns.seanet.com To:r-help@r-project.org,alan@gmail.com Subject: Re: [R] Data Frame as Hash Table Message-ID:4c0220b6.7090...@pburns.seanet.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed You

Re: [R] Data frame manipulation

2010-05-29 Thread Tal Galili
Hi there, I am glad it helped. I used mean as something to use, not because I had an understanding that this is what you need - so if you believe sum is what you where after - go with it :) Regarding loving R, and time spending - everyone on this list probably know how you feel. We all spent

Re: [R] Data frame manipulation

2010-05-28 Thread Tal Galili
Hi there, The tool to learn for this is the cast function using the reshape package. In your example you have more then one value for RTL, which you should think of how to account for. But basically, here is a solution to what you asked for (assuming I understood you correctly) require(reshape)

Re: [R] Methods to explore R data structures

2010-05-28 Thread Timothy Wu
Great, these are valuable tips. Thanks both of you. I appreciate it. :) Timothy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] Data frame manipulation

2010-05-28 Thread LCOG1
Tal, Wow, i cant believe how many different manipulations i went through trying to coerce it into the format i wanted. The below works nearly perfectly, i had to change the mean call to sum. Im curious why you used mean? Other than that thank you very much, i feel a little foolish about

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread Joris Meys
, something like : if(trade$Trade.Status==DEL)switch(.) I would like to avoid the loop . From: Joris Meys [mailto:jorism...@gmail.com] Sent: Wednesday, May 26, 2010 9:15 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria see ?switch X- rep(c(Buy,Sell,something else),each=5) Y- rep(c(DEL,INS,DEL),5) new.vect - X for (i in which(Y==DEL)){     new.vect[i]-switch(   EXPR = X[i],   Sell=Buy,   Buy

[R] data frame change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
. NULL That's certainly not what I want. From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 8:43 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria The loop is due to the switch statement

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
..sum. NULL That's certainly not what I want. From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 8:43 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria The loop is due to the switch statement

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread Joris Meys
NULL $Net.Charges..sum. NULL That's certainly not what I want. From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 8:43 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria The loop is due

[R] Methods to explore R data structures

2010-05-27 Thread Timothy Wu
Hi, I'm very confused about R structures and the methods to go with them. I'm using R for microarray analysis with Bioconductors. Suppose without reading the documentations, what's the best way to explore a data structure when you know nothing about it? I am currently using is() / class() to see

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread Joris Meys
want !! From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 10:38 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria Off course. You put in a matrix to sapply, but sapply is for vectors. You want

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
, Instrument.Long.Name, Delivery.Prompt.Date, Buy.Sell..Cleared., Volume, Price, Net.Charges..sum.), row.names = c(NA, 3L), class = data.frame) From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 10:38 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria Off course. You put in a matrix to sapply, but sapply is for vectors. You want to apply the switch command on every entry of the vector trades$Buy.Sell..Cleared for which trades

Re: [R] Methods to explore R data structures

2010-05-27 Thread Martin Morgan
On 05/27/2010 02:13 AM, Timothy Wu wrote: Hi, I'm very confused about R structures and the methods to go with them. I'm using R for microarray analysis with Bioconductors. Suppose without reading the documentations, what's the best way to explore a data structure when you know nothing about

Re: [R] Methods to explore R data structures

2010-05-27 Thread Greg Snow
: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Timothy Wu Sent: Thursday, May 27, 2010 3:14 AM To: r-help@r-project.org Subject: [R] Methods to explore R data structures Hi, I'm very confused about R structures and the methods to go with them. I'm

[R] Data frame manipulation

2010-05-27 Thread LCOG1
Hello All, Please consider the following: TotEmp-c(19,6,1,1,8,44,2,33,48,1) ClusterType-c(AGF,CNS,OSV,RTL,RTL,TRN,REL,ACC_CLUST,RTL,WHL) Taz-c(0,0,0,100,100,100,101,101,102,103) AllCtTypes_-c(AGF,CNS,OSV,RTL,TRN,REL,ACC_CLUST,WHL,ADM_CLUST,

[R] data frame manipulation change elements meeting criteria

2010-05-26 Thread arnaud Gaboury
Dear group, Here is my df : trade - structure(list(Trade.Status = c(DEL, INS, INS), Instrument.Long.Name = c(SUGAR NO.11, CORN, CORN), Delivery.Prompt.Date = c(Jul/10, Jul/10, Jul/10), Buy.Sell..Cleared. = c(Sell, Buy, Buy), Volume = c(1L, 2L, 1L), Price = c(15.2500, 368., 368.5000),

Re: [R] data frame manipulation change elements meeting criteria

2010-05-26 Thread Joris Meys
see ?switch X- rep(c(Buy,Sell,something else),each=5) Y- rep(c(DEL,INS,DEL),5) new.vect - X for (i in which(Y==DEL)){ new.vect[i]-switch( EXPR = X[i], Sell=Buy, Buy=Sell, X[i]) } cbind(new.vect,X,Y) On Wed, May 26, 2010 at 7:43 PM, arnaud Gaboury

[R] Data frames, passing by value, and performance

2010-05-24 Thread gschultz
I understand that everything passed to an R function is passed by value. This would seem to include data frames, which my current application uses heavily, both for storing program inputs, and holding intermediate and final results. In trying to get greater performance out of my R code, I am

Re: [R] Data frames, passing by value, and performance

2010-05-24 Thread Gabor Grothendieck
If you don't modify the data frame in your function it won't physically make a new copy. On Mon, May 24, 2010 at 10:29 AM, gschu...@scriptpro.com wrote: I understand that everything passed to an R function is passed by value.  This would seem to include data frames, which my current

Re: [R] Data frames, passing by value, and performance (Matt Shotwell)

2010-05-24 Thread biostatmatt
R is pretty smart about duplicating only when necessary. That is, arguments passed to a function are copy-on-write. Also, I think (someone more knowledgeable please correct if I'm wrong) it may be better to use the data frame, which is just a list internally, because if you only modify one column,

Re: [R] Data reconstruction following PCA using Eigen function

2010-05-24 Thread Julia El-Sayed Moustafa
Hi Thomas, Thanks very much for your reply. I used svd and it worked perfectly for my purposes! Thanks again, Julia -- View this message in context: http://r.789695.n4.nabble.com/Data-reconstruction-following-PCA-using-Eigen-function-tp2226535p2229191.html Sent from the R help mailing list

Re: [R] Data reconstruction following PCA using Eigen function

2010-05-22 Thread Thomas Stewart
Looks like you have some numerical precision issues. Why not use the svd function directly? (See below.) -tgs x - read.table( textConnection( Sample1 0.7329881 0.76912670 2.45906143 -0.06411602 1.2427801 0.3785717 2.34508664 1.1043552 -0.1883830 0.6503095 Sample2 -2.0446131

<    4   5   6   7   8   9   10   11   12   13   >