Re: [R] Data Manipulation

2010-09-10 Thread dfong
I'm actually importing it from a CSV, so I already have that in a table. But i Can't make a graph with text. I assume I need to do some counting in order to draw the graph? Any example of this? thanks -- View this message in context: http://r.789695.n4.nabble.com/Data-Manipulation-tp2534662p253

Re: [R] Data Manipulation

2010-09-10 Thread Joshua Wiley
Hi, Look at the table() function. Here is an example with your data: dat <- read.table(textConnection(" Study A A B B B A C C D"), header = TRUE) closeAllConnections() table(dat) Hope that helps, Josh On Fri, Sep 10, 2010 at 8:53 AM, dfong wrote: > > Hi, > > I just started using R and nee

[R] Data Manipulation

2010-09-10 Thread dfong
Hi, I just started using R and need some guidance. I need to create a time series chart in R, but the problem is the data is not numeric. The data is in the following format Study A A B B B A C C D Then there is also another column with dates. How can I manipulate this in order to have so

Re: [R] Data Manipulations and SQL

2010-08-26 Thread Gabor Grothendieck
On Thu, Aug 26, 2010 at 1:18 PM, stephenb 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 it I would like t

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 y

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 in

[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

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

[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, Marci

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 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)      NA      

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)),

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 wrote: > On Sun, Aug 8, 2010 at 11:21 AM, steven mosher 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 da

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 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 every observation

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 wrote: > On Sun, Aug 8, 2010 at 2:01 AM, steven mosher >

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 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 ts I had to plow th

Re: [R] Data frame reordering to time series

2010-08-07 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 p

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 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 =1),1991,1993,1994,seq(1991,1995,by=1)) > Value

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) Values<-c(12,14,34,21,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 wrote: > On Sat, Aug 7, 2010 at 4:49 PM, steven mos

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 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)) >  Years<-c(seq(19

[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)) Values2<-c(12

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 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] < ml-node+2307936-1777222343-309...@n4.nabble.com > wrote: > Hi, > > I am tryin

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.com > wrote: > Hi, > > I am very new to R so these questions may seem simple! > >

[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 recre

Re: [R] Data Handling

2010-07-30 Thread Gabor Grothendieck
On Fri, Jul 30, 2010 at 9:02 AM, Lily_stats 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.xts > However, I get an error : > > Error in as.POSIXlt.character(

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.xtshttp://r.789695.n4.nabble.com/Data-Handling-tp2307770p2307936.html Sent from the R help mailing list archive at Nabble.com.

[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 i

Re: [R] data arranged by p-values

2010-07-26 Thread ONKELINX, Thierry
John Tukey > -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 > > > Idcat1lo

[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

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, Kingsf

Re: [R] data from SpatialGridDataFrame

2010-07-20 Thread chris howden
-boun...@r-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 clas

[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 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 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 p

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 d

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 wrote: > > On Jul 8, 2010, at 10:33 PM, Erik Iverson wrote: > > >> I have a data frame: >>> id url >>> urlType >>

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 variable

[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 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 www.yahoo.com>1 2 2 www.google.com/?search=

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 1 2 2 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: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 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 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 y

[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){ fo

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

2010-07-07 Thread Greg Snow
t: Sunday, July 04, 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 ca

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 th

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: levels(PR_SUMMARY$Bucket)=c("

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 te

[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: http://r.789695.n4.nabble.com/Data-Labels

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,

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, Do

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 se

[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 <- data.f

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 t

[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

[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

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-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 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,"

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 >

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 o

[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("t

Re: [R] data frame manipulation with zero rows

2010-06-02 Thread arnaud Gaboury
n Ripley > Subject: Re: [R] data frame manipulation with zero rows > > Hi Arnaud, > > I've added this case to the set of test cases in plyr and it will be > fixed in the next version. > > Hadley > > On Tue, Jun 1, 2010 at 2:33 PM, arnaud Gaboury > wrote:

Re: [R] data frame manipulation with zero rows

2010-06-02 Thread Hadley Wickham
(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.o

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
rnaud Gaboury > Cc: 'Prof 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

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

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread Prof Brian Ripley
hat that is or what it should do for the case 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 manip

Re: [R] data frame manipulation ddply

2010-06-01 Thread arnaud Gaboury
to aggregate > -Original Message- > From: Patrick Hausmann [mailto:patrick.hausm...@uni-bremen.de] > Sent: Tuesday, June 01, 2010 11:38 AM > To: arnaud Gaboury > Subject: Re: [R] data frame manipulation ddply > > Hi Arnaud, > > maybe "agg

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread Peter Ehlers
ilto: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, arnaud Gaboury wrote: Dear group, Here is the kind of data.frame I obtain every day with my function : futures<- structure(list(DESCRIPT

[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

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
0 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 <

[R] data frame manipulation with zero rows

2010-05-31 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 N

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Don MacQueen
If you only need a single variable (in this case value), and just want to refer to it by the "key", there are other options. value <- rnorm(6) names(value) <- format(seq(0.5,3,0.5)) value['1.5'] But do watch out for numerical precision in the output of seq() if your vector of values

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Alan Lue
...@r-project.org wrote: >> >> Message: 40 >> Date: Sun, 30 May 2010 09:24:22 +0100 >> From: Patrick Burns >> To:r-help@r-project.org,alan@gmail.com >> Subject: Re: [R] Data Frame as Hash Table >> Message-ID:<4c0220b6.7090...@pburns.seanet.com> >>

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Marshall Feldman
t.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

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 1

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Barry Rowlingson
On Sun, May 30, 2010 at 9:03 AM, 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))) >  key        value > 1 0.5 -1.118665122 > 2 1.0  0.465122921 > 3 1.5 -0.52923921

[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 The

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 time

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 ab

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 http://www.R

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)

[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", "HLH","HLH_C

Re: [R] Methods to explore R data structures

2010-05-27 Thread Greg Snow
age- > From: 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 structu

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 a

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

2010-05-27 Thread arnaud Gaboury
..@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 to apply the switch command on every entry of the

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

2010-05-27 Thread arnaud Gaboury
, 2L, 1L), Price = c("15.2500", "368.", "368.5000"), Net.Charges..sum. = c(4.01, -8.64, -4.32)), .Names = c("Trade.Status", "Instrument.Long.Name", "Delivery.Prompt.Date", "Buy.Sell..Cleared.", "Volume", "Price"

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

2010-05-27 Thread Joris Meys
)],switch,Sell="Buy",Buy="Sell") > > > tradenews > Sell > "Buy" > > Not really what I want !! > > From: Joris Meys [mailto:jorism...@gmail.com] > Sent: Thursday, May 27, 2010 10:38 AM > To: arnaud Gaboury > Cc: r-help@r-projec

[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
t; NULL > > $Instrument.Long.Name > NULL > > $Delivery.Prompt.Date > NULL > > $Buy.Sell..Cleared. > [1] "Buy" > > $Volume > [1] "Buy" > > $Price > NULL > > $Net.Charges..sum. > NULL > > That's certainly not what I w

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

2010-05-27 Thread arnaud Gaboury
[1] "Buy" $Volume [1] "Buy" $Price 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 manipulat

[R] data frame change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
] "Buy" $Volume [1] "Buy" $Price 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 el

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

2010-05-26 Thread arnaud Gaboury
PM To: 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

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

2010-05-26 Thread Joris Meys
e any way to combine if() and switch() in one line? In my case, > 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 &

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 P

[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",

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 arc

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,

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