Boolean operators && and ||

The shorter ones are vectorized, meaning they can return a vector, like this: The longer form evaluates left to right examining only the first element of each vector, so the above gives As the help page says, this makes the longer form “appropriate for programming control-flow and [is] typically preferred in if clauses.” So you … Read more

Categories r

Regular expression to limit number of characters to 10

I am trying to write a regular expression that will only allow lowercase letters and up to 10 characters. What I have so far looks like this: This does not work or compile. I had a working one that would just allow lowercase letters which was this: But I need to limit the number of … Read more

S3 Bucket action doesn’t apply to any resources

From IAM docs, http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Action Some services do not let you specify actions for individual resources; instead, any actions that you list in the Action or NotAction element apply to all resources in that service. In these cases, you use the wildcard * in the Resource element. With this information, resource should have a value like … Read more

When should I ever use file.read() or file.readlines()?

The short answer to your question is that each of these three methods of reading bits of a file have different use cases. As noted above, f.read() reads the file as an individual string, and so allows relatively easy file-wide manipulations, such as a file-wide regex search or substitution. f.readline() reads a single line of … Read more