[R] Unique subsetting question

2010-09-22 Thread AndrewPage
Hi all, I'm looking at a large data set, and I'm interested in removing rows where only one variable is duplicated. Here's an example: presidents Qtr1 Qtr2 Qtr3 Qtr4 1945 NA 87 82 75 1946 63 50 43 32 1947 35 60 54 55 1948 36 39 NA NA 1949 69 57 57

Re: [R] Unique subsetting question

2010-09-22 Thread AndrewPage
I understand how duplicated and unique work for a list where all parts of a given row are duplicated, or how to find duplicated values if I'm just looking at that first column, but in this case the rows for 1954 and 1955 are not completely the same; only quarter 1 is duplicated, so I'm not sure

Re: [R] Unique subsetting question

2010-09-22 Thread AndrewPage
I just figured that out, but the real data I'm using is a data frame for sure, so I'll find another example. -- View this message in context: http://r.789695.n4.nabble.com/Unique-subsetting-question-tp2550453p2550736.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Unique subsetting question

2010-09-22 Thread AndrewPage
How about this: s = c(aa, bb, cc, , aa, dd, , aa) n = c(2, 3, 5, 6, 7, 8, 9, 3) b = c(TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE) df = data.frame(n, s, b) # df is a data frame I want to display df with no value in s occurring more than once. Also, I want to delete the

Re: [R] Unique subsetting question

2010-09-22 Thread AndrewPage
Thanks-- that works for what I'm trying to do. I was also wondering, in the data frame example you gave, if I just wanted to get rid of rows where the a value is 5, how would I do that? -- View this message in context:

Re: [R] Unique subsetting question

2010-09-22 Thread AndrewPage
Oops, yeah I didn't see that. Thanks, Andrew -- View this message in context: http://r.789695.n4.nabble.com/Unique-subsetting-question-tp2550453p2550865.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

[R] Finding the right url for RCurl

2010-08-05 Thread AndrewPage
Hi all, I am using RCurl to try and download data from a website, but I'm having trouble finding out what URL to use. Here is the site: http://www.invescopowershares.com/products/holdings.aspx?ticker=PGX See how in the upper right, above the displayed sheet, there's a link to download the

Re: [R] Finding the right url for RCurl

2010-08-05 Thread AndrewPage
Thanks for the help so far-- one interesting thing about this particular page is that the data displayed on the website actually differs from the data you can access with the download link. The XML package command works, but the table it produces in R has the following column names: x1 =

[R] Odd crash with tcl/tk

2010-07-28 Thread AndrewPage
Hi, Recently, I've been trying to use packages in R that require loading the Tcl/Tk interface. However, I get a strange result and a crash that I haven't been able to find discussion about on these boards (or any others). When I enter library(tcltk), it reads Loading Tcl/Tk interface ... , but

[R] Command that is conditional upon file retrieval: is it possible?

2010-07-21 Thread AndrewPage
Hi all, I'm currently working on an R program where I have to access an FTP server to download some of the data I need. However, the people who post up the files I access are at times inconsistent with regards to time posted, if they post at all, etc Here's some of the code I use:

[R] Search and extract string function

2010-07-15 Thread AndrewPage
Hi all, I'm trying to write a function that will search and extract from a long character string, but with a twist: I want to use the characters before and the characters after what I want to extract as reference points. For example, say I'm working with data entries that looks like this:

Re: [R] Search and extract string function

2010-07-15 Thread AndrewPage
Actually I have one more question that's somewhat related-- I'm starting out by importing a .txt file that isn't divided into vectors and is at times inconsistent with regards to spacing, indents, etc., so I can't rely on those. It looks something like this: