Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Rhadoop Cloudera


Rhadoop Cloudera




I am trying to convert pig script to Rhadoop script.but I am unable to convert, struck some thing. Please help me.


-------pig script---------

batting = LOAD '/home/cloudera/Desktop/test/Batting.csv' using PigStorage(',');

runs = FOREACH batting GENERATE $0 as playerID, $1 as year, $8 as runs;

grp_data = GROUP runs by (year);

max_runs = FOREACH grp_data GENERATE group as grp,MAX(runs.runs) as max_runs;

join_max_run = JOIN max_runs by ($0, max_runs), runs by (year,runs); 

join_data = FOREACH join_max_run GENERATE $0 as year, $2 as playerID, $1 as runs; 

dump join_data;


-----Rhadoop script---

batting <- read.table(file="/home/cloudera/Desktop/test/Batting.csv",header=FALSE,sep=",",fill=TRUE,quote=NULL)


run <- batting[,c(1,2,10)]

max_runs <- run[,ax(v2)] --strucked


write.table(max_runs,"8.txt",quote=F, row.names=F, col.names=T,sep=",")