How to create two different CSV files with the same name but one uses a upper case letters and the other uses a lower case letters

Viewed 47

I want to create multiple files for columns in a life table. I thought the easiest way to do this would be to save the files using their variable names (ax, Sx, lx, Lx, ...). However, I cannot get R to create two files based on the same name (one in lower case and one in upper case, e.g. lx.csv and Lx.csv).

To demonstrate the problem:

# write a csv as normal
write.csv(mtcars, "d.csv")

# next line seems to replace d.csv rather than create a new D.csv file
write.csv(iris, "D.csv")

# get iris when read back in  
d <- read.csv("d.csv")
head(d)
#   X Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# 1 1          5.1         3.5          1.4         0.2  setosa
# 2 2          4.9         3.0          1.4         0.2  setosa
# 3 3          4.7         3.2          1.3         0.2  setosa
# 4 4          4.6         3.1          1.5         0.2  setosa
# 5 5          5.0         3.6          1.4         0.2  setosa
# 6 6          5.4         3.9          1.7         0.4  setosa

Is this behavior normal and is there a way to force the creation of new file with the upper case name?

I am using Windows and R 4.1.0

Update

Thanks to @tim for the answer. I had to go through the following steps in Powershell (in admin mode)

  1. Run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  2. Restart PC
  3. Run cd C:\folder to get to the location i want to enable case sensitive file names
  4. Run (Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ enable}

I wanted to enable case sensitive file names for all the sub directories. I think if I just needed for a single folder I could have used fsutil.exe file setCaseSensitiveInfo C:\folder enable for 3 and 4

1 Answers
Related