0
我有一個.csv文件包含用戶的GPS位置。一列稱爲位置存儲區,其中包含15個經度和緯度的用戶。是位置存儲內容的示例如下:如何提取csv文件中列的最後一個數字與R
121.49961,25.023201;121.499596,25.023188;121.49961,25.02319;121.4996,25.023182;121.4996,25.023184;121.4996,25.023184;121.4996,25.023174;121.4996,25.023167;121.49959,25.02316;121.49959,25.023146;121.499565,25.023125;121.499565,25.023117;121.49958,25.023111;121.499596,25.023132;121.4996,25.023123
121.5011,25.02951;121.5011,25.02951;121.50063,25.029524;121.500534,25.029497;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512
121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512;121.50069,25.029512
...
我要提取的最後一對從R中的.csv文件經度和緯度的,我該怎麼辦呢?謝謝。
到目前爲止,我已經做了以下步驟:
Trip1 <- read.csv("1.csv", sep = ",", header = TRUE)
Trip1$location_store
head(Trip1$location_store)
LocationTemp <-strsplit(as.character(Location), ";")
LocationTemp
控制檯導致
...
[[176]]
[1] "121.52448,25.073643" "121.52452,25.073673" "121.524574,25.07372"
[4] "121.524635,25.073753" "121.5247,25.073814" "121.524765,25.07385"
[7] "121.52485,25.073881" "121.524925,25.073938" "121.52499,25.073973"
[10] "121.52507,25.074041" "121.52514,25.074095" "121.525185,25.074121"
[13] "121.525215,25.074146" "121.52523,25.074142" "121.52524,25.074146"
[[177]]
[1] "121.52526,25.07417" "121.525276,25.074173" "121.52529,25.074173"
[4] "121.52529,25.07418" "121.52529,25.074183" "121.52529,25.074183"
[7] "121.52529,25.07418" "121.5253,25.074179" "121.5253,25.074183"
[10] "121.5253,25.074188" "121.5253,25.074186" "121.52531,25.074186"
[13] "121.52531,25.074188" "121.52531,25.074186" "121.52531,25.074186"
[[178]]
[1] "121.52531,25.074186" "121.52531,25.074186" "121.525314,25.074188"
[4] "121.525314,25.07419" "121.525314,25.074188" "121.525314,25.074188"
[7] "121.525314,25.074188" "121.525314,25.074188" "121.525314,25.074188"
[10] "121.525314,25.074188" "121.525314,25.074188" "121.525314,25.074188"
[13] "121.525314,25.074188" "121.525314,25.074188" "121.525314,25.074188"
...
但是,我不知道提取最後一對經度和緯度值。
到目前爲止你有什麼?你有沒有讀過?以'read.csv2'開始(它是'''分隔的),收集到長形式,然後將緯度/經度分隔成不同的列,在這一點你的數據將是一個整潔的形式,很容易子集。或者只是掏出你需要的東西。 – alistaire
E.g. '庫(tidyr);位置< - read.csv2('file.csv'); locations_tidy < - locations%>%gather()%>%separate(value,c('lat','lon'),sep =',',convert = TRUE); locations_tidy%>%tail(1)' – alistaire
嗨,alistaire,感謝您的建議,我添加了更多的代碼,至今我已經完成了,您能否發表評論? –