Finding and renaming long file names with R

I have never given it a though, but there is apparently a limit to the length of file names that can be handled by Windows Explorer of Windows XP. I found out when trying to copy my Zotero folder to a computer with Windows XP. I was getting error message of folders that could not be copied, suggesting that my HD was full. I checked a few of these folders and they all contained one or more files with very long file names (>250 characters). Continue reading “Finding and renaming long file names with R”

Using the GRASS command g.mlist in R

In this post I was trying to find a way to get a list of GRASS data layers in R. The problem is running the GRASS function ‘g.list’ from R (using system or execGRASS from the spgrass6 package) gives a vector which can not be easily handled in R (i.e., it is not a nice vector with one layer name per vector element).

Finding the solution was a nice exersize in using the R functions gsub() and strsplit(), but today I realized that there is solution that is not only easier but also better and more flexible. Continue reading “Using the GRASS command g.mlist in R”

Using the GRASS command g.list in R

Running grass commands within R is easy using either the system function or the spgrass6 package. But sometimes the GRASS outputs are not easy to read into a data frame or vector. For example, what if you want a vector with all raster data layers in mapset ‘species’. Continue reading “Using the GRASS command g.list in R”