Object not found

Asked

Viewed 1,718 times

0

I made the following commands on R:

setwd:(###)
data1<-read.table("scatter1.txt",header=T)
head(data1)
tail(data1)
summary(data1)
str(data1)
names(data1)
plot(xv,ys,col="red")

And the message appeared below:

Error in Eval(predvars, data, env) : Object 'xv' not found

What could be wrong?

  • 1

    xv and ys are columns of data1? If yes, you have to indicate the origin of these two objects: plot(data1$xv, data1$ys, col="red"). If it doesn’t work, put some of your data here so we can reproduce: dput(head(data1)).

  • 1

    Note that you do not have the objects xv and ys. Possibly, these are the data1 fields. If it is, you can do attach(data1) or plot(data1$xv, data1$ys, col="red").

1 answer

0

As William asked... Probably your data does not have a column named 'xv'.

Imagine the example:

# criando dados
xv <- runif(9)
yv <- runif(9)


# cria o dataframe
data1 <- data.frame(xv,yv)

data1

xv         yv
1 0.790820953 0.87757976
2 0.909833827 0.42454033
3 0.238349353 0.81647967
4 0.723215071 0.26172111
5 0.003577045 0.58418732
6 0.763899972 0.02090613
7 0.285341114 0.39609819
8 0.340382556 0.27279806
9 0.903062143 0.20278835

To plot the data, you must put the dataframe and the data column reference:

plot(data1$xv,data1$yv)

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.