How to SELECT with two CSV files/... on PostgreSQL? I have two CSV files which you can insert into the following PostgreSQL schema.
However, I cannot \COPY the data into the tables. 
Pseudocode


Let data_id=1
Show name and event_value from data.csv and log.csv, respectively 
Do this request from R with connection to PostgreSQL


Pseudocode in other words but not correct syntax

SELECT name, event_value 
    FROM data, log
    WHERE data_id=1;


CSV files

I enclose the header in double quotes in CSV files (thread PG COPY error: invalid input syntax for integer). 
data.csv where two integer/SERIAL + integer

"data_id", "event_value"
1, 777
1, 666
2, 111
4, 123 
3, 324
1, 245


log.csv where integer/SERIAL + string so I put enclosed the latter one in double quotes

"data_id", "name"
1, "leo"
2, "leopold"
3, "lorem"


PostgreSQL

Schema and workflow

DROP TABLE IF EXISTS data, log;    
CREATE TABLE data (
        data_id SERIAL NOT NULL, -- no primary key possible here, because possible have many events per data id
        event_value INTEGER NOT NULL
);
CREATE TABLE log (
        data_id SERIAL PRIMARY KEY NOT NULL,
        name INTEGER NOT NULL
);

-- https://stackoverflow.com/a/2987451/54964
-- https://soleil4716.wordpress.com/2010/08/19/using-copy-command-in-postgresql/
-- joanolo, HEADER
\COPY data FROM '/home/masi/Data/data.csv' DELIMITER ',' CSV HEADER;
\COPY log FROM '/home/masi/Data/log.csv' DELIMITER ',' CSV HEADER;


Work flow pseudocode


Start from clean table (drop old tables) and Create new tables
Insert two CSV files into the tables
Do SELECT now with connection to PostgreSQL from R


Output

masi@masi:~$ psql -f schema.sql 
psql:schema.sql:1: NOTICE:  table "data" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
COPY 6
psql:schema.sql:14: ERROR:  invalid input syntax for integer: " leo"
CONTEXT:  COPY log, line 2, column name: " leo"


I should not have mistakes in CSV files, based on the thread PG COPY error: invalid input syntax for integer. 

OS: Linux Debian 8.7
PostgreSQL: 9.4
Related: R sqldf/... approach in the thread How to select on CSV files by R sqldf/data.table/dplyr?
Error is obvious since you're intending to add characters to integer defined column. Just change datatype for name column in log table from integer to varchar(10)