Error subset data .txt

rstudio

#1

Hello,

my question may be very simle, but I don't find any answer so I would like to ask, I have two different .txt files, which is:
idx_DGG_land.txt (1229504 obs., 1variable) & isea4h9.txt (2621450obs., 5 variables)
I succesfully import the files, but my next step is get the index of DGG over land in the isea grid
here it is my code as far:

#covers the land surfaces but also on the ocean surfaces
isea4h9<- read.table("C:/.../isea4h9.txt", quote=""", comment.char="")
#the indexes of points only on land surfaces
idx_DGG_Land<- read.table("C:/.../idx_DGG_land.txt", quote=""", comment.char="")
DGG_land<-isea4h9(idx_DGG_land,: )
And I get an error that says that isea4h9 is not a function

As data frame can not work because has different rows. How can I get only DGG over land are needed??
Thank you in advance,
Varvara


#2

It'll be easier to help you if you can turn this into a self-contained reprex (short for reproducible example)—more detail, below. However, from what you've shown, it seems that you're, in effect, calling isea4h9 as though it were a function (parentheses after with an assignment operator to a new variable), which it either is not, or you haven't attached the package in which it is a function (given that it's what you name the data that you read in, I'm guessing it's the former).

install.reprex("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ, linked to below.


#3

If you are trying to merge the two data-frames row-by-row, while excluding all the data that is "offshore", then I think you should checkout the left_join() function from the dplyr package:

library(dplyr)
help(left_join)

The ability to achieve this will depend on what common data columns you have in both data-frames that uniquely identify each row. Another member of the dplyr "join" family may be required depending on the structure of your two data-frames.