I have the simpliest code ever to download a zip and unzip it on my work directory in case it has not been already download:
URL <- ("https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip")
ZipFile <- "ElectricPowerCons.zip"
DataPath <- "ElectricPowerCons"
If (!file.exists(ZipFile)) {
download.file(URL, ZipFile, mode = "wb")
}
If (!file.exists(DataPath)) {
unzip(ZipFile)
}
When I run it, I get the following errors when passing the if statements:
Error: unexpected '{' in "If (!file.exists(ZipFile)) {"
Error: unexpected '{' in "If (!file.exists(DataPath)) {"
This also happened to me in another simple code, and I spent a lot of time finding the cause. I remember that I replaced the curly brackets in another way and I get it solved. Now I tried the same and didn't succeed, and I would like to know if there are certain syntax issues that I am missing.
I have also read other questions here but don't fit into my question since they had particular different characterstics.
Could anyone help me?
Aucun commentaire:
Enregistrer un commentaire