1. 程式人生 > >R class of subset of matrix and data.frame

R class of subset of matrix and data.frame

a = matrix(
    c(2, 4, 3, 1, 5, 7), # the data elements
    nrow=2,              # number of rows
    ncol=3,              # number of columns
    byrow = TRUE)        # fill matrix by rows
    
class( (a[1,])
[1] "numeric"

class(a[c(1,2),])
[1] "matrix"

class(as.matrix(a[1,]))
[1] "matrix"
#### a row changed to be a column ????

matrix(a[ 1, ],ncol=3) #
 

  n = c(2, 3, 5)
  s = c("aa", "bb", "cc")
  b = c(TRUE, FALSE, TRUE)
  df = data.frame(n, s, b)


class( df[1,])
[1] "data.frame"

class(df[c(1,2),])
[1] "data.frame"

class(as.matrix(df[1,]))
[1] "matrix"

相關推薦

R class of subset of matrix and data.frame

a = matrix(     c(2, 4, 3, 1, 5, 7), # the data elements     nrow=2,              # number of rows     ncol=3,              # number of columns     byrow =

R語言】合併行操作中data.framedata.table的效能比較

測試案例說明 總資料量為M*N條。平均的分佈在N個data.frame/data.table變數中,每個變數為M行。 這N個變數儲存在list中,以1:N表示。list(data.frame)與list(data.table)。 將N個變數合併成一個。 N個

Machine learning and data are fueling a new kind of car, brought to you by Intel

Here's why Intel just offered $15.3 billion for Mobileye, an Israeli company that specializes in machine vision and learning for cars. The automobile is be

How SimilarWeb analyze hundreds of terabytes of data every month with Amazon Athena and Upsolver

This is a guest post by Yossi Wasserman, a data collection & innovation team leader at Similar Web. SimilarWeb, in their own words: Si

響應: 425 Rejected data connection for transfer of "/", IP addresses of control and data connection do

使用 FileZilla_3.30.0_win64-setup_bundled.exe 連線伺服器,提示錯誤如下: 響應:425 Rejected data connection for transfer of "/", IP addresses of control a

How to Build an Ensemble Of Machine Learning Algorithms in R (ready to use boosting, bagging and stacking)

Tweet Share Share Google Plus Ensembles can give you a boost in accuracy on your dataset. In thi

python的強制轉換(當出現 not supported between instances of 'str' and 'int' 的錯誤時)

int typeerror error: 有時 ror images blog 整型 bsp 當我們編程時,有時會出現如下錯誤:TypeError: ‘>‘ not supported between instances of ‘str‘ and ‘int‘ 如下圖:

報錯:illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='

imp ner 解決方法 block wid sql cit 編碼 不知道 sql語句: select t1.block_info, t2.zone from device_indoor_tbl t1 left join blackwhitezone_tbl t2 o

Notes of Head.First.HTML.and.CSS.2nd.Edition

uil ssl nal notice because str over quest OS What does the web server do? tirelessly waiting for requests from webbrowsers What do

translation of the paper sequence and structure conservation in a protein core

prot The ons style 之間 als dell 標準 原子 sequence and structure conservation in a protein core 將殘基結合的緊密程度作為判斷保守型的標準(從結構上定義殘基的保守性)   使用原子與原子之間

解決Mysql錯誤提示Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)

       今天在寫資料庫作業的時候,針對這個問題,我一直在找解決辦法,現在終於是被我解決了。 在網上看了很多辦法,把這些辦法串起來就是最終辦法了,可以不用重新安裝。 第一步:檢視mysql根目錄的my.ini

R squared or coefficient of determination

R squared or coefficient of determination This is my study notes in machine learning, writing articles in English because I want to improve my w

sum of rabbits who whelp and won't die

        古典問題:有一對兔子,從出生後第3個月起每個月都生一對兔子,小兔子長到第三個月                  後每個月又生一對兔子,假如兔子都不死,問每個月的兔子總數為多

History of pruning algorithm development and python implemention(Continuous Updating)

name of tree inventer name of article year ID3 Ross Quinlan 《Discovering rules by i

The score of 'O' and 'X'

題目描述 注意要點: 使用strlen函式注意加標頭檔案#inlcude <cstring> 迴圈巨集定義for迴圈#define _for(i,a,b) for(int i=(a);i<(b);++i) 程式碼實現 #include <iostream>

German embassy i Industrie Router Hutschiene n Paris accused of undeclared staff payments and wrong

www.inhandnetworks.de Two former employees of the German embassy in Paris have accused it of using fake invoicing practices to channel money into

MySQL Illegal mix of collations (utf8_tolower_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for oper

一句話的事: 這是個編碼問題。 我用的 dbForge Studio for Mysql mysql server 版本為 8.0.12 如上圖,在客戶端選擇相應的編碼方式,或者直接勾選“det

Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT)--異常3

情景:在遷移資料庫部分表後,報瞭如下字符集錯誤: java.sql.SQLException: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT)for operation '

Coming of Age: Emerging Technologies And The World's Children

Read "technology" and "children" in the same sentence, and you'll probably think about screen time or social media. But technology's implications are vastl

Ask HN: Whats the best desktop cfg for ML and Data science side project as R&D?

Should I go for a) All in one powerful desktop b) multiple PCs with RAM in the 4-8 GB range? How to decide?