Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have the following df
Case Points
A 2
B 3
C 8
I would the like to fetch the Points of a certain row. So lets say I have a list with rownumbers 2 and 3
rownumbers <- c(2,3)
Then I would like to the fetch the numbers 3 and 8. Could anybody tell me how to do this?
Try:
mydata[rownumbers,"Points"]
This answered in comments so I made it as community wiki
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I need help how to compare 2 columns in r studio but only in the first 5 observations
code used first was
damgeByage<-table(test$Vehicle_Age,test$Vehicle_Damage)
damgeByage
which give me all 186 observation but only want the first 10 oobservation of both columns
I
We can subset the data with row index
table(test[1:10, c("Vehicle_Age", "Vehicle_Damage")])
akrun's answer works or you can also use:
table(test$Vehicle_Age[1:10],test$Vehicle_Damage[1:10])
the table is also subsettable if you just wanted the first 10 rows of the results:
damgeByage<-table(test$Vehicle_Age,test$Vehicle_Damage)
damgeByage[1:10,]
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Alright, so one of my friends challenged me to get this done, but I just can't get very far....
What he asked me to do is to make a program that shows and counts ALL the possible parts of an entered number.
Example for 5:
1+1+1+1+1
2+1+1+1
3+1+1
4+1
5
3+2
2+2+1
I would like the program to be written in either C++ or some pseudocode, I wouldn't mind for either.
Anticipated thanks to you all!
Edit: Not duplicate. I requested a solution in c++; and the other one is in Python. Also, my question asks for ALL possible parts that added return the initial number.
For non zero partitions ( imagine boolean separators in array of 1)
2 ** (n-1)
This list would include both 2 + 3 and 3 + 2.
If you allow 0 then infinite.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have a dataset named SPT which has one column which consist 4 unique values-A,B,C,D, Now I have to create one more column which consist of 1 if first column had A, B otherwise 0.How to do it using ifelse command
Using ifelse:
SPT$new <- ifelse(SPT$col %in% c('A','B'),1,0)
Where new must be changed by the name of your new variable, and col by the name of the column that is storing the 4 letters
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Specifically, what the 3rd line of code does and how does 'train[train$label==1,]' work
train <- read.csv("../input/train.csv")
set.seed(71)
data <- sample(as.integer(row.names(train[train$label==1,])),100)
par(mfrow=c(10,10),mar=c(0.1,0.1,0.1,0.1)) ---- 3
It subsets the train dataset to only observations where label = 1.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
In R Studio I have a data set of 10 columns and I am required to add a further column (further variable) which is the average of 2 columns already there.
We have been told to use this formula: Tav = (Tmax+Tmin)/2 to create an extra column for the average of tmax and tmin but it does not work for me.
I attach an image showing my situation:
I have tried to search for a solution on this site and others but cannot seem to find anything that helps my specific situation.
Thanks for any help in advance.
Next time please read these first before posting: https://stackoverflow.com/help/how-to-ask
How to make a great R reproducible example?
Based on your screenshot, I think this is what you're after:
abp$tav <- (abp$tmax+abp$tmin)/2