Re: [R] Extract values from multiple lists

2014-12-17 Thread SH
Dear Dennis, David, Jeff, and Denes, Thanks for your helps and comments. The simple one seems good enough for my works. Best, Steve On Wed, Dec 17, 2014 at 5:46 AM, Dénes Tóth wrote: > > Dear Jeff, > > On 12/17/2014 01:46 AM, Jeff Newmiller wrote: > >> You are chasing ghosts of performance pa

Re: [R] Extract values from multiple lists

2014-12-17 Thread Dénes Tóth
Dear Jeff, On 12/17/2014 01:46 AM, Jeff Newmiller wrote: You are chasing ghosts of performance past, Denes. In terms of memory efficiency, yes. In terms of CPU time, there can be significant difference, see below. The data.frame function causes no problems, and if it is used then the OP w

Re: [R] Extract values from multiple lists

2014-12-16 Thread Jeff Newmiller
You are chasing ghosts of performance past, Denes. The data.frame function causes no problems, and if it is used then the OP would not need to presume they know the internal structure of the data frame. See below. (I am using R3.1.2.) a1 <- list(x = rnorm(1e6), y = rnorm(1e6)) a2 <- list(x = rn

Re: [R] Extract values from multiple lists

2014-12-16 Thread Dénes Tóth
On 12/16/2014 06:06 PM, SH wrote: Dear List, I hope this posting is not redundant. I have several list outputs with the same components. I ran a function with three different scenarios below (e.g., scen1, scen2, and scen3,...,scenN). I would like to extract the same components and group the

Re: [R] Extract values from multiple lists

2014-12-16 Thread David L Carlson
inal Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of SH Sent: Tuesday, December 16, 2014 11:06 AM To: r-help Subject: [R] Extract values from multiple lists Dear List, I hope this posting is not redundant. I have several list outputs with the same components. I ran a

[R] Extract values from multiple lists

2014-12-16 Thread SH
Dear List, I hope this posting is not redundant. I have several list outputs with the same components. I ran a function with three different scenarios below (e.g., scen1, scen2, and scen3,...,scenN). I would like to extract the same components and group them as a data frame. For example, pop.i

Re: [R] Extract values from vector and repeat by group

2013-11-18 Thread arun
f$group), length)) shall give you desired vector. Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Benjamin Gillespie > Sent: Sunday, November 17, 2013 3:47 PM > To: r-help@r-project.org > Subje

Re: [R] Extract values from vector and repeat by group

2013-11-18 Thread PIKAL Petr
ilto:r-help-bounces@r- > project.org] On Behalf Of Benjamin Gillespie > Sent: Sunday, November 17, 2013 3:47 PM > To: r-help@r-project.org > Subject: [R] Extract values from vector and repeat by group > > Hi all, > > I hope you can help. > > I have a data frame '

Re: [R] Extract values from vector and repeat by group

2013-11-18 Thread Benjamin Gillespie
November 2013 16:48 To: R help Cc: Berend Hasselman; Benjamin Gillespie Subject: Re: [R] Extract values from vector and repeat by group Hi, ?merge() sometimes change the order. For example: df1 <- df[-12,] df2 <- df1 merge(df1, df1[df1$time == 4, c("group", "var")], by.x

Re: [R] Extract values from vector and repeat by group

2013-11-17 Thread arun
Hi, ?merge() sometimes change the order. For example: df1 <- df[-12,] df2 <- df1 merge(df1, df1[df1$time == 4, c("group", "var")], by.x = "group", by.y = "group", suffixes = c("", "GroupSK0")) In that case, df1$ord1 <- with(df1,order(group,time)) res <- merge(df1, df1[df1$time == 4, c("group",

Re: [R] Extract values from vector and repeat by group

2013-11-17 Thread Berend Hasselman
On 17-11-2013, at 15:47, Benjamin Gillespie wrote: > Hi all, > > I hope you can help. > > I have a data frame 'df': > > group=c(rep(1,8),rep(2,10),rep(3,11)) > var=rnorm(29) > time=c(seq(1,8),seq(1,10),seq(1,11)) > df=data.frame(group,var,time) > > I would like to extract the value from 'var

[R] Extract values from vector and repeat by group

2013-11-17 Thread Benjamin Gillespie
Hi all, I hope you can help. I have a data frame 'df': group=c(rep(1,8),rep(2,10),rep(3,11)) var=rnorm(29) time=c(seq(1,8),seq(1,10),seq(1,11)) df=data.frame(group,var,time) I would like to extract the value from 'var' for each 'group' at 'time'=4 and repeat these extracted values in a new vec

Re: [R] extract values

2013-03-12 Thread Rui Barradas
Hello, I don't understand. Your object is a vector, with a dim attribute, so x[, 1] is meaningless. And all the values are less than 1820: any(x > 1820) # FALSE Given the names attribute of your data, is it the values of x corresponding to names greater than 1820? If so, try y <- as.numer

Re: [R] extract values

2013-03-12 Thread catalin roibu
Thank very much for your help! On 12 March 2013 20:04, Sarah Goslee wrote: > Data in x is never > 1820: > > summary(x) >Min. 1st Qu. MedianMean 3rd Qu.Max. > 0.8465 1.2890 1.5660 1.5710 1.8050 3.4340 > > And your object is a vector: trying to extract the first column with > x

Re: [R] extract values

2013-03-12 Thread Sarah Goslee
Data in x is never > 1820: > summary(x) Min. 1st Qu. MedianMean 3rd Qu.Max. 0.8465 1.2890 1.5660 1.5710 1.8050 3.4340 And your object is a vector: trying to extract the first column with x[,1] is meaningless, because x has no dimensions. > dim(x) NULL It looks to me as if you wa

Re: [R] extract values

2013-03-12 Thread David L Carlson
iversity College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of catalin roibu > Sent: Tuesday, March 12, 2013 12:50 PM > To: r-help@r-project.org > Subject: [R] extract values >

Re: [R] extract values

2013-03-12 Thread jim holtman
First take a look at your data and understand its structure. What you have is a named vector and not a matrix: > str(x) Named num [1:213] 2.58 1.73 3.43 2.19 1.93 ... - attr(*, "names")= chr [1:213] "1799" "1800" "1801" "1802" ... > x1 <- x[names(x) > '1820'] > x1 1821 1822 1823 1824

Re: [R] extract values

2013-03-12 Thread arun
uesday, March 12, 2013 1:50 PM Subject: [R] extract values Hello all! I have a problem to extract values greater that for example 1820. I try this code: x[x[,1]>1820,]->x1 Please help me! Thank you! The data structure is: structure(c(2.576, 1.728, 3.434, 2.187, 1.928, 1.886, 1.2425, 1.23, 1

[R] extract values

2013-03-12 Thread catalin roibu
Hello all! I have a problem to extract values greater that for example 1820. I try this code: x[x[,1]>1820,]->x1 Please help me! Thank you! The data structure is: structure(c(2.576, 1.728, 3.434, 2.187, 1.928, 1.886, 1.2425, 1.23, 1.075, 1.1785, 1.186, 1.165, 1.732, 1.517, 1.4095, 1.074, 1.618, 1

Re: [R] extract values from summary of function indval of the package labdsv

2012-07-24 Thread Rui Barradas
Hello, There's a general purpose way to get the members of the object returned by summary functions. What you have tried unsuccessfully is a particular case of that method: assign summary to a variable and see what's int it. si <- summary(indication3) class(si) # see the class of summary ob

[R] extract values from summary of function indval of the package labdsv

2012-07-23 Thread katse
Hi everybody, I am doing Indicator species analysis using the function "indval" from the package "labdsv". For further analysis I need the values "Number of Significant Indicators" and "Sum of Indicator Values" that is calculated from the summary on my indval object. indication3<-indval(Veg,cav

Re: [R] extract values ​​for the dates and a new column

2012-03-14 Thread Jeff Newmiller
The error seems clear enough to me... you are trying to mix vectors of different lengths where one length is not a multiple of the other length. Your discussion is pretty confused though, referring to possible data frames x, x.sub, x.res and Dataset. You might benefit from reviewing ?str and ?dp

[R] extract values ​​for the dates and a new column

2012-03-14 Thread RMSOPS
#add column Start Hello Good Afternoon I am trying to create a new column in the data frame, the target is based on a column of dates to extract a value of life and add a new column to data frame f<-x.res$T-x.res$duration Dataset$StarEvent<-(as.character.POSIXt(f)) x.sub$T is: [1] "2006-10-31

Re: [R] Extract values from a data frame

2011-08-12 Thread Lali
Hi Ista, Thanks for your suggestion, I am still trying to wrap my head around the functions you used, as I am not familiar with any of them, but it works perfectly! I do want to understand the code, if you don't mind I would like to ask a few questions In this line: dfm <- melt(df[c(1, 2, 5, 8)],

Re: [R] Extract values from a data frame

2011-08-12 Thread Ista Zahn
On Fri, Aug 12, 2011 at 3:54 AM, Lali wrote: > Hi Ista, > Thanks for your suggestion, I am still trying to wrap my head around the > functions you used, as I am not familiar with any of them, but it works > perfectly! > I do want to understand the code, if you don't mind I would like to ask a > fe

Re: [R] Extract values from a data frame

2011-08-11 Thread Ista Zahn
Hi Laura, On Thu, Aug 11, 2011 at 7:01 AM, Lali wrote: > Hi everyone, > I have a data frame that looks *sort of* like this: > > name <- letters[1:5] > signal.1 <- c("12", "bad signal", "noise", "10", "X") > length.signal.1 <- 5:9 > intensity.signal.1 <- 3:7 > signal.2 <- c("13", "noise", "19.2",

[R] Extract values from a data frame

2011-08-11 Thread Lali
Hi everyone, I have a data frame that looks *sort of* like this: name <- letters[1:5] signal.1 <- c("12", "bad signal", "noise", "10", "X") length.signal.1 <- 5:9 intensity.signal.1 <- 3:7 signal.2 <- c("13", "noise", "19.2", "X", "V") length.signal.2 <- 2:6 intensity.signal.2 <- 1:5 signal.3 <- c

Re: [R] Extract values from data frame in R

2010-08-09 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Erik Iverson > Sent: Sunday, August 08, 2010 11:27 PM > To: Alexander Eggel > Cc: r-help@r-project.org > Subject: Re: [R] Extract values from data frame in

Re: [R] Extract values from data frame in R

2010-08-08 Thread David Winsemius
On Aug 9, 2010, at 2:16 AM, Alexander Eggel wrote: Using R, I would like to find out which Samples (S1, S2, S3, S4, S5) fulfill the following criteria:contain minimally one value (x, y or z) bigger than 4. Any ideas? Thanks, Alex. data Sample xy z 1S1 -0.3

Re: [R] Extract values from data frame in R

2010-08-08 Thread Erik Iverson
On 08/09/2010 01:16 AM, Alexander Eggel wrote: Using R, I would like to find out which Samples (S1, S2, S3, S4, S5) fulfill the following criteria:contain minimally one value (x, y or z) bigger than 4. Any ideas? Thanks, Alex. data Sample xy z 1S1 -0.35.3

[R] Extract values from data frame in R

2010-08-08 Thread Alexander Eggel
Using R, I would like to find out which Samples (S1, S2, S3, S4, S5) fulfill the following criteria:contain minimally one value (x, y or z) bigger than 4. Any ideas? Thanks, Alex. > data Sample xy z 1S1 -0.35.32.5 2S20.40.2 -1.2 3S3

Re: [R] Extract values of a two-factor table and duplicate them into a three-factor table

2010-03-10 Thread Ista Zahn
Hi Melanie, I think you just need merge(TABLE1, TABLE2) see ?merge for details. -Ista On Wed, Mar 10, 2010 at 12:47 AM, Melanie HAMEL wrote: > Dear all, > > I would like to solve a trivial problem (I guess it is) but can't find the > right way. Maybe someone can help me ? > > I've got a table

[R] Extract values of a two-factor table and duplicate them into a three-factor table

2010-03-09 Thread Melanie HAMEL
Dear all, I would like to solve a trivial problem (I guess it is) but can't find the right way. Maybe someone can help me ? I've got a table with two factors (station = station ID, buffer = buffer size in meters) and a value for each unique combination of those two factors (S = number of habit

Re: [R] Extract values from a predict() result... how?

2010-02-15 Thread David Winsemius
On Feb 15, 2010, at 4:35 PM, Jay wrote: Hello, silly question I suppose, but somehow I can't manage to extract the probabilities from a glm.predict() result: str(res) Named num [1:9] 0.00814 0.01877 0.025 0.02941 0.03563 ... - attr(*, "names")= chr [1:9] "1" "2" "3" "4" ... I got from: #

[R] Extract values from a predict() result... how?

2010-02-15 Thread Jay
Hello, silly question I suppose, but somehow I can't manage to extract the probabilities from a glm.predict() result: > str(res) Named num [1:9] 0.00814 0.01877 0.025 0.02941 0.03563 ... - attr(*, "names")= chr [1:9] "1" "2" "3" "4" ... I got from: # A Gamma example, from McCullagh & Nelder (

Re: [R] extract values from summary

2009-04-07 Thread Dieter Menne
Felipe Carrillo yahoo.com> writes: > > # How can I extract the 'Forecasts' from the 'summary(predicted)' from the example below? .. > # I would like to extract the three predicted values and > # make a line plot with the 'Point Forecast' values only. > # I tried str(predicted) and names(pred

[R] extract values from summary

2009-04-06 Thread Felipe Carrillo
Hi: # How can I extract the 'Forecasts' from the 'summary(predicted)' from the example below? library(forecast) weightData <- data.frame(weight = c(2.1,2.4,2.8,3.6,4.1,5.2,6.3),week= 1:7) weight <- as.numeric(weightData$weight) predicted <- forecast(weight,h=3,level=95) # see the predicted sum

Re: [R] Extract values based on indexes without looping?

2008-12-23 Thread Charles C. Berry
On Tue, 23 Dec 2008, Sean Zhang wrote: Dear R-Helpers: I am a entry level user of R. You need to read An Introduction to R particularly this section: 2.7 Index vectors; selecting and modifying subsets of a data set ... 2. A vector of positive integral qua

Re: [R] Extract values based on indexes without looping?

2008-12-23 Thread Jorge Ivan Velez
How about this? value.vec[which.vec] HTH, Jorge On Tue, Dec 23, 2008 at 9:52 PM, Sean Zhang wrote: > Dear R-Helpers: > > I am a entry level user of R. > > Have the following question. Many thanks in advance. > > > # value.vec stores values > value.vec <- c('a','b','c') > # which.vec stores t

Re: [R] Extract values based on indexes without looping?

2008-12-23 Thread David Winsemius
> sapply(which.vec, function(x){ value.vec[x] } ) [1] "c" "b" "b" "a" On Dec 23, 2008, at 9:52 PM, Sean Zhang wrote: # value.vec stores values value.vec <- c('a','b','c') # which.vec stores the locations/indexs of values in value.vec. which.vec <- c(3, 2, 2, 1) # How can I obtain the followin

[R] Extract values based on indexes without looping?

2008-12-23 Thread Sean Zhang
Dear R-Helpers: I am a entry level user of R. Have the following question. Many thanks in advance. # value.vec stores values value.vec <- c('a','b','c') # which.vec stores the locations/indexs of values in value.vec. which.vec <- c(3, 2, 2, 1) # How can I obtain the following vector based on t

Re: [R] Extract values from a named array

2008-04-07 Thread Gang Chen
Thanks a lot for the suggestions! Gang On 4/7/08, Uwe Ligges <[EMAIL PROTECTED]> wrote: > > > Gang Chen wrote: > > > Sorry for this dumb question. Suppose I have a named array ww defined as > > > > ww <- 1:5 > > names(ww) <- c("a", "b", "c", "d", "e") > > > > How can I extract the whole array of

Re: [R] Extract values from a named array

2008-04-07 Thread Uwe Ligges
Gang Chen wrote: > Sorry for this dumb question. Suppose I have a named array ww defined as > > ww <- 1:5 > names(ww) <- c("a", "b", "c", "d", "e") > > How can I extract the whole array of numbers without the names? > ww[1:5] does not work while ww[[1]] can only extract one number at a > time.

Re: [R] Extract values from a named array

2008-04-07 Thread Henrique Dallazuanna
Try: as.numeric(ww) On Mon, Apr 7, 2008 at 1:33 PM, Gang Chen <[EMAIL PROTECTED]> wrote: > Sorry for this dumb question. Suppose I have a named array ww defined as > > ww <- 1:5 > names(ww) <- c("a", "b", "c", "d", "e") > > How can I extract the whole array of numbers without the names? > ww[1:5

[R] Extract values from a named array

2008-04-07 Thread Gang Chen
Sorry for this dumb question. Suppose I have a named array ww defined as ww <- 1:5 names(ww) <- c("a", "b", "c", "d", "e") How can I extract the whole array of numbers without the names? ww[1:5] does not work while ww[[1]] can only extract one number at a time. Thanks, Gang