Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python では、リストをこのようにスライスしx[4:-1]て、4 番目の要素から最後の要素まで取得できます。
x[4:-1]
R では、 を使用したベクトルx[4:length(x)]や のような多次元配列に対して同様のことを行うことができますx[,,,,4:dim(x)[5],,,]。これは、中間の要素から最後の要素までの特定の次元の配列スライスのより洗練された構文ですか?
x[4:length(x)]
x[,,,,4:dim(x)[5],,,]
ありがとう
要素のドロップ構文を使用できます。
> (1:10)[-(1:4)] [1] 5 6 7 8 9 10
配列の最後の n 要素をスライスすることに関心がある場合は、次を使用できます。
x[seq(length=n, from=length(x), by=-1)]