From jinghuazhao at hotmail.com  Fri Feb 10 01:15:16 2017
From: jinghuazhao at hotmail.com (jing hua zhao)
Date: Fri, 10 Feb 2017 00:15:16 +0000
Subject: [Rd] issue with unz()?
In-Reply-To: <LOXP123MB11586751F324220E12A5F3B6A5440@LOXP123MB1158.GBRP123.PROD.OUTLOOK.COM>
References: <mailman.23.1278669608.14475.r-devel@r-project.org>,
	<5DBE21404FF5E54C826BE1040C2CD031C919E1@msgebe52.mfad.mfroot.org>,
	<LOXP123MB11586751F324220E12A5F3B6A5440@LOXP123MB1158.GBRP123.PROD.OUTLOOK.COM>
Message-ID: <LOXP123MB11582BC9AA67FF9B412DE796A5440@LOXP123MB1158.GBRP123.PROD.OUTLOOK.COM>

The 2015 does contain three files.

________________________________
From: jing hua zhao <jinghuazhao at hotmail.com>
Sent: 10 February 2017 00:13
To: r-devel at r-project.org
Subject: issue with unz()?


Dear R-devel,





url0514 <- "http://data.dft.gov.uk.s3.amazonaws.com/road-accidents-safety-data/Stats19_Data_2005-2014.zip"
file0514 <- c("Vehicles0514.csv","Casualties0514.csv","Accidents0514.csv")

temp <- tempfile()
download.file(url0514,temp)
a0514 <<- read.csv(unz(temp, file0514[3]))

c0514 <<- read.csv(unz(temp, file0514[2]))

v0514 <<- read.csv(unz(temp, file0514[1]))



cts [a|c|v]0514, but this is not the case if zip file contains only one file, i.e.,

file2015 <- c("Vehicles_2015.csv","Casualties_2015.csv","Accidents_2015.csv")
url2015 <- "http://data.dft.gov.uk/road-accidents-safety-data/RoadSafetyData_2015.zip"
download.file(url2015,temp)
v2015 <<- read.csv(unz(temp, file2015[1]))
c2015 <<- read.csv(unz(temp, file2015[2]))
a2015 <<- read.csv(unz(temp, file2015[3]))


so to combine [a|c|v]0514 and [a|c|v]2015, I need to add something like


names(a0514)[names(a0514)=="?..Accident_Index"] <- "Accident_Index"
names(c0514)[names(c0514)=="?..Accident_Index"] <- "Accident_Index"
names(v0514)[names(v0514)=="?..Accident_Index"] <- "Accident_Index"


This is unnecessary under Linux (RHEL), since those i..Accident_Index have no i.. prefix.


Do I miss anything here?


Many thanks,




Jing Hua Zhao

	[[alternative HTML version deleted]]



[Rd] issue with unz()?
jing hua zhao