Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Character vector can not be created with 'char' #343

Closed
@fplazaonate

Description

@fplazaonate

It seems to me that CharacterVector and StringVector have the same behaviour. (correct me if I am wrong)
It is OK because as far as I know R treats single chars as strings.

However, creating a CharacterVector from char produce wrong results in Rcpp
Here is an example:

#include<Rcpp.h>usingnamespaceRcpp;// [[Rcpp::export]]NumericMatrixtest_character_vector(){  NumericMatrixm(3,3);rownames(m) =CharacterVector::create('a','b','c');return m;}/*** Rm1=matrix(nrow = 3,ncol=3)rownames(m1)=c('a','b','c')rownames(m1) #OKm2=test_character_vector()rownames(m2) # WRONG*/

Result

> m1=matrix(nrow = 3,ncol=3)> rownames(m1)=c('a','b','c')> rownames(m1) #OK[1] "a" "b" "c"> m2=test_character_vector()> rownames(m2) # WRONG[1] "abc" "bc"  "c"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp