0

I have a list of plot ID : c(id_kort) which contains ID of plot like : 'D117_N2C','D117_A2C','D117_C01','D117_C02',.... I obtained it like this :

id_kort = c(df[,"Plot_ID"])

I have a dataframe with data of multiple plots but I only want the ones that are in my list.

I tried this :

vg_data_kort = subset(df2, Plot_ID %in% id_kort)

but got this error :

Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”
Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”
Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”
Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”

If I try to subset a smaller amount, it works perfectly :

vg_data_kort = subset(df2, Plot_ID %in% c('D117_N2C','D117_A2C'))

or

z = c('D117_N2C','D117_A2C')
vg_data_kort = subset(vg_data, Plot_ID %in% z)

I really don't understand why it is doing that...

I also tried :

vg_data_kort=df2[as.character(df$Plot_ID),]

and I got the right dimensions but everything is filled with NA values.

Thank you very much in advance for your help !

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Flóki
  • 9
  • 2
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Nov 11 '22 at 15:10
  • Greetings! Usually it is helpful to provide a minimally reproducible dataset for questions here so people can troubleshoot your problems. One way of doing this is by using the `dput` function. You can find out how to use it here: https://youtu.be/3EID3P1oisg – Shawn Hemelstrand Nov 15 '22 at 02:24

0 Answers0