投稿日をWEBで見るとわからない
<U+200E>
日付の前ですが、Webをスクレイピングした後、日付の前に「< U + 200E>」が表示されます。だから私はそれをcsvファイルとしてどこかに保存して読み込んだ。
library(XML)
gethelp.url = 'http://forums.autodesk.com/t5/Get-Help-with-Fusion-360/bd-p/123'
gethelp.df =htmlTreeParse(gethelp.url, useInternalNodes = T)
getdate <- xpathSApply(gethelp.df, "//span[@class='local-date']", xmlValue)
postingdate <- as.data.frame(getdate)
write.csv(postingdate,"postingdate.csv")
postingdate <- read.csv("postingdate.csv")
head(postingdate)
X getdate
1 1 <U+200E>07-21-2013
2 2 <U+200E>01-23-2014
3 3 <U+200E>03-08-2014
4 4 <U+200E>01-23-2014
5 5 <U+200E>04-29-2014
6 6 <U+200E>04-29-2014
これらの日付と今日の日数の差を計算したかったので、gsub を使用して < U+200E> を削除しました。
postingdate$date3<- gsub(pattern="200",replacement="", postingdate$getdate)
postingdate$date3<- gsub(pattern="E>",replacement="", postingdate$date3)
postingdate$date3<- gsub(pattern="<U",replacement="", postingdate$date3)
postingdate$date3<- gsub(pattern="\\+",replacement="", postingdate$date3)
以下のように difftime を使用すると、
postingdate$diff <- difftime(Sys.Date(),postingdate$date,units="days")
エラーメッセージが表示されます。
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
In addition: Warning message:
In `$.data.frame`(postingdate, date) : Name partially matched in data frame
ただし、strptimeを使用すると、ウィンドウでは機能しますが、LinuxではNAになります
postingdate$date <- strptime(postingdate$date3,format="%m-%d-%Y")
postingdate$diff <- difftime(Sys.Date(),postingdate$date,units="days")
大規模なグーグル検索の後、どちらのプラットフォームでも strptime の使用に違いはないようです。Linuxでこのstrptimeを実行できるアドバイスはありますか?