How can I represent vector

x1=c(4,-1,3)
x2=c(1,3,5)
x=c(x1,x2)
data=matrix(x,ncol=2,byrow=FALSE)
transport_data=t(data)
How can I do to represent vectors of variable x1,x2?

you've achieved your goal.
The data object that you made with matrix() gives you x1 and x2 vectors arranged in a columnar fashion
similarly
The transport_data object that you made by transposing data is a rowwise matrix that represents x1 and x2

1 Like

I have to create variable's span

I commit an error I need observations span

Its very unclear what you mean.
what are the 'observations' in this context ?

and aren't "spans" in linear algebra all the possible linear combinations of the vectors ? Mustn't the answer therefore be somewhat algebraic, because if you tried to enumate them, it would be infinite... ?

1 Like

Hi, and welcome!

Here's a bit more compact way to do this, and if you want to unpack one of the four vectors, you would call them with

x1 <- c(4,-1,3)
x2 <- c(1,3,5)
m <- t(cbind(x1,x2))
m
#>    [,1] [,2] [,3]
#> x1    4   -1    3
#> x2    1    3    5
m[1,]
#> [1]  4 -1  3
m[2,]
#> [1] 1 3 5
m[,1]
#> x1 x2 
#>  4  1
m[,2]
#> x1 x2 
#> -1  3

Created on 2020-02-22 by the reprex package (v0.3.0)

I would obtain a triplot whit 2 points that represent my variables x1 and x2 and arrows that link point (0,0,0) with x1 and (0,0,0) with x2

Are you trying to create a graph object? (Sometimes referred to as a network representation.)

I think @Daniel96 means he's trying to create a 3D plot with two (geometric) vectors, one from the origin to the point x1, and one from the origin to the point x2. I can help with a 2D version, but I have no idea how to help with a 3D version, however.

1 Like

I tried with scatterplot3d()
But I don't have any idea how can I represent vectors in R3


x1 <- c(4,-1,3)
x2 <- c(1,3,5)
origin <- c( 0, 0, 0)
m <- t(cbind(x1,x2,origin))


library("scatterplot3d") # load

scatterplot3d(m,
              type="p",
              color = c("red","blue","black"),
              pch = 1,
              xlim = c(-6,6),
              ylim = c(-6,6),
              zlim = c(-6,6))

image
I'm afraid I don't know what a triplot is but this is a scatterplot3d

1 Like

Here's a post on Stack Overflow about drawing 3D vectors with a package called rgl -- maybe try that?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.