Forest Inventory and Analysis (FIA) Data analysis in R.

#1

Does any one how to merge three FIA data (COND, PLOTSNAP, and TREE files) in one single file?

I realized i needed to provide more detail information. From FIA Datamart, we can manually download three csv files name (COND, PLOTSNAP, and TREE). These three large dataset have common variables that can be used to merge all three data into one. I have done this in SAS 9.3, and works great. BUT i am trying to use R to do similar work. Below i have provided SAS code that i used for merging. I would appreciate if you could help me converting SAS code into R.
In code below: T mean TREE, C means COND, and PS means PLOTSNAP csv file.

PROC SQL NOPRINT;
CREATE TABLE ALL AS
SELECT ,
T. CN AS T_CN,
C. CN AS C_CN,
PS. CN AS PS_CN,
FROM PLOTSNAP PS, COND C, TREE T
WHERE T.PLT_CN=C.PLT_CN
AND T.CONDID=C.CONDID
/
AND C.COND_STATUS_CD IN (1,2,3) */
AND PS.CN=C.PLT_CN
AND PS.CYCLE=C.CYCLE
AND PS.COUNTYCD=C.COUNTYCD
AND PS.PLOT=C.PLOT=T.PLOT
AND PS.INVYR=C.INVYR=T.INVYR;

How do I do this in R?

0 Likes

#2

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

0 Likes

#3

If you look at the FIA documentation, you'll see that you need to go through an SQL step, use R DBI and appropriate reader. Once you import the three files into data objects, assuming they have common keys, you can use normal tidy methods to combine them.

0 Likes

#4

I provided more details for the question.

0 Likes

#5

I have provided more details.

0 Likes

#6

This is still confusing, do you have already imported your csv files into a database? If that is the case then you can just run your sql query from R using an odbc connection, the way to do this depends on what database you are using.
If that is not the case, could you provide a direct link to those csv files?

0 Likes

#7

Like @andresrcs I'm still confused about the state of your data; I don't speak SAS, but from the additional detail, it looks like you're taking it off the Oracle back end, in which case you may want to take a look at ROracle, which will let you bring your FIA query into an R object.

0 Likes

closed #8

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes