Colleagues, I have data which has a .asc file extension. Can R read that file extension? All the best, Thomas Subia Statistician
Hallo Thomas The asc extension could represent several different formats https://fileinfo.com/extension/asc you should check the contents with let say Notepad or any other plain text editor or some commander. It could be plain text file which you can read by usual ways into R. Cheers Petr> -----Original Message----- > From: R-help <r-help-bounces at r-project.org> On Behalf Of Thomas Subia > via R-help > Sent: Friday, May 20, 2022 3:27 PM > To: r-help at r-project.org > Subject: [R] R and .asc file extension > > Colleagues, > > I have data which has a .asc file extension. > > Can R read that file extension? > > All the best, > > Thomas Subia > Statistician > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
On 20.05.2022 15:27, Thomas Subia via R-help wrote:> Colleagues, > > I have data which has a .asc file extension.asc likely means ASCII and can be any kind of text data, so wed need some contents to suggest a function. But any for text files should work. Best, Uwe Ligges> > Can R read that file extension? > > All the best, > > Thomas Subia > Statistician > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
A google search returned a stack overflow page that might help. stackoverflow.com/questions/20177581/reading-an-asc-file-into-r (add the https part to get a functional link.) I would also try looking at the file using something like notebook, or any program that is a plain text editor. That way I can see exactly what the file contains. Tim -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of Thomas Subia via R-help Sent: Friday, May 20, 2022 9:27 AM To: r-help at r-project.org Subject: [R] R and .asc file extension [External Email] Colleagues, I have data which has a .asc file extension. Can R read that file extension? All the best, Thomas Subia Statistician ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=OuZijT4yJ8dfQLVPVj4YWSCPkpUW4wkGCSHim27tbH9qYMjXbuMSxybv7i0cvWHl&s=7eUP-gSu0ZAEL_iEdxyJwCEEE7PQF15Fplf_dGvzMfM&ePLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=OuZijT4yJ8dfQLVPVj4YWSCPkpUW4wkGCSHim27tbH9qYMjXbuMSxybv7i0cvWHl&s=0Y81eoA64cMK6zoqQGZoDecTemarTEV4UxqvF-FSuMA&eand provide commented, minimal, self-contained, reproducible code.
R has no restrictions regarding file name extensions. Seriously. What you are probably asking is whether there are functions available that can transform such a file into a usable R data object. Unfortunately, a file named with an ASC file extension could contain any kind of data, and even among "common" formats such files contain easily thousands of different formats. So deciding whether R can sensibly parse data based only on that information is impossible. POSIX-conformant operating systems often have a utility program called "file" that looks in the file data and uses heuristics to guess what format is being used. But even that output may not be sufficient to answer that question. Try opening it in a text editor, and if that works you might see some clues that you can google for. Or if you know from where you obtained the data what type of information it should contain, you may be able to use a search engine to find clues about it. Don't be surprised if it is a one-of-a-kind format... it was not uncommon 30 years ago to re-direct output prepared for sending to a line printer into a file with an asc extension (short for "ASCII format"), with no defined format for other computers to recognize at all. You would have to use the readLines function and string search functions like grep or sub to extract information from it in that case, based on your ability to see patterns in a text viewer. On May 20, 2022 6:27:20 AM PDT, Thomas Subia via R-help <r-help at r-project.org> wrote:>Colleagues, > >I have data which has a .asc file extension. > >Can R read that file extension? > >All the best, > >Thomas Subia >Statistician > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.-- Sent from my phone. Please excuse my brevity.
? Fri, 20 May 2022 13:27:20 +0000 (UTC) Thomas Subia via R-help <r-help at r-project.org> ?????:> I have data which has a .asc file extension. > > Can R read that file extension?It very much depends on the content. ".asc" could mean ASCII text (in which case read.table() or at least readLines() is your friend), or something completely different. For example, RFC 4880 "ASCII armoured" files typically have .asc extension, but you're much better off reading those using an OpenPGP implementation, not R. -- Best regards, Ivan
Dear Thomas, If your .asc file is a raster (Esri ASCII raster format), you may consider the functions 'raster' in the raster package or 'read_starts' in the star package. Otherwise (or even)? 'scan' or 'read.table' from base/utils may be your friends. Best, Fran?ois Le 20/05/2022 ? 15:27, Thomas Subia via R-help a ?crit?:> Colleagues, > > I have data which has a .asc file extension. > > Can R read that file extension? > > All the best, > > Thomas Subia > Statistician
Gregory Coats
2022-Jun-15 01:08 UTC
[R] How do I "teach" R that columns 1, 2, and 3 are the Year-Month-Day
# Column 1 is the Year # Column 2 is the Month # Column 3 is the Day # Column 4 is the Fuel Fuel <- c(50.45, 61.48, 59.07, 55.40, 30.63, 41.35, 32.81, 49.86, 62.99, 89.37) plot (Fuel) 2021 7 25 50.45 2021 8 27 61.48 2021 9 26 59.07 2021 11 4 55.40 2021 11 22 30.63 2021 11 26 41.35 2021 12 6 32.81 2022 1 14 49.86 2022 4 29 62.99 2022 6 11 89.37 How do I "teach" R that columns 1, 2, and 3 are the Year-Month-Day? Greg Coats [[alternative HTML version deleted]]