First create a directory called Fun and move into that directory. In this directory make 2 files called red and blue. Check that you have made the correct files in Fun.
mkdir Fun
cd Fun
touch red blue
ls ./
Change the name of the file red to orange and delete the file blue. Now you should only have 1 file called orange in Fun.
mv red orange
rm blue
First generate mymatrix to be a matrix with lowercase letters a through o, 5 rows and 3 columns.
mymatrix <- matrix(data= letters[1:15], nrow=5, ncol=3)
How would you print the third column of this matrix using numeric indices and retaining the column format?
mymatrix[,3,drop=F]
Next generate mydf from the code below:
require('RCurl')
mlbweightdfurl <- 'http://goo.gl/rih9v9'
mlb.weight.df <- textConnection(getURL(mlbweightdfurl, followlocation = TRUE))
mlb.weight.df <- read.table(mlb.weight.df, header = TRUE)
mydf <- head(mlb.weight.df)
Show 2 ways you could print the third column of the data frame as a vector.
mydf[,3]
mydf[[3]]
Show 2 ways you could print the third column retaining the column format.
mydf[,3 ,drop=F]
mydf[3]
Will both of these ways work for a matrix as well? No, if you subset the matrix the second way it will return the third entry only. In a data frame this allows you to access the third "list" that makes up the data frame.
Well done. Thanks for noting that you can choose to either set drop = F to get an array/matrix back.
Use file orange in directory Fun created above in Question 1. Change the permissions so that someone in your group or outside of your group could read and write into the file orange.
chmod go+rwx /Fun
chmod go+rw /orange
Your answer is almost fine, but it is pretty aggressively permissive. You also made a typo. You could be more conservative. I'll demonstrate from the perspective of creating the directory and the file in your current working directory:
mkdir Fun
touch Fun/orange
chmod go+x Fun
chmod go+rw Fun/orange
Assuming the user has necessary permissions to the current working directory, you can share the path directly to the orange file and they could only read and write it. However, they couldn't read the contents of the Fun directory nor could they make new files in the Fun directory.