Re: [R] Construct a File Path: File Path Unknown
it would probably be faster if you can be as specific as possible... in the help that has been provided, it is looking everywhere in c:/ you could narrow that down a bit and save it from looking too deep in your system. dir(C:\Documents and Settings\username\Desktop, pattern=foo.pdf, full.names=T, ignore.case=T, recursive=T) **I'm not 100% about this, but it seems logical to me William Dunlap wrote: Try using normalizePath(foo.pdf) after creating the file. It should return an absolute path to an existing file. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tyler Rinker Sent: Thursday, August 25, 2011 12:43 PM To: jvad...@usgs.gov Cc: r-help@r-project.org Subject: Re: [R] Construct a File Path: File Path Unknown Jean, Thank you. It's slow but it works. dir(C:/, pattern=plotrix.pdf, full.names=T, ignore.case=T, recursive=T) Does anyone have a faster way? If it helps using: shell.exec(search-ms://query=plotrix.pdf)utilizes windows's search bar to find the file (this is quick), however it opens a screen that finds the file rather than providing me with the search path. For a look at what that looks like on a windows machine click here: http://windows.microsoft.com/en- US/windows7/products/features/windows-search I'm thinking there's a way to use this method to extract the path even faster than dir(). TylerTo: tyler_rin...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] Construct a File Path: File Path Unknown From: jvad...@usgs.gov Date: Thu, 25 Aug 2011 13:19:37 -0500 Try the dir() function. ?dir # for example dir(c:/, pattern=foo.pdf, full.names=T, ignore.case=T, recursive=T) Jean Tyler Rinker wrote on 08/25/2011 11:54:28 AM: I am not a programmer and am self-taught so I may lack the language to ask this appropriately (perhaps why an rseek search was unfruitful). Let's say I saved a file to my desktop called foo.pdf. Then I want R to return the file path of foo.pdf (pretend I don't know the location(path) of foo.pdf). Question: How would I get R to return the unknown file path for foo.pdf. I hypothesize that the find find.package() function code contains the secret for doing this but am unable to parse out the snippet to do so. I attempted file.path(foo.pdf) which R returns [1] foo.pdf #not what I want === R version 2.14 beta Windows 7 Reproducible code is not appropriate for this query __ R-help@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. [[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-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@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. -- View this message in context: http://r.789695.n4.nabble.com/Construct-a-File-Path-File-Path-Unknown-tp3768821p3769392.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Quadratic equation
these guys wont help you with your homework. But have you ever heard of Google?... if so, R has plenty of online manuals and cheat sheets. -- View this message in context: http://r.789695.n4.nabble.com/Quadratic-equation-tp3758790p3759239.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Grouping columns
untested because I don't have access to your data, but this should work. b13.NEW - b13[, c(Gesamt, Wasser, Boden, Luft, Abwasser, Gefährliche Abfälle, nicht gefährliche Abfälle)] Geophagus wrote: *Hi @ all, I have a question concerning the possibilty of grouping the columns of a matrix. R groups the columns alphabetically. What can I do to group the columns in my specifications? The script is the following:* #R-Skript: Anzahl xyz #Quelldatei einlesen b-read.csv2(Z:/int/xyz.csv, header=TRUE) #Teilmengen für die Einzeljahre generieren b1-subset(b,jahr==2007) b2-subset(b,jahr==2008) b3-subset(b,jahr==2009) #tapply für die Einzeljahre auf die jeweilige BranchenID b1_1-tapply(b1$betriebs_id,b1$umweltkompartiment,length) b1_2-tapply(b2$betriebs_id,b2$umweltkompartiment,length) b1_3-tapply(b3$betriebs_id,b3$umweltkompartiment,length) #Verbinden der Ergebnisse b11-rbind(b1_1,b1_2,b1_3) Gesamt-apply(X=b11,MARGIN=1, sum) b13-cbind(Gesamt,b11) b13 Gesamt Abwasser Boden Gefährliche Abfälle Luft nicht gefährliche Abfälle Wasser b1_1 9832 432183147 2839 1592 1804 b1_2 10271 413283360 2920 1715 1835 b1_3 9983 404213405 2741 1691 1721 *Now I want to have the following order of the columns: Gesamt, Wasser, Boden, Luft, Abwasser, Gefährliche Abfälle, nicht gefährliche Abfälle Thanks a lot for your answers! Fak* -- View this message in context: http://r.789695.n4.nabble.com/Grouping-columns-tp3681018p3681121.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] problems with merge() - the output has many repeated lines
?unique -- View this message in context: http://r.789695.n4.nabble.com/problems-with-merge-the-output-has-many-repeated-lines-tp2333596p2334249.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] fill in values between rollapply
Dennis: I had never used the rep() function and that works out great, thank you. Brad -- View this message in context: http://n4.nabble.com/fill-in-values-between-rollapply-tp1816885p1835513.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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] fill in values between rollapply
Hi, Sorry ahead of time for not including data with this question. Using rollapply to calculate mean values for 5 day blocks, I'd use this: Roll5mean - rollapply(data, 5, mean, by=5, align = c(left)) My question is, can someone tell me how to fill in the days between each of these means with the previously calculated mean? If this doesn't make sense, I will clarify and provide data for an example. Thanks. Brad -- View this message in context: http://n4.nabble.com/fill-in-values-between-rollapply-tp1816885p1816885.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] fill in values between rollapply
Dennis: I will check this out tonight and let you know, it seems promising. Either way, thanks for the suggestion. Brad On Fri, Apr 9, 2010 at 12:03 PM, Dennis Murphy [via R] ml-node+1819642-2015310724-118...@n4.nabble.comml-node%2b1819642-2015310724-118...@n4.nabble.com wrote: Hi: Not exactly elegant, but here's one approach: library(zoo) x - zoo( rpois(100, 40) ) w - rollapply(x, 5, mean, by = 5, align = c('left')) x2 - rep(w, each = 5) Does that work? HTH, Dennis On Fri, Apr 9, 2010 at 12:32 AM, Brad Patrick Schneid [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1819642i=0wrote: Hi, Sorry ahead of time for not including data with this question. Using rollapply to calculate mean values for 5 day blocks, I'd use this: Roll5mean - rollapply(data, 5, mean, by=5, align = c(left)) My question is, can someone tell me how to fill in the days between each of these means with the previously calculated mean? If this doesn't make sense, I will clarify and provide data for an example. Thanks. Brad -- View this message in context: http://n4.nabble.com/fill-in-values-between-rollapply-tp1816885p1816885.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1819642i=1mailing 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. [[alternative HTML version deleted]] __ [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1819642i=2mailing 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. -- View message @ http://n4.nabble.com/fill-in-values-between-rollapply-tp1816885p1819642.html To unsubscribe from fill in values between rollapply, click here (link removed) ==. -- View this message in context: http://n4.nabble.com/fill-in-values-between-rollapply-tp1816885p1819968.html Sent from the R help mailing list archive at Nabble.com. [[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-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] time series problem: time points don't match
Gabor: That is not the ideal solution, but it definitely works to provide me with the easier alternative. Thanks for the reply! -- View this message in context: http://n4.nabble.com/time-series-problem-time-points-don-t-match-tp1748387p1748706.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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] time series problem: time points don't match
Hi, I have a time series problem that I would like some help with if you have the time. I have many data from many sites that look like this: Site.1 datetimelevel temp 2009/10/01 00:01:52.0 2.8797 18.401 2009/10/01 00:16:52.0 2.8769 18.382 2009/10/01 00:31:52.0 2.8708 18.309 2009/10/01 00:46:52.0 2.8728 18.285 2009/10/01 01:01:52.0 2.8716 18.245 2009/10/01 01:16:52.0 2.8710 18.190 Site.2 datetimelevel temp 2009/10/01 00:11:06.0 2.9507 18.673 2009/10/01 00:26:06.0 2.9473 18.630 2009/10/01 00:41:06.0 2.9470 18.593 2009/10/01 00:56:06.0 2.9471 18.562 2009/10/01 01:11:06.0 2.9451 18.518 2009/10/01 01:26:06.0 2.9471 18.480 As you can see, the times do not match up. What I would like to do is be able to merge these two data sets to the nearest time stamp by creating a new time between the two; something like this: datenew.timelevel.1 temp.1level.2 temp.2 2009/10/01 00:01:52.0 2.8797 18.401 NA NA 2009/10/01 00:13:59.0 2.8769 18.382 2.9507 18.673 2009/10/01 00:28:59.0 2.8708 18.309 2.9473 18.630 2009/10/01 00:43:59.0 2.8728 18.285 2.9470 18.593 2009/10/01 00:59:59.0 2.8716 18.245 2.9471 18.562 2009/10/01 01:13:59.0 2.8710 18.190 2.9451 18.518 2009/10/01 01:26:06.0 NA NA 2.9471 18.480 Note that the sites may not match in the # of observations and a return of NA would be necessary, but a deletion of that time point all together for both sites would be preferred. A possibly easier alternative would be a way to assign generic times for each observation according to the time interval, so that the 1st observation for each day would have a time = 00:00:00 and each consecutive one would be 15 minutes later. Thanks for any suggestions. Brad -- View this message in context: http://n4.nabble.com/time-series-problem-time-points-don-t-match-tp1748387p1748387.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Similarity Percentage Analysis
I'm guessing the answer is no? I too am looking for a function for SIMPER, it seems logical that this would be in the Vegan package with the ANOSIM function. -- View this message in context: http://n4.nabble.com/Similarity-Percentage-Analysis-tp868460p1573091.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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] should be easy data frame manipulation
I have a data.frame with the following: ID Species Count 1 A 3 1 B 2 1 E 12 2 A 13 2 C 5 2 F 4 3 B 5 3 D 3 I need it in this format: ID A B C D E F 1 3 2 0 0 12 0 2 13 0 5 0 0 4 3 0 5 0 3 0 0 Any ideas? -- View this message in context: http://n4.nabble.com/should-be-easy-data-frame-manipulation-tp1457518p1457518.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Applying a transformation to multiple data frame columns
look at plyr package colwise (column wise) function -- View this message in context: http://n4.nabble.com/Applying-a-transformation-to-multiple-data-frame-columns-tp1457641p1457666.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] should be easy data frame manipulation
You rock! thank you.. you saved me hours of hunting around. -- View this message in context: http://n4.nabble.com/should-be-easy-data-frame-manipulation-tp1457518p1457675.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] read multiple large files into one dataframe
Thats it Hadley!!! Thank you. -- View this message in context: http://n4.nabble.com/read-multiple-large-files-into-one-dataframe-tp891835p1290089.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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] auto reading in multiple txt files with filename as 1st column ID
Hi, I have many .txt files which look like this: 2009/02/07 12:30:10.0 5.0161 13.208 2009/02/07 12:45:10.0 5.0102 13.350 2009/02/07 13:00:10.0 5.0044 13.473 2009/02/07 16:30:10.0 4.9366 13.788 2009/02/07 16:45:10.0 4.9397 13.798 end data. ###I can read in all files from my_folder using the following code: flist - list.files(path=file.path(my_folder), pattern=[.]txt$) flist-flist[grep('.txt', flist)] myInput - lapply(flist, read.table, header=FALSE, skip=44) ## Each file is uniquely named site_name.txt , and the last row of each file contains the line: end data. I would like to do the following: 1) add a new column with site_name repeated for each observation/row (data files vary in the # of observations) which corresponds to the name of the txt file 2) remove the last line which says end data 3) merge the files vertically into one huge data frame if I have the text files site_name_A.txt and site_name_B.txt, I want the end product to be a data.frame and look like this: site_name_A 2009/02/07 12:30:10.0 5.0161 13.208 site_name_A 2009/02/07 12:45:10.0 5.0102 13.350 site_name_A 2009/02/07 13:00:10.0 5.0044 13.473 site_name_B 2009/02/07 12:30:10.0 4.9366 13.788 site_name_B 2009/02/07 12:45:10.0 4.9397 13.798 I am just learning R and would greatly appreciate any suggestions. Thanks ahead of time. -- View this message in context: http://n4.nabble.com/auto-reading-in-multiple-txt-files-with-filename-as-1st-column-ID-tp1288549p1288549.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] read multiple large files into one dataframe
### The following is very helpful # listOfFiles - list.files(pattern= .txt) d - do.call(rbind, lapply(listOfFiles, read.table)) ### but what if each file contains information corresponding to a different subject and I need to be able to tell where each row came from? i.e.: I need a new row that repeats the original filename for each observation of the former respective files. Any ideas? -- View this message in context: http://n4.nabble.com/read-multiple-large-files-into-one-dataframe-tp891835p1288816.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Automatic File Reading [Broadcast]
Sorry... also, how do I remove the last line which says end data -- View this message in context: http://n4.nabble.com/R-Automatic-File-Reading-tp810331p1182386.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Automatic File Reading [Broadcast]
Hi, I have many files which look like this: 2009/02/07 12:30:10.0 5.0161 13.208 2009/02/07 12:45:10.0 5.0102 13.350 2009/02/07 13:00:10.0 5.0044 13.473 2009/02/07 16:30:10.0 4.9366 13.788 2009/02/07 16:45:10.0 4.9397 13.798 end data. Thanks to this thred, I can read them all in automatically. each file is uniquely named site_name.txt and as you can see, there are no headers in the files I would like to add a new column with site_name repeated for each observation which corresponds to the name of the file the data came from AND also merge the files vertically into one huge data file. I am just learning R and would greatly appreciate any suggestions. Thanks ahead of time. -- View this message in context: http://n4.nabble.com/R-Automatic-File-Reading-tp810331p1182221.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.