Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R、 如何在带有时区和垃圾Unicode字符的Linux上使用strTime_Linux_R_Strptime_Input Sanitization - Fatal编程技术网

R、 如何在带有时区和垃圾Unicode字符的Linux上使用strTime

R、 如何在带有时区和垃圾Unicode字符的Linux上使用strTime,linux,r,strptime,input-sanitization,Linux,R,Strptime,Input Sanitization,当我在网上看到发布日期时,我看不到 在日期之前,但在我浏览完网页之后,不知怎的,我看到了日期之前的“”。所以我把它保存在某个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 <- xpathS

当我在网上看到发布日期时,我看不到

在日期之前,但在我浏览完网页之后,不知怎的,我看到了日期之前的“”。所以我把它保存在某个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
但如果我使用strtime,它可以在windows上运行,但在Linux上它会提供NA

postingdate$date <- strptime(postingdate$date3,format="%m-%d-%Y")
postingdate$diff <- difftime(Sys.Date(),postingdate$date,units="days")
postingdate$date注意

strptime("07-21-2013",format="%m-%d-%Y")
返回

[1] "2013-07-21 EDT"
所以时区把时间搞乱了。改用

format(postingdate$date3,format="%m-%d-%Y", usetz=FALSE)

gsub(模式=”,替换=”,发布日期$getdate)

是一个更紧凑的正则表达式,用于删除您不想要的部分。

这部分是关于删除Unicode垃圾()的问题,部分是关于strftime的问题。谢谢您的回答。正则表达式更加紧凑!我没有在Linux上测试这些时区代码,但是在窗口“format(postingdate$date3,format=“%m-%d-%Y”,usetz=FALSE)”在与difftime一起使用时抛出一条错误消息。
strptime("07-21-2013",format="%m-%d-%Y")
[1] "2013-07-21 EDT"
format(postingdate$date3,format="%m-%d-%Y", usetz=FALSE)
gsub(pattern="<U\\+200E>",replacement="", postingdate$getdate)