我想知道当trt = C时如何从一行中所有其他列中删除所有数据。我对一种适用于许多专栏的解决方案感兴趣!
proc VGAPlaneSelect
push ax
push dx
push cx
mov al, 02h
mov dx, 03C4h
out dx, al
VGAPlaneSelect_start:
mov ax, 1
mov cl, [VGAPlane]
shl ax, cl
cmp [VGAPlane], 4
jne VGAPlaneSelect_end
mov [VGAPlane], 0
jmp VGAPlaneSelect_start
VGAPlaneSelect_end:
mov dx, 03C5h
out dx, al
pop cx
pop dx
pop ax
ret
endp VGAPlaneSelect
类似...
A <- sample(1:100,9)
B <- sample(1:100,9)
trt <- rep(c("A", "B", "C"),3)
df <- data.frame(trt, A, B)
df
trt A B
1 A 32 43
2 B 29 79
3 C 94 95
4 A 100 24
5 B 63 38
6 C 80 92
7 A 22 98
8 B 61 56
9 C 69 81
to look like this:
trt A B
1 A 90 50
2 B 84 100
3 C NA NA
4 A 42 17
5 B 61 43
6 C NA NA
7 A 78 84
8 B 27 36
9 C NA NA
答案 0 :(得分:2)
我们可以使用CREATE TABLE dbo.YourTable (StartDate datetime,
EndDate datetime);
INSERT INTO dbo.YourTable (StartDate,
EndDate)
VALUES('2020-01-10T13:00:00.347','2020-01-12T02:00:00.347'),
('2020-01-14T17:24:41.243','2020-01-19T09:17:12.997');
GO
WITH N AS(
SELECT N
FROM (VALUES(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL))N(N)),
Tally AS(
SELECT TOP(SELECT MAX(DATEDIFF(DAY, StartDate, EndDate)+1) FROM dbo.YourTable)
ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) -1 AS I
FROM N N1, N N2, N N3), --1000 days enough?
Dates AS(
SELECT DATEADD(DAY, T.I,CONVERT(date,YT.StartDate)) AS [Date],
CASE WHEN T.I = 0 THEN YT.StartDate ELSE DATEADD(DAY, T.I,CONVERT(date,YT.StartDate)) END AS StartingDateTime,
CASE WHEN LEAD(T.I) OVER (PARTITION BY YT.StartDate ORDER BY T.I) IS NULL THEN YT.EndDate ELSE DATEADD(DAY, T.I+1,CONVERT(date,YT.StartDate)) END AS EndingDateTime
FROM Tally T
JOIN dbo.YourTable YT ON T.I <= DATEDIFF(DAY, YT.StartDate, YT.EndDate))
SELECT D.[Date],
(DATEDIFF(SECOND,D.StartingDateTime,D.EndingDateTime) * 1.0) / 60 / 60 AS [Hours]
FROM Dates D;
GO
DROP TABLE dbo.YourTable;
选择要更改的行和列,即
[
给出,
df[df$trt == 'C', -1] <- NA
您也可以使用它来选择特定的列,
trt A B
1 A 87 56
2 B 53 18
3 C NA NA
4 A 8 1
5 B 79 38
6 C NA NA
7 A 48 36
8 B 55 22
9 C NA NA
给出,
df[df$trt == 'C', -c(1, 3)] <- NA
答案 1 :(得分:1)
这是功能为<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\app.jar"">
</httpPlatform>
</system.webServer>
</configuration>
的解决方案。
is.na<-
答案 2 :(得分:1)
for (i in 1:nrow(df)) {
if (df$trt[i] == "C") {
df[i, ] <- NA
df$trt[i] <- "C"
}
}
强悍,但有效!