Posts by Capitão Ahab • 565 points
9 posts
-
1
votes3
answers1888
viewsQ: A: Remove columns from a dataframe
How can I remove columns from a dataframe other than as follows? > df x y z 1 1 6 A 2 1 5 B 3 2 4 C 4 2 3 D 5 3 2 E 6 3 1 F > df <- data.frame(df[,1:2]) > df x y 1 1 6 2 1 5 3 2 4 4 2 3…
rasked Capitão Ahab 565 -
6
votes2
answers57
viewsQ: A: problems with Sort (NA)
I have a vector I want to order using sort but, in doing so, I do not see the missing values (NA). How to do it? Grateful. > x [1] "b" "c" "a" NA NA "b" "c" "a" NA NA "b" "c" "a" > sort(x) [1]…
-
2
votes2
answers443
viewsA: Reorder categories in a data frame
Another alternative to change your order: levels(df$categorias)=levels(df$categorias)[c(5,2,3,1,4)] levels(df$categorias) [1] "Muito baixa" "Baixa" "Média" "Alta" "Muito alta"…
-
6
votes1
answer4170
viewsQ: How to draw elements (select elements randomly) from an array?
How can I draw elements (select elements randomly) from a vector in the R? For example, I want to draw elements from this vector: numeros = c(1,2,45,63,29,100,999,23.45,76.1)…
rasked Capitão Ahab 565 -
5
votes2
answers431
viewsQ: Count elements in a range of values
Is there any more concise way to count all the elements of a vector (here in the example between 10 and 20) than the one presented? vector<int> v={1,2,3,45,24,10,20,-90,100,18,17,15,87}; int…
-
4
votes1
answer2492
viewsQ: Recursive functions in C++: examples
I am starting to learn C++ and I am currently focusing on recursive functions. I’ve seen some interesting examples, like the factorial calculation of a number, but I’d like to see other examples. I…
-
5
votes1
answer1131
viewsQ: Complex numbers in C++
I’m new to C++ and would like to know how to use complex numbers: double real[2]={2,5}; double imaginario[2]{7,9}; cout << "Soma: " << real[0]+real[1] << "+" <<…
-
5
votes1
answer4952
viewsQ: How to generate random values for a known distribution?
I am aware that, for example runif(1000,0,3) generates 1000 random values for a uniform distribution for x between 0 and 3. But how to do this for any probability density function? Every clue is…
-
9
votes1
answer196
viewsQ: Rstudio: do not automatically load variables in Environment
Whenever I start Rstudio some variables appear in environment. Is there any way to remove them automatically without using the famous rm(list=ls())? Thank you!…