Schwab,Wilhelm K
2010-Oct-07 21:30 UTC
[R] Deleting observations - can't see the data after that
Hello all, I am loading a data frame, fitting a model, getting diagnostic plots and they are flagging a couple of observations as problematic. Fair enough, and I want re-fit without them. After I delete an offending row (identified by one of the diagnostic plots), something like data = data[-3,]; then R will no longer print the contents of the data frame; it tells me it is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame like it does before the deletion. Is there a way to get around that, either using a different deletion technique or another function? print(data) and show(data) are not helping. Ultimately, I am trying to go through a couple of iterations of find pathologic points, delete and re-fit. In this case I could guess at what is wrong and probably be correct, but I want to follow the clues as a learning exercise. Once that is complete, I plan to plot everything with the deleted points emphasized. Bill
jim holtman
2010-Oct-07 21:43 UTC
[R] Deleting observations - can't see the data after that
Can you give a reproducible sample of data. Exactly what commands are you executing when it doesn't print? What does 'str(data)' show? This works fine for me:> x <- data.frame(a=1:5, b=1:5) > xa b 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5> x <- x[-3,] > xa b 1 1 1 2 2 2 4 4 4 5 5 5> str(x)'data.frame': 4 obs. of 2 variables: $ a: int 1 2 4 5 $ b: int 1 2 4 5>On Thu, Oct 7, 2010 at 5:30 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote:> Hello all, > > I am loading a data frame, fitting a model, getting diagnostic plots and they are flagging a couple of observations as problematic. ?Fair enough, and I want re-fit without them. > > After I delete an offending row (identified by one of the diagnostic plots), something like > > ? ?data = data[-3,]; > > then R will no longer print the contents of the data frame; it tells me it is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame like it does before the deletion. ?Is there a way to get around that, either using a different deletion technique or another function? ?print(data) and show(data) are not helping. > > Ultimately, ?I am trying to go through a couple of iterations of find pathologic points, delete and re-fit. ?In this case I could guess at what is wrong and probably be correct, but I want to follow the clues as a learning exercise. ?Once that is complete, I plan to plot everything with the deleted points emphasized. > > Bill > > ______________________________________________ > R-help at 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, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Joshua Wiley
2010-Oct-07 21:45 UTC
[R] Deleting observations - can't see the data after that
Hi Bill, Several things come to mind. First, try naming your data frame something besides a function name (data() is also a function). Second, have you attached the data frame? Using: data = data[-3, ] worked fine for me when I made up some data. Perhaps you can create a minimal and reproducible example? You might also send us the results of: sessionInfo() ls() search() Cheers, Josh On Thu, Oct 7, 2010 at 2:30 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote:> Hello all, > > I am loading a data frame, fitting a model, getting diagnostic plots and they are flagging a couple of observations as problematic. ?Fair enough, and I want re-fit without them. > > After I delete an offending row (identified by one of the diagnostic plots), something like > > ? ?data = data[-3,]; > > then R will no longer print the contents of the data frame; it tells me it is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame like it does before the deletion. ?Is there a way to get around that, either using a different deletion technique or another function? ?print(data) and show(data) are not helping. > > Ultimately, ?I am trying to go through a couple of iterations of find pathologic points, delete and re-fit. ?In this case I could guess at what is wrong and probably be correct, but I want to follow the clues as a learning exercise. ?Once that is complete, I plan to plot everything with the deleted points emphasized. > > Bill > > ______________________________________________ > R-help at 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, self-contained, reproducible code. >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
Schwab,Wilhelm K
2010-Oct-07 23:13 UTC
[R] Deleting observations - can't see the data after that
Josh, Jim, Thanks for responding. So far, it looks like my use of the name data was the problem - that could have taken some time to find. I typically do not attach frames (and did not here), so I end up with lots of this$that in my code. If it gives me any more trouble, I will indeed post an example. Thanks! Bill -----Original Message----- From: Joshua Wiley [mailto:jwiley.psych at gmail.com] Sent: Thursday, October 07, 2010 4:46 PM To: Schwab,Wilhelm K Cc: r-help at r-project.org Subject: Re: [R] Deleting observations - can't see the data after that Hi Bill, Several things come to mind. First, try naming your data frame something besides a function name (data() is also a function). Second, have you attached the data frame? Using: data = data[-3, ] worked fine for me when I made up some data. Perhaps you can create a minimal and reproducible example? You might also send us the results of: sessionInfo() ls() search() Cheers, Josh On Thu, Oct 7, 2010 at 2:30 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote:> Hello all, > > I am loading a data frame, fitting a model, getting diagnostic plots and they are flagging a couple of observations as problematic. ?Fair enough, and I want re-fit without them. > > After I delete an offending row (identified by one of the diagnostic > plots), something like > > ? ?data = data[-3,]; > > then R will no longer print the contents of the data frame; it tells me it is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame like it does before the deletion. ?Is there a way to get around that, either using a different deletion technique or another function? ?print(data) and show(data) are not helping. > > Ultimately, ?I am trying to go through a couple of iterations of find pathologic points, delete and re-fit. ?In this case I could guess at what is wrong and probably be correct, but I want to follow the clues as a learning exercise. ?Once that is complete, I plan to plot everything with the deleted points emphasized. > > Bill > > ______________________________________________ > R-help at 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, self-contained, reproducible code. >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
Schwab,Wilhelm K
2010-Oct-08 01:22 UTC
[R] Deleting observations - can't see the data after that
Josh, Unfortunately, I created a lot of lines after getting it working, so there was no getting back to it, and right now I can't reproduce it - sorry. If I use one Gnome shell and exit R and re-run it, am I clearing everything? I assume so, but if not, that might be relevant. AFAIK, I do not save and re-use workspaces. Bill -----Original Message----- From: Joshua Wiley [mailto:jwiley.psych at gmail.com] Sent: Thursday, October 07, 2010 8:15 PM To: Schwab,Wilhelm K Subject: Re: [R] Deleting observations - can't see the data after that I mostly meant look at whatever past commands you had typed using the "up" arrow (only useful for a very limited number). I am sure this has already taken enough of your time, and since its working for you now, I would not worry about looking into it further. I know that I have seen something in the past that produced a short output about an object exactly like what you described (data frame with n rows and m columns), but I cannot remember what it was for the life of me. On Thu, Oct 7, 2010 at 5:32 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote:> Josh, > > Sounds good. ?Where would I find the history? ?I'm working on Linux (Ubuntu 9.10, R 2.9.2); if it's history(), we're out of luck. ?You guys are allowed to hound; whether or not I can create a suitable example is another story. > > As far as what was happening, a summary of the object makes a lot of sense, and that's pretty much what it was. ?Something like "a data frame with 16 rows and 5 columns" or there abouts. > > Bill > > > > -----Original Message----- > From: Joshua Wiley [mailto:jwiley.psych at gmail.com] > Sent: Thursday, October 07, 2010 7:22 PM > To: Schwab,Wilhelm K > Cc: r-help at r-project.org > Subject: Re: [R] Deleting observations - can't see the data after that > > Dear Bill, > > We hound because we care---through repeated painful experiences, I have developed an avoidance to using function names for my functions/objects (and against irons near my fingers...but that is another story). > > If you still have the output from R when you attempted to print your data frame, I would be interested in seeing it. ?It almost sounds like some sort of summary of the object, rather than the object itself (if that makes any sense). ?Maybe its still in your history? > > As a side note, depending on the situation, you might get some mileage > out of with() to lessen the this$that burden. ?If you didn't know > about it, hopefully it saves you at least a bit of time :) > > Here's to a better next two days than your last, > > Cheers, > > Josh > > On Thu, Oct 7, 2010 at 5:16 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote: >> First, no lasting hard feelings - I've had two days of people riding me over minutia like you can't imagine. >> >> When you put this in the context of a possible bug, I'll see what I can turn up for you. ?FWIW, I think it just the variable name. >> >> Bill >> >> >> >> >> >> -----Original Message----- >> From: Peter Ehlers [mailto:ehlers at ucalgary.ca] >> Sent: Thursday, October 07, 2010 7:10 PM >> To: Schwab,Wilhelm K >> Cc: r-help at r-project.org >> Subject: Re: [R] Deleting observations - can't see the data after >> that >> >> On 2010-10-07 17:58, Schwab,Wilhelm K wrote: >>> Foolish? ?Try convenient. ?Can't win for losing today. ?Anyway, I most certainly did not make the mistake you suggest, though some other mistake is possible. ?I never said it printed nothing; I was very explicit that it described it as a data frame with the correct number of rows and columns; it simply would not print the data. >> >> I didn't mean to be critical. I'm just trying to understand how you managed to get to the stage where R will show you that 'data' "is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame". >> >> This should be reproducible. Who knows, you may have found a bug that should be fixed. So what was the precise message from R when it told you that it had the dataframe but wouldn't print it. Can you make up a reproducible example? >> >> ? -Peter Ehlers >> >>> >>> >>> >>> >>> >>> -----Original Message----- >>> From: Peter Ehlers [mailto:ehlers at ucalgary.ca] >>> Sent: Thursday, October 07, 2010 6:53 PM >>> To: Schwab,Wilhelm K >>> Cc: r-help at r-project.org >>> Subject: Re: [R] Deleting observations - can't see the data after >>> that >>> >>> On 2010-10-07 17:13, Schwab,Wilhelm K wrote: >>>> Josh, Jim, >>>> >>>> Thanks for responding. ?So far, it looks like my use of the name data was the problem - that could have taken some time to find. ?I typically do not attach frames (and did not here), so I end up with lots of this$that in my code. >>>> >>> >>> While I think it's foolish to call your data.frame 'data', I really >>> doubt that that's the cause of your troubles. More likely you did >>> something else afterwards that caused your data to be 'unprintable'. >>> Or perhaps you goofed up the subsetting with something like >>> >>> ? ?data = data(-3,); >>> >>> But I would have expected R to print _some_ thing, if only an error message. >>> >>> Anyway, I'm glad the problem is resolved (for now). >>> >>> ? ? -Peter Ehlers >>> >>> >>>> If it gives me any more trouble, I will indeed post an example. >>>> >>>> Thanks! >>>> >>>> Bill >>>> >>>> >>>> >>>> -----Original Message----- >>>> From: Joshua Wiley [mailto:jwiley.psych at gmail.com] >>>> Sent: Thursday, October 07, 2010 4:46 PM >>>> To: Schwab,Wilhelm K >>>> Cc: r-help at r-project.org >>>> Subject: Re: [R] Deleting observations - can't see the data after >>>> that >>>> >>>> Hi Bill, >>>> >>>> Several things come to mind. ?First, try naming your data frame something besides a function name (data() is also a function). >>>> Second, have you attached the data frame? >>>> >>>> Using: data = data[-3, ] worked fine for me when I made up some data. >>>> Perhaps you can create a minimal and reproducible example? >>>> >>>> You might also send us the results of: >>>> >>>> sessionInfo() >>>> ls() >>>> search() >>>> >>>> Cheers, >>>> >>>> Josh >>>> >>>> On Thu, Oct 7, 2010 at 2:30 PM, Schwab,Wilhelm K<bschwab at anest.ufl.edu> ? wrote: >>>>> Hello all, >>>>> >>>>> I am loading a data frame, fitting a model, getting diagnostic plots and they are flagging a couple of observations as problematic. ?Fair enough, and I want re-fit without them. >>>>> >>>>> After I delete an offending row (identified by one of the >>>>> diagnostic plots), something like >>>>> >>>>> ? ? ?data = data[-3,]; >>>>> >>>>> then R will no longer print the contents of the data frame; it tells me it is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame like it does before the deletion. ?Is there a way to get around that, either using a different deletion technique or another function? ?print(data) and show(data) are not helping. >>>>> >>>>> Ultimately, ?I am trying to go through a couple of iterations of find pathologic points, delete and re-fit. ?In this case I could guess at what is wrong and probably be correct, but I want to follow the clues as a learning exercise. ?Once that is complete, I plan to plot everything with the deleted points emphasized. >>>>> >>>>> Bill >>>>> >>>>> ______________________________________________ >>>>> R-help at 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, self-contained, reproducible code. >>>>> >>>> >>>> >>>> >>>> -- >>>> Joshua Wiley >>>> Ph.D. Student, Health Psychology >>>> University of California, Los Angeles http://www.joshuawiley.com/ >>>> >>>> ______________________________________________ >>>> R-help at 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, self-contained, reproducible code. >>> >> >> ______________________________________________ >> R-help at 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, self-contained, reproducible code. >> > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > University of California, Los Angeles > http://www.joshuawiley.com/ >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
Schwab,Wilhelm K
2010-Oct-08 14:20 UTC
[R] Deleting observations - can't see the data after that
Josh, How about the direct approach: grep or otherwise search the source? If you can guess the form of a printf()-like statement, then it might be easy to find. More likely, one would have to overlay results of a few different searches. Maybe someone who is actively working on the code will see this and stumble on it?? The idea is simply that one might be able to work backwards from the behavior (which we have both observed) to possible causes and give a little thought to possible absorbing states that maybe should not exist. Bill ________________________________________ From: Joshua Wiley [jwiley.psych at gmail.com] Sent: Thursday, October 07, 2010 9:14 PM To: Schwab,Wilhelm K Subject: Re: [R] Deleting observations - can't see the data after that I mostly meant look at whatever past commands you had typed using the "up" arrow (only useful for a very limited number). I am sure this has already taken enough of your time, and since its working for you now, I would not worry about looking into it further. I know that I have seen something in the past that produced a short output about an object exactly like what you described (data frame with n rows and m columns), but I cannot remember what it was for the life of me. On Thu, Oct 7, 2010 at 5:32 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote:> Josh, > > Sounds good. Where would I find the history? I'm working on Linux (Ubuntu 9.10, R 2.9.2); if it's history(), we're out of luck. You guys are allowed to hound; whether or not I can create a suitable example is another story. > > As far as what was happening, a summary of the object makes a lot of sense, and that's pretty much what it was. Something like "a data frame with 16 rows and 5 columns" or there abouts. > > Bill > > > > -----Original Message----- > From: Joshua Wiley [mailto:jwiley.psych at gmail.com] > Sent: Thursday, October 07, 2010 7:22 PM > To: Schwab,Wilhelm K > Cc: r-help at r-project.org > Subject: Re: [R] Deleting observations - can't see the data after that > > Dear Bill, > > We hound because we care---through repeated painful experiences, I have developed an avoidance to using function names for my functions/objects (and against irons near my fingers...but that is another story). > > If you still have the output from R when you attempted to print your data frame, I would be interested in seeing it. It almost sounds like some sort of summary of the object, rather than the object itself (if that makes any sense). Maybe its still in your history? > > As a side note, depending on the situation, you might get some mileage out of with() to lessen the this$that burden. If you didn't know about it, hopefully it saves you at least a bit of time :) > > Here's to a better next two days than your last, > > Cheers, > > Josh > > On Thu, Oct 7, 2010 at 5:16 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote: >> First, no lasting hard feelings - I've had two days of people riding me over minutia like you can't imagine. >> >> When you put this in the context of a possible bug, I'll see what I can turn up for you. FWIW, I think it just the variable name. >> >> Bill >> >> >> >> >> >> -----Original Message----- >> From: Peter Ehlers [mailto:ehlers at ucalgary.ca] >> Sent: Thursday, October 07, 2010 7:10 PM >> To: Schwab,Wilhelm K >> Cc: r-help at r-project.org >> Subject: Re: [R] Deleting observations - can't see the data after that >> >> On 2010-10-07 17:58, Schwab,Wilhelm K wrote: >>> Foolish? Try convenient. Can't win for losing today. Anyway, I most certainly did not make the mistake you suggest, though some other mistake is possible. I never said it printed nothing; I was very explicit that it described it as a data frame with the correct number of rows and columns; it simply would not print the data. >> >> I didn't mean to be critical. I'm just trying to understand how you managed to get to the stage where R will show you that 'data' "is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame". >> >> This should be reproducible. Who knows, you may have found a bug that should be fixed. So what was the precise message from R when it told you that it had the dataframe but wouldn't print it. Can you make up a reproducible example? >> >> -Peter Ehlers >> >>> >>> >>> >>> >>> >>> -----Original Message----- >>> From: Peter Ehlers [mailto:ehlers at ucalgary.ca] >>> Sent: Thursday, October 07, 2010 6:53 PM >>> To: Schwab,Wilhelm K >>> Cc: r-help at r-project.org >>> Subject: Re: [R] Deleting observations - can't see the data after >>> that >>> >>> On 2010-10-07 17:13, Schwab,Wilhelm K wrote: >>>> Josh, Jim, >>>> >>>> Thanks for responding. So far, it looks like my use of the name data was the problem - that could have taken some time to find. I typically do not attach frames (and did not here), so I end up with lots of this$that in my code. >>>> >>> >>> While I think it's foolish to call your data.frame 'data', I really >>> doubt that that's the cause of your troubles. More likely you did >>> something else afterwards that caused your data to be 'unprintable'. >>> Or perhaps you goofed up the subsetting with something like >>> >>> data = data(-3,); >>> >>> But I would have expected R to print _some_ thing, if only an error message. >>> >>> Anyway, I'm glad the problem is resolved (for now). >>> >>> -Peter Ehlers >>> >>> >>>> If it gives me any more trouble, I will indeed post an example. >>>> >>>> Thanks! >>>> >>>> Bill >>>> >>>> >>>> >>>> -----Original Message----- >>>> From: Joshua Wiley [mailto:jwiley.psych at gmail.com] >>>> Sent: Thursday, October 07, 2010 4:46 PM >>>> To: Schwab,Wilhelm K >>>> Cc: r-help at r-project.org >>>> Subject: Re: [R] Deleting observations - can't see the data after >>>> that >>>> >>>> Hi Bill, >>>> >>>> Several things come to mind. First, try naming your data frame something besides a function name (data() is also a function). >>>> Second, have you attached the data frame? >>>> >>>> Using: data = data[-3, ] worked fine for me when I made up some data. >>>> Perhaps you can create a minimal and reproducible example? >>>> >>>> You might also send us the results of: >>>> >>>> sessionInfo() >>>> ls() >>>> search() >>>> >>>> Cheers, >>>> >>>> Josh >>>> >>>> On Thu, Oct 7, 2010 at 2:30 PM, Schwab,Wilhelm K<bschwab at anest.ufl.edu> wrote: >>>>> Hello all, >>>>> >>>>> I am loading a data frame, fitting a model, getting diagnostic plots and they are flagging a couple of observations as problematic. Fair enough, and I want re-fit without them. >>>>> >>>>> After I delete an offending row (identified by one of the >>>>> diagnostic plots), something like >>>>> >>>>> data = data[-3,]; >>>>> >>>>> then R will no longer print the contents of the data frame; it tells me it is a data frame with specific (correct) number of rows and columns, but won't show me what remains in the frame like it does before the deletion. Is there a way to get around that, either using a different deletion technique or another function? print(data) and show(data) are not helping. >>>>> >>>>> Ultimately, I am trying to go through a couple of iterations of find pathologic points, delete and re-fit. In this case I could guess at what is wrong and probably be correct, but I want to follow the clues as a learning exercise. Once that is complete, I plan to plot everything with the deleted points emphasized. >>>>> >>>>> Bill >>>>> >>>>> ______________________________________________ >>>>> R-help at 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, self-contained, reproducible code. >>>>> >>>> >>>> >>>> >>>> -- >>>> Joshua Wiley >>>> Ph.D. Student, Health Psychology >>>> University of California, Los Angeles http://www.joshuawiley.com/ >>>> >>>> ______________________________________________ >>>> R-help at 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, self-contained, reproducible code. >>> >> >> ______________________________________________ >> R-help at 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, self-contained, reproducible code. >> > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > University of California, Los Angeles > http://www.joshuawiley.com/ >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
Hi, It seems that the files did not make it through the mailer. Perhaps it didn't like my extensions. I have now attached the files as .txt's as well as copied in the contents of each file: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: AllPredictedValues.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101018/1fc08e15/attachment.txt> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: MaxGrowth.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101018/1fc08e15/attachment-0001.txt> -------------- next part -------------- MaxGrowth.txt: list(4L, 3L, 4L) AllPredictedValues.txt list(list(structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L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L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L), .Label = c("0", "1", "2"), class = "factor"), structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L), .Label = c("0", "1", "2"), class = "factor")), list( structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", "1", "2"), class = "factor"), structure(c(3L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 2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L, 3L, 3L, 3L, 1L, 3L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 1L, 1L, 2L, 1L, 1L, 3L, 1L, 3L, 3L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 2L), .Label = c("0", "1", "2"), class = "factor"))) On Oct 18, 2010, at 4:09 PM, jim holtman wrote:> files did not make it through the mailer. How did you attach them? > try outputting the data using 'dput' and then attaching a '.txt' file, > or just pasting them in the email. > > On Mon, Oct 18, 2010 at 2:40 PM, Gregory Ryslik <rsaber at comcast.net> wrote: >> Hi Everyone, >> >> This is closer to what I need but this returns me a matrix where each element is a factor. Instead I would want a list of lists. The first entry of the list should equal the first column of the matrix that mapply makes, the second entry to the second column etc... >> >> I've attached the two files that have all.predicted.values and max.growth from dput to make for easy testing. Thanks again! >> >> Kind regards, >> Greg >> >> On Oct 18, 2010, at 1:33 PM, Erich Neuwirth wrote: >> >>> You probably need mapply since you have 2 list of arguments which you want to use "in sync" >>> >>> mapply(function(x1,x2)x1[[x2]],all.predicted.values,max.growth) >>> >>> might be what you want. >>> >>> >>> >>> On Oct 18, 2010, at 5:17 PM, Gregory Ryslik wrote: >>> >>>> Unfortunately, that gives me null everywhere. Here's the data I have for all.predicted.values and max.growth. Perhaps this will help. Thus I want all.predicted.values[[1]][[4]] then all.predicted.values[[2]][3]] and then all.predicted.values[[3]][[4]]. >>>> >>>> I've attached what your statement outputs at the end. >>>> >>>> Thanks again! >>>> >>>> Browse[2]> max.growth >>>> [[1]] >>>> [1] 4 >>>> >>>> [[2]] >>>> [1] 3 >>>> >>>> [[3]] >>>> [1] 4 >>>> >>>> Browse[2]> all.predicted.values >>>> [[1]] >>>> [[1]][[1]] >>>> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 2 2 2 2 2 0 0 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 >>>> Levels: 0 1 2 >>>> >>>> [[3]][[3]] >>>> [1] 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 >>>> [55] 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 1 0 >>>> Levels: 0 1 2 >>>> >>>> [[3]][[4]] >>>> [1] 2 2 2 0 1 0 2 2 0 2 1 2 2 0 0 1 1 1 1 0 2 0 0 0 2 0 0 0 1 2 0 0 0 0 1 2 0 0 1 2 0 1 1 2 0 0 0 2 2 0 0 1 2 0 >>>> [55] 0 0 0 0 1 0 0 0 0 1 0 2 1 1 1 2 0 0 1 2 1 1 1 2 1 2 2 2 1 1 0 0 1 0 2 1 1 2 1 1 1 2 0 1 1 0 >>>> Levels: 0 1 2 >>>> >>>> >>>> Browse[2]> predicted.values.for.max.growth<-diag(sapply(all.predicted.values,'[[','max.growth')) >>>> Browse[2]> predicted.values.for.max.growth >>>> [[1]] >>>> NULL >>>> >>>> [[2]] >>>> [1] 0 >>>> >>>> [[3]] >>>> [1] 0 >>>> >>>> [[4]] >>>> [1] 0 >>>> >>>> [[5]] >>>> NULL >>>> >>>> [[6]] >>>> [1] 0 >>>> >>>> [[7]] >>>> [1] 0 >>>> >>>> [[8]] >>>> [1] 0 >>>> >>>> [[9]] >>>> NULL >>>> >>>> >>>> >>>> On Oct 18, 2010, at 11:08 AM, Henrique Dallazuanna wrote: >>>> >>>>> Try this: >>>>> >>>>> diag(sapply(all.predicted.values, '[[', 'max.growth')) >>>>> >>>>> >>>>> On Mon, Oct 18, 2010 at 12:59 PM, Gregory Ryslik <rsaber at comcast.net> wrote: >>>>> Hi, >>>>> >>>>> I have a list of n items and the ith element has m_i elements within it. >>>>> >>>>> I want to do something like: >>>>> >>>>> predicted.values<- lapply(all.predicted.values,'[[',max.growth[[i]]) >>>>> >>>>> Where max.growth[[i]] is the element I want to extract from each of the ith predicted elements. Thus, for example, I want to extract the max.growth[[1]] element from all.predicted.values[[1]] (which is itself a list). Then I want to extract max.growth[[2]] element from all.predicted.values[[2]]. >>>>> >>>>> I realize I can do this with a for loop but then if I can do this as one line that would be preferable. >>>>> >>>>> Thanks! >>>>> >>>>> Greg >>>>> [[alternative HTML version deleted]] >>>>> >>>>> ______________________________________________ >>>>> R-help at 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, self-contained, reproducible code. >>>>> >>>>> >>>>> >>>>> -- >>>>> Henrique Dallazuanna >>>>> Curitiba-Paran?-Brasil >>>>> 25? 25' 40" S 49? 16' 22" O >>>> >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> R-help at 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, self-contained, reproducible code. >>> >>> -- >>> Erich Neuwirth >>> Didactic Center for Computer Science and Institute for Scientific Computing >>> University of Vienna >>> >>> >>> >>> >> >> ______________________________________________ >> R-help at 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, self-contained, reproducible code. >> > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem that you are trying to solve?