lundi 5 octobre 2015

ifelse on a dataframe in R,

I have a dataframe df

that looks like this

A B C 
1 2 3
2 5 6
3 8 9

the below line of code adds a new column and fills data accordingly.

df$Mean.Result1 <- ifelse(df[, "A"] > 0.05 & df[, "B"] > 0.05, "Equal", "")

I am using R with Splunk

and R in Splunk is not able to recognize the above format .

Is it right to do :

df.$Mean.Result1 <- ifelse(df.$A > 0.05 & df.$B > 0.05, "Equal", "")

How are the two pieces of code different? Will it effect the the speed of computation , my actual dataset has around 500 million rows and 400 columns.

Thanks.

Aucun commentaire:

Enregistrer un commentaire