我的数据框String serverURL = "http://192.168.0.150/main_light/switch";
URL url = new URL(serverURL);
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
//Do something with this InputStream
// handle the response
int status = connection.getResponseCode();
// If response is not success
if (status != 200) {
throw new IOException("Post failed with error code " + status);
}
} catch (Exception e) {
Log.e(TAG,e.toString());
} finally {
if(connection != null)
connection.disconnect();
}
中有一列Season
,其格式为NBAS
我希望将此值更改为日期时间值,以便此子集可用:
"1989-90"
编辑3:编辑上方以显示更多上下文
现在它正在给我错误信息:
summary(lm(X3PA ~ W.L., data = subset(NBAS, NBAS$Season > '1989-90')))
谢谢!
EDIT1: 根据NicE的建议,我只是删除了连字符并使用以下格式将格式更改为数字:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
In addition: Warning message:
In Ops.factor(NBAS$Season, "1989-90") : ‘>’ not meaningful for factors
然后我能够正确使用该子集。
答案 0 :(得分:1)
您可以尝试删除连字符并将其视为数字:
NBAS$Season <- as.numeric(gsub("-","",Season))