无法在R控制台中安装软件包

时间:2016-07-23 11:30:53

标签: r

在R中安装软件包时出现以下错误,有人可以为我提供解决方案吗?我已经尝试过在其他帖子上发布的解决方案,但没有任何帮助。

install.packages("ggplot2")

--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv');  

1 个答案:

答案 0 :(得分:0)

你可以尝试

import java.io.IOException;
/*import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;*/

import org.apache.commons.collections4.map.LinkedMap;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

public class FirstandLast {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        // TODO Auto-generated method stub


        Configuration conf = new Configuration();
        Path in=new Path(args[0]);
        FileSystem a=in.getFileSystem(conf);
        FileStatus s=a.getFileStatus(in);


        long len=s.getLen();

        if(len<=0){
            System.err.println("file size is empty");
            System.exit(-1);
        }
        Job j = new Job(conf,"First and last lines");
        j.setJarByClass(FirstandLast.class);
        j.setMapperClass(Map1.class);
        j.setReducerClass(Red1.class);
        j.setOutputKeyClass(IntWritable.class);
        j.setOutputValueClass(Text.class);
        j.setInputFormatClass(TextInputFormat.class);
        j.setOutputFormatClass(TextOutputFormat.class);

        Path outputPath = new Path(args[1]);

      FileInputFormat.addInputPath(j, new Path(args[0]));
      FileOutputFormat.setOutputPath(j,outputPath);
        //deleting the output path automatically from hdfs so that we don't have delete it explicitly

        outputPath.getFileSystem(conf).delete(outputPath);

            //exiting the job only if the flag value becomes false

      System.exit(j.waitForCompletion(true)?0:1);

    }

    public static class Map1 extends Mapper<LongWritable, Text, IntWritable, Text> {
        static int count=0;

        public void map(LongWritable key, Text value , Context con) throws IOException, InterruptedException{
            count++;
            String line=value.toString();

                con.write(new IntWritable(1), new Text(count+"\t"+line));



        }
    }

public static class Red1 extends Reducer<IntWritable, Text, IntWritable, Text> {

    @Override
    public  void reduce(IntWritable key, Iterable<Text> value,
            Reducer<IntWritable, Text, IntWritable, Text>.Context con)
            throws IOException, InterruptedException {

        LinkedMap<String,String> map=new LinkedMap<String, String>();
        String s="";
        for(Text a:value){
            s=a.toString();
            map.put(s, null);
        }
        String first[]=map.firstKey().split("\t");
        String last[]=map.lastKey().split("\t");
        con.write(new IntWritable(Integer.parseInt(last[0])),new Text(last[1]));
        con.write(new IntWritable(Integer.parseInt(first[0])),new Text(first[1]));


    }

    }

    }